diff --git a/MAC/Navigator/scripts/libs/nav_fw/fwTreeView.ctl b/MAC/Navigator/scripts/libs/nav_fw/fwTreeView.ctl index 900c976dbe8c952ae5d5fdd5a73441cc9c9bf979..a058f11651f096b5a54174a484b28903c3762a76 100644 --- a/MAC/Navigator/scripts/libs/nav_fw/fwTreeView.ctl +++ b/MAC/Navigator/scripts/libs/nav_fw/fwTreeView.ctl @@ -45,7 +45,6 @@ /** @name "constants" */ - // indexes to access node object const int fwTreeView_HANDLE = 1; const int fwTreeView_LEVEL = 2; @@ -406,6 +405,8 @@ fwTreeView_defaultSelect(unsigned pos) */ fwTreeView_draw(string referenceName = "") { + + //DebugTN("List B4: ", list.items); unsigned branchMarkLen = strlen(fwTreeView_BRANCH_MARK_COLLAPSED); //==strlen(expandeBranchMark) int spaceCnt, i, imax; string item; @@ -413,7 +414,7 @@ fwTreeView_draw(string referenceName = "") int visibleNodes=0; // erase list: -// setValue(referenceName + "list", "deleteAllItems"); + //setValue(referenceName + "list", "deleteAllItems"); getValue(referenceName + "list","itemCount",existingNodes); @@ -460,6 +461,7 @@ fwTreeView_draw(string referenceName = "") setValue(referenceName + "list","deletePos",deletePos); getValue(referenceName + "list","itemCount",existingNodes); } + //DebugTN("List After draw: ", list.items); } diff --git a/MAC/Navigator/scripts/libs/nav_fw/gcfnav-configuration-functions.ctl b/MAC/Navigator/scripts/libs/nav_fw/gcfnav-configuration-functions.ctl index 4417a44fb0e0b739b2958f083ce57b5f3cf8d2c0..75ed2340987d7e044d30fc8692580439999ef337 100644 --- a/MAC/Navigator/scripts/libs/nav_fw/gcfnav-configuration-functions.ctl +++ b/MAC/Navigator/scripts/libs/nav_fw/gcfnav-configuration-functions.ctl @@ -1267,3 +1267,145 @@ navConfigAddRemoveSubView() PanelOff(); } + +/////////////////////////////////////////////////////////////////////////// +//Function navConfigSubscribePSIndicationChange +// +// subscribes to the __pa_PPSIndication DP of the datebase to monitor +// possible treechanges. +// +// Added 6-2-2007 A.Coolen +/////////////////////////////////////////////////////////////////////////// +void navConfigSubscribePSIndicationChange() { + + // Routine to try to force a treeupdate everytime a datapoint is deleted or added + // this is indictaed by a line like: d|someDatapoint or e|somedatapoint + // in the __pa_PPSIndication DP in any of the stations or the mainCU's + + // query to trigger an action everytime such a point is changed + string query = "SELECT '_original.._value' FROM '__pa_PSIndication' REMOTE ALL"; + + dpQueryConnectAll("navConfigPSIndicationTriggered",false,"MainPSIndicationChange",query); +} + + +bool inRefList(string &datapoint, dyn_string &reference, bool &isReference) { + + dyn_string refOut; + isReference=FALSE; + LOG_DEBUG("Lookup : ", datapoint); + + for (int i= 1; i<= dynlen(g_referenceList); i++) { + refOut = strsplit(g_referenceList[i],"="); + LOG_DEBUG("refOut[2] : ",refOut[2]); + if (strpos(datapoint,refOut[2]) > -1) { + isReference=TRUE; + strreplace(datapoint,refOut[2],refOut[1]); + break; + } + } + reference = refOut; + return isReference; +} + + +/////////////////////////////////////////////////////////////////////////// +//Function navConfigPSIndicationTriggered +// +// Callback where a trigger of __pa_PPSIndication is handled. +// +// Added 6-2-2007 A.Coolen +/////////////////////////////////////////////////////////////////////////// +void navConfigPSIndicationTriggered(string identifier, dyn_dyn_anytype result) { + + // PSIndication was changed For now we only want to set the triggerUpdate DP in all + // navigatorInstances to activate the treeUpdates. + // The info however also contains a d (=delete) or a e (=enable) + // and the datapoint that was actually involved. I will save those now, they are not used, + // but might come in handy in a later stage. + + + if (g_initializing) { + return; + } + int i,j; + string action = ""; + string datapoint = ""; + string database = ""; + + for(i=2;i<=dynlen(result);i++) { + + database=dpSubStr(result[i][1],DPSUB_SYS); + + dyn_string vals= strsplit(result[i][2],"|"); + + action = vals[1]; + datapoint = database+vals[2]; + } + + +// DebugTN("*******************************************"); +// DebugTN("g_itemID2datapoint : ",g_itemID2datapoint); +// DebugTN("g_datapoint2itemID : ",g_datapoint2itemID); +// DebugTN("g_referenceList : ",g_referenceList); +// DebugTN("result in trigger : ", result); +// DebugTN("Navigator instance: ",DPNAME_NAVIGATOR+navConfigGetNavigatorID()); +// DebugTN("TreenodeCount : ",fwTreeView_getNodeCount()); +// DebugTN("*******************************************"); + + // Check if the datapoint contains a reference and if this is the case, change the datapoint to the + // full refered path. + dyn_string reference; + bool dpIsReference; + inRefList(datapoint, reference, dpIsReference); + + // now we have the full datapoint path, and we need to determine what to do\ + // based on the action + // (e) there is a new enabled datapoint, we need to look if it is in the current active tree + // if it is, then nothing needs to be done. if it is not we need to reload that part of the tree. + // + // (d) a datapoint had been removed from the tree, we need to check if it was available in our tree, + // if not, then nothing needs to be done, if it was we need to collapse the tree from the datapoint that was + // removed + + + // first check if We have the point in our lists anyway + long nodeID = getNodeFromDatapoint(datapoint); +// DebugTN("Node found from datapoint : ", nodeID); + + //Check if action is enable and if point is allready in tree or not + if (nodeID > 0 && action = d) { + + + // check if action = delete and if point is still available in the tree. + } else if (nodeID <= 0 && action = e){ + + + } else { +// DebugTN("Illegal action in combination with nodeID"); + } + +} + + +/////////////////////////////////////////////////////////////////////////// +//Function navConfigTriggerAllNavigatorRefresh +// +// Find out all navigator instances and trigger the triggerUpdate DP +// causing an update of the navigator. +// +// Added 6-2-2007 A.Coolen +/////////////////////////////////////////////////////////////////////////// +void navConfigTriggerAllNavigatorRefresh() { + + // Routine to find all Navigator Instances and set the triggerUpdate + + dyn_dyn_anytype tab; + int i; + string query = "SELECT '_original.._value' FROM '__navigator*.triggerUpdate'"; + dpQuery(query, tab); + + for(i=2;i<=dynlen(tab);i++) { + dpSet(tab[i][1], 1); + } +} \ No newline at end of file diff --git a/MAC/Navigator/scripts/libs/nav_fw/gcfnav-functions.ctl b/MAC/Navigator/scripts/libs/nav_fw/gcfnav-functions.ctl index b396ce85f774cd78340c394d4bf99892f10b683b..7eecc11059ab6124d08c262323b7dd2683240188 100644 --- a/MAC/Navigator/scripts/libs/nav_fw/gcfnav-functions.ctl +++ b/MAC/Navigator/scripts/libs/nav_fw/gcfnav-functions.ctl @@ -168,6 +168,7 @@ void changeSelectedPosition(string newDatapoint) } } + fwTreeView_draw(); g_curSelNode = nodeID; //update global info fwTreeView_setSelectedPosition(fwTreeView_Tree2ViewIndex(nodeID)); @@ -493,7 +494,7 @@ long treeAddNode(long parentId, int level, string text) /////////////////////////////////////////////////////////////////////////// void treeAddDatapoints(dyn_string names) { - LOG_DEBUG("treeAddDatapoints: ", LOG_DYN(names)); + LOG_DEBUG("treeAddDatapoints: ",names); int namesIndex; dyn_string addedDatapoints; string systemName; @@ -562,11 +563,19 @@ void treeAddDatapoints(dyn_string names) string addingDPpart = systemName; for (pathIndex = 0; pathIndex <= dynlen(dpPathElements); pathIndex++) { - // Check if the item already exists + // Check if the item already exists as normal dpe or as a reference if (mappingHasKey(g_datapoint2itemID, addingDPpart)) { addedNode = g_datapoint2itemID[addingDPpart]; } + else if (mappingHasKey(g_datapoint2itemID, addingDPpart+" ->")) + { + addedNode = g_datapoint2itemID[addingDPpart+" ->"]; + } + else if (mappingHasKey(g_datapoint2itemID, addingDPpart+" ->>")) + { + addedNode = g_datapoint2itemID[addingDPpart+" ->>"]; + } else { // item does not exist @@ -621,18 +630,49 @@ void treeAddDatapoints(dyn_string names) // special case: __childDp if (strpos(elementName,"__childDp") >= 0) { - string referenceContent; - if (dpAccessable(addingDPpart + "." + elementName)) - { - dpGet(addingDPpart + "." + elementName, referenceContent); - // add the reference to the global list. This list is inspected on several occasions, e.g. when - // the user changes the selected item in the tree - dynAppend(g_referenceList, addingDPpart + "=" + referenceContent); - LOG_TRACE("Add reference: ", addingDPpart + "=" + referenceContent); - } - else + if (strpos(addingDPpart, " ->") < 0) { - LOG_WARN("Unable to get reference info for datapoint",addingDPpart + "." + elementName); + dyn_string referenceContent; + if (dpAccessable(addingDPpart + "." + elementName)) + { + dpGet(addingDPpart + "." + elementName, referenceContent); + } + else + { + LOG_WARN("Unable to get reference info for datapoint",addingDPpart + "." + elementName); + } + for (int k = 1; k <= dynlen(referenceContent); k++) + { + dyn_string referenceSplit = strsplit(referenceContent[k], "="); + if (dynlen(referenceSplit) >= 2) { + string referenceText = addingDPpart + referenceSign(referenceSplit[2]); + + //only add reference if not allready present... + if (! dynContains(g_referenceList,referenceText + "=" + referenceSplit[2])) { + dynAppend(g_referenceList, referenceText + "=" + referenceSplit[2]); + } + + + // Change internalNodeMapping Name to reference name + int index = dynContains(internalFullDPName,addingDPpart); + dynRemove(internalFullDPName,index); + dynInsertAt(internalFullDPName, referenceText,index); + + // Remove the old datapoint + int index = dynContains(names,addingDPpart); + dynRemove(names,index); + dynInsertAt(names, referenceText,index); + + + LOG_TRACE("Add reference: ", referenceText); + + + // Because this is a reference, the DP's of the branche must be retrieved and + // add to the dyn_string names, for correct build-up of the tree. + dyn_string refResources = navConfigGetResources(referenceText, 2); + dynAppend(names, refResources); + } + } } } else @@ -651,15 +691,23 @@ void treeAddDatapoints(dyn_string names) } for (int k = 1; k <= dynlen(referenceContent); k++) { + LOG_TRACE("ref. content to split: " + referenceContent[k]); dyn_string referenceSplit = strsplit(referenceContent[k], "="); - string referenceText = addingDPpart + "_" + referenceSplit[1] + referenceSign(referenceSplit[2]); - dynAppend(g_referenceList, referenceText + "=" + referenceSplit[2]); - dynAppend(names, referenceText); - LOG_TRACE("Add reference: ", referenceText); - // Because this is a reference, the DP's of the branche must be retrieved and - // add to the dyn_string names, for correct build-up of the tree. - dyn_string refResources = navConfigGetResources(referenceText, 2); - dynAppend(names, refResources); + if (dynlen(referenceSplit) >=2) { + string referenceText = addingDPpart + "_" + referenceSplit[1] + referenceSign(referenceSplit[2]); + + //only add reference if not allready present... + if (! dynContains(g_referenceList,referenceText + "=" + referenceSplit[2])) { + dynAppend(g_referenceList, referenceText + "=" + referenceSplit[2]); + } + dynAppend(names, referenceText); + // Because this is a reference, the DP's of the branche must be retrieved and + // add to the dyn_string names, for correct build-up of the tree. + dyn_string refResources = navConfigGetResources(referenceText, 2); + dynAppend(names, refResources); + } else { + LOG_DEBUG("No reference info found"); + } } } } @@ -695,6 +743,8 @@ void treeAddDatapoints(dyn_string names) } } } + LOG_DEBUG("g_itemID2datapoint : "+g_itemID2datapoint); + LOG_DEBUG("g_datapoint2itemID : "+g_datapoint2itemID); } @@ -976,6 +1026,7 @@ void Navigator_HandleEventInitialize() navConfigSetNavigatorID(navID); navConfigIncreaseUseCount(); navConfigSubscribeUpdateTrigger("Navigator_HandleUpdateTrigger"); + navConfigSubscribePSIndicationChange(); navPMLinitialize(); @@ -1498,16 +1549,7 @@ TreeView_OnSelect(unsigned pos) } if (!parentDatapointIsReference || (parentDatapointIsReference && dpAccessable(datapointPath + "__enabled"))) { - // set the tree selection to the referenced item - if(parentDatapointIsReference) - { - LOG_INFO("Navigating to referenced datapoint:",datapointPath); - navConfigTriggerNavigatorRefreshWithDP(datapointPath); - } - else - { - TreeCtrl_HandleEventOnSelChange(pos); - } + TreeCtrl_HandleEventOnSelChange(pos); } else {