hook_<libraryPrefix>_alterInfoAreaDisplay()
This function allows the icon-ID, and therefore the icon displayed in an information area, to determine when the value of the data point element that is connected to an information area changes. Which data point elements are connected to a certain information area is determined via the function hook_<LibName>_getInfoAreaDPEs().
Synopsis
int hook_ <libraryPrefix>_
alterInfoAreaDisplay(
anytype aParams);
Parameters
Parameter | Description |
---|---|
aParams |
aParams[1] = Number of the information area aParams[2] = Mapping that contains all datapoint elements of the information area with those values. |
Example
In the following example an icon is shown for a symbol (see Information Areas of a Symbol) depending on the value of a data point element. In order to display the icons for the information area of a symbol, execute the following steps.
- Implement hook_<Standard Library Projectname>_getInfoAreaDPEs of
the script Standard Library Projectname/scripts/libs/<Standard Library
Projectname>_hook.ctl for the corners 1 and 2 of the information area
of a symbol and set the variable bLocalInfoAreaUseDefault=false - see the code
in bold below:
dyn_string hook_motor_getInfoAreaDPEs(anytype aParams) { // get parameters from anytype string sDp = aParams[1]; sDp = dpSubStr(sDp, DPSUB_SYS_DP_EL); int iInfoAreaNr = aParams[2]; bool bUsePanelGlobalVariables=aParams[3]; //Workaround for AjaxWebUi - we cannot use panel global variables for callbacks bool bLocalInfoAreaUseDefault=TRUE; string stemp, sOperationMode=""; int iType; dyn_string dsDPE; string sAddDot=""; if(sDp[strlen(sDp)-1]!=".") sAddDot="."; if (DebugInfos) DebugN("hook_getInfoAreaDPEs", sDp, sAddDot, strlen(sDp), sDp[strlen(sDp)-1]); sOperationMode=hook_getOperationModeElement(sDp); switch (iInfoAreaNr) { case 1: if (dpExists(sDp+sAddDot+"state.runMode")) { dynAppend(dsDPE, sDp+sAddDot+"state.runMode"); // not default handling bLocalInfoAreaUseDefault=false; // default handling } break; case 2: if (dpExists(sDp+sAddDot+"state.open")) { dynAppend(dsDPE, sDp+sAddDot+"state.open"); // not default handling bLocalInfoAreaUseDefault=false; } else if (dpExists(sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr)) dynAppend(dsDPE, sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr); // default handling break; case 3: if (gUseNotes && dpExists (sDp+sAddDot+"general.note")) // if notes are used and the DPE exists, dont use default handling for this infoArea { dynAppend(dsDPE, sDp+sAddDot+"general.note"); bLocalInfoAreaUseDefault=false; } else { if (dpExists(sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr)) dynAppend(dsDPE, sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr); } break; case 4: if (dpExists(sDp+sAddDot+sOperationMode+".auto") && dpExists(sDp+sAddDot+sOperationMode+".manual") && dpExists(sDp+sAddDot+sOperationMode+".local") && dpExists(sDp+sAddDot+sOperationMode+".remote")) // if OperationMode DPEs exists, dont use default handling for this infoArea { dynAppend(dsDPE, sDp+sAddDot+sOperationMode+".auto"); dynAppend(dsDPE, sDp+sAddDot+sOperationMode+".manual"); dynAppend(dsDPE, sDp+sAddDot+sOperationMode+".local"); dynAppend(dsDPE, sDp+sAddDot+sOperationMode+".remote"); bLocalInfoAreaUseDefault=false; } else { if (dpExists(sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr)) dynAppend(dsDPE, sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr); } break; case 5: stemp=hook_getInvalidElement(sDp); if (dpExists(sDp+sAddDot+stemp)) // if invalid DPE exists, dont use default handling for this infoArea { dynAppend(dsDPE, sDp+sAddDot+hook_getInvalidElement(sDp)+":_original.._invalid"); bLocalInfoAreaUseDefault=false; } else { if (dpExists(sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr)) dynAppend(dsDPE, sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr); } break; case 6: stemp=hook_getAlertElement(sDp); if (dpExists(sDp+sAddDot+stemp)) // if alert DPE exists, dont use default handling for this infoArea { dpGet(sDp+sAddDot+stemp+":_alert_hdl.._type", iType); // check also if there is an _alert_hdl if (iType!=0) { dynAppend(dsDPE, sDp+sAddDot+stemp+":_alert_hdl.._act_state_color"); bLocalInfoAreaUseDefault=false; } } if (bLocalInfoAreaUseDefault==true) { if (dpExists(sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr)) dynAppend(dsDPE, sDp+sAddDot+"infoArea.mode_"+iInfoAreaNr); } break; default: break; }
-
Define the icons for the _STDLIB_Modes_1 and 2 of the data point type _STDLIB_Mode.
-
Implement hook_<Standard Library Projectname>_alterInfoAreaDisplay of the script Standard Library Projectname/scripts/libs/<Standard Library Projectname>_hook.ctl for the corners 1+2.
int hook_motor_alterInfoAreaDisplay(anytype aParams) { int InfoAreaNr = aParams[1]; mapping dpesForInfoArea=aParams[2]; dyn_string dsDPEs = mappingKeys(dpesForInfoArea); string sDP = dpSubStr(dsDPEs[1],DPSUB_SYS_DP); DebugN("hook_stdlib_alterInfoAreaDisplay",aParams); if(InfoAreaNr == 1) //use special icon for info area 1 depending on DPE state.runMode { return dpesForInfoArea[sDP+".state.runMode:_online.._value"]; //the icon number corresponds to the value of the DPE runMode } if(InfoAreaNr == 2) //use special icon for info area 1 depending on DPE state.open return dpesForInfoArea[sDP+".state.open:_online.._value"]+1; //open.state is used to calculate the icon number return -1; //no specific implementation, use the default of the standard library }
- Open the symbol and change the values of the data point elements state.open and state.runMode. The icons for the symbol are changed.
Return Value
If -1 is returned, then the default implementation is used. The default implementation is described in the function hook_<LibName>_getInfoAreaDPEs(). Otherwise the corresponding icon ID-number of the given information area is returned.