unCoreInternals 9.3.0
|
When unDeviceTree.pnl initializes, inside the initPanel() function there is a call to unTreeDeviceOverview_initializeTreeDeviceWidget(b32SelectInitState, b32SortByInitState, dsExcludedDeviceType, sInitFunction, sCBFunction, exInfo); in unTreeDeviceOverview.ctl.
The callback parameter sCBFunction is set to unTreeDeviceOverview_displayCallBackTreeDeviceWidget().
In unTreeDeviceOverview_initializeTreeDeviceWidget, the code dpConnect(sCBFunction, false, sTreeDevOvDp+".command", /*sTreeDevOvDp+".filter", sTreeDevOvDp+".view", */sTreeDevOvDp+".systemName"), is connecting to the _unTreeDevOv DatapointType (_UnTreeDevOv_unicosHMI_1_2 datapoint, for example). Therefore, each time that there is a change in .command or .systemName dpe, the unTreeDeviceOverview_displayCallBackTreeDeviceWidget() is triggered.
In unTreeDeviceOverview_displayCallBackTreeDeviceWidget, there are 3 scenarios DEVUN_ADD_COMMAND, DEVUN_DELETE_COMMAND, and DEVUN_APPLYFILTER_COMMAND. Depending on the scenario, the filter does different actions for the devices (build/apply, add, delete, etc.).
In unTreeDeviceOverview_initializeTreeDeviceWidget (unTreeDeviceOverview.ctl), the function to get all the front-ends unGenericDpFunctions_getFrontEndDeviceType is called.
In the initPanel() function of unDeviceTree.pnl, a dpQueryConnectSingle is performed for distributed systems.
string query = "SELECT '.config:_original.._value' FROM '*' WHERE _DPT = \"_UnDistributedControl\""; int iRes = dpQueryConnectSingle("unDistConfigChangedCB",true,"Trace Changes in _UnDistributedControl DPs",query,3000);
Every time that there is a change in the distributed systems, the function unDistConfigChangedCB() is called. unDistConfigChangedCB() —> applicationListChangedCB() —> unTreeDeviceOverview_buildSubsystemList()
The initPanel() function finishes with a call to presetApplicationFilter, which calls to unApplicationFilter_registerAppListChangedCB() —> applicationListChangedCB. The unApplicationFilter_registerAppListChangedCB function sets the following dpConnect:
dpConnect(sWorkFunction, false, getSystemName() + UN_APPLICATION_DPNAME + "." + g_unicosHMI_sApplicationListChangedDpe);
applyFilter() —> showFilter() —> unTreeDeviceOverview_triggerDisplay() (in unTreeDeviceOverview.ctl) —> _unTreeDeviceOverview_triggerDisplay() —> dpSet(sTreeDevOvDp+".command", iCommand, sTreeDevOvDp+".systemName", sSystemName);
The function _unTreeDeviceOverview_triggerDisplay triggers the execution of the callback handling the tree device unTreeWidget display, which effectively refreshes or displays the unTreeDevice in the panel with the introduced filter values.
An example of sTreeDevOvDp datapoint is _UnTreeDevOv_unicosHMI_1_2 which belongs to the DPT _unTreeDevOv.
In the main() of unDeviceListUpdate.ctl, there is a call to unDeviceListUpdate_registerTriggerUpdate() with unDeviceListUpdate_applicationTrigger as parameter. There are a few dpConnects calls there, but the important part is that in unDeviceListUpdate_applicationTrigger(), unDeviceListUpdate_getAndWriteDevice() is called.
In unDeviceListUpdate_getAndWriteDevice, there is a call to _unTreeDeviceOverview_getDeviceList (in unTreeDeviceOverview.ctl), and then to unDeviceListUpdate_triggerHMI(DEVUN_ADD_COMMAND, sSystemName) which updates the .command and .systemname dpe of the _unApplication:
dpSet("_unApplication.deviceList.command", iCommand, "_unApplication.deviceList.systemName", sSystemName);
When initializing the HMI (old or new), there is a call to unGraphicalFrame_initHMI() (defined in unGraphicalFrame.ctl). Inside the function unGraphicalFrame_initHMI() there is a dpConnect to update the device list whenever there is a change:
dpConnect(g_dsHMIFunctions[HMI_APPLICATION_UPDATE_FUNCTION], false, "_unApplication.deviceList.command", "_unApplication.deviceList.systemName");
whose callback parameter g_dsHMIFunctions[HMI_APPLICATION_UPDATE_FUNCTION] is equal to the function unicosHMI_applicationUpdateDeviceList.
unicosHMI_applicationUpdateDeviceList defined in unicosHMI.ctl, calls the unTreeDeviceOverview_loadAll() (in unTreeDeviceOverview.ctl) and unGraphicalFrame_triggerDisplay(DEVUN_ADD_COMMAND, sSystemName) (in unGraphicalFrame.ctl) functions.
The unGraphicalFrame_triggerDisplay() calls _unTreeDeviceOverview_triggerDisplay() when g_dsTreeDeviceOverview_triggerDisplayDP is not empty (i.e. the deviceTreeOverview has been initialized). The global variable g_dsTreeDeviceOverview_triggerDisplayDP has length 0 unless it has been initialized in unTreeDeviceOverview_initializeTreeDeviceWidget() in the unTreeDeviceOverview.ctl:
dynAppend(g_dsTreeDeviceOverview_triggerDisplayDP, sTreeDevOvDp);
As it was explained in the section above, _unTreeDeviceOverview_triggerDisplay sets the .command and .systemName dpe of the datapoint whose DPT is _unTreeDevOv:
dpSet(sTreeDevOvDp+".command", iCommand, sTreeDevOvDp+".systemName", sSystemName);
When importing a device, the function dpConnect(sCBFunction, false, sTreeDevOvDp+".command", /*sTreeDevOvDp+".filter", sTreeDevOvDp+".view", */sTreeDevOvDp+".systemName"); defined in unTreeDeviceOverview_initializeTreeDeviceWidget is triggered. The refresh is triggered because the _UnTreeDevOv_unicosHMI_1_2 .command is set to 1 (which means DEVUN_ADD_COMMAND). The .command and .systemName in _UnTreeDevOv are changed by _unTreeDeviceOverview_triggerDisplay function (it is only triggered when the deviceTreeOverview is open). The g_dsTreeDeviceOverview_triggerDisplayDP has length 0 unless the devicetreeoverview has been initialized dynAppend(g_dsTreeDeviceOverview_triggerDisplayDP, sTreeDevOvDp) (explained above).
The sCBFunction parameter in unTreeDeviceOverview_initializeTreeDeviceWidget is unTreeDeviceOverview_displayCallBackTreeDeviceWidget, so the logic goes through case DEVUN_ADD_COMMAND and builds/applies the filter.
The actual device list is updated and refreshed when calling unTreeDeviceOverview_applyFilter() in the unTreeDeviceOverview_selectSortDeviceList() function, which calls unTreeDeviceOverview_getSelectedDeviceList().
SELECT '_online.._value' FROM '*.statusInformation.selectedManager' WHERE _DPT IN ("CPC_AnaDO","CPC_AnaDig","CPC_Analog","CPC_AnalogAlarm","CPC_AnalogInput","CPC_AnalogOutput","CPC_AnalogParameter","CPC_AnalogStatus","CPC_Controller","CPC_DigitalAlarm","CPC_DigitalInput","CPC_DigitalOutput","CPC_DigitalParameter","CPC_Local","CPC_MassFlowController","CPC_OnOff","CPC_ProcessControlObject","CPC_RcpBuffers","CPC_SteppingMotor","CPC_SumAlarm","CPC_Word2AnalogStatus","CPC_WordParameter","CPC_WordStatus","FGC2_LHC_PC","GenericDevice","UnRcpClass","UnRcpInstance") && _DP LIKE "*-*-*-*-*"" - In the function unDeviceListUpdate_getAndWriteDevice(), the function _unTreeDeviceOverview_getDeviceList is called first, i.e. the datapoints are used to obtain the information about the device list. It seems that call and comparison against _unTreeDeviceOverview_getDeviceListFomFile done by unDeviceListUpdate_compareDeviceList() is never performed. Then, a call to unDeviceListUpdate_writeFile() is performed to update the list of devices in the file. To summarize, the query to obtain the information from the datapoints is used when performing an importation (or deletion), triggered by the unDeviceListUpdate.ctl script. The information from the file is used in unicosHMI.ctl and unGraphicalFrame.ctl when initializing the HMI. @section autotoc_md171 Scalability of devices - The function that handles the load of the devices when a node in the device tree is left clicked (in the left side of the panel) is handleTriggerCommandThread in unDeviceTree.pnl, which relies on addNodeInTree. In addNodeInTree, the loop for takes a long time to process if there are a lot of devices. In concrete, it takes long time to process unTreeWidget_setPropertyValue inside the loop, the other two functions are quick. The case "addNode" goes to unTreeWidget_addNodeInTree (in unTreeWidget.ctl), which calls unTreeWidget_getNodeCompositeLabelAndParentKey and unTreeWidget_getNodeNameAndNodeDp (function which is triggered the same number of times as devices are to be added as node in the tree). - The widget representation load is triggered by function panelGeneral_nodeLeftClick in treeDeviceOverview.pnl. Here, the function takes some time to process if there is a lot of devices, because it triggers the function unTreeDeviceOverview_getDeviceWidgetList, where there is a for loop calling the function unGenericDpFunctions_getDeviceWidget as many times as devices are being processed. - The table being load in the snapshot is triggered by function panelGeneral_snapshot(). The function starts to load the info for the devices when calling the function unTreeDeviceOverview_displayList().This can take some time when having a lot of devices because there is a for loop iterating as many times as devices are being processed. @section autotoc_md172 Miscellaneous notes - The datapoints in <em>unTreeDevOv are created in function unGraphicalFrame_initHMI when calling unConfigGenericFunctions_createDp using sTreeDevOvDp as parameter. The name comes from sTriggerName = DEVUN_DPPREFIX+sModule+""+myManNum() - The .dat files are created or updated when the script unDeviceListUpdate.ctl runs. In particular, they are created in unDeviceListUpdate_writeFile —> fFile = fopen(sFileName, "w");
Using panel references, the composition of the deviceTreeOverview panel is the following:
unTreeDeviceOverview.pnl ===> treeDeviceOverview.pnl ===> unDeviceTree.pnl ===> unTreeWidget.pnl
The following functions in the unTreeDeviceOverview.ctl script use and rely on the corresponding C++ functions to get data:
_unTreeDeviceOverview_getDeviceList —> CtrlTreeDeviceOverview_getDeviceList unTreeDeviceOverview_getSelectedDeviceList —> CtrlTreeDeviceOverview_getSelectedDeviceList unTreeDeviceOverview_sortSelectedDeviceList —> CtrlTreeDeviceOverview_sortSelectedDeviceList
The functions belonging to the unTreeDeviceOverview.ctl script are used in:
The global variables g_m_sTreePVSSSystem, g_m_dsTreeFrontEnd, g_m_dsTreeFrontEndDp, g_m_dsTreeFrontEndType, g_m_dsTreeApplication, g_m_dsTreeFrontEndApplication, g_m_dsTreeSubsystem1, g_m_dsTreeSubsystem2 that are defined in unicos_declarations.ctl are used in: