Genie Name: genericlist
Genie Library: sa_controls
System Project: SA_Controls
The Generic List Genie (named "genericlist") allows you to display a custom generated list of information on a page in a pre-defined format with a header row and scroll bars. It is a variation of the Generic List Vertical Genie, which produces a list with no header row and just a vertical scroll bar.
Complete the following properties for the Genie in the Genie Properties dialog box.
Select the Genie and double-click on it to view its parameters. The parameters are used as described in the table below:
Parameter |
Description |
---|---|
AN |
This is automatically populated and matches the AN in the Genie Properties dialog box. This cannot be modified. |
GenericListFillFunction |
Specify the user Cicode function to be called at runtime to populate the list by passing the list’s AN to the function. The function needs to retrieve the data to be displayed. For example, AlarmPage_GetReferences. |
OnRightClickFunction |
Allows the user right-click on a row within the alarms list and perform operations displayed on the right-click menu. |
OnColumnSelectedFunction |
Allows you to select a column. |
OnColumnReorderedFunction |
Allows you reorder the columns displayed. |
OnColumnResizedFunction |
Allows you to resize the columns displayed. |
For these Genies to work at runtime, they require some arrays to be pre-configured before animation begins. In the Page Properties dialog box, Events tab, select the following event options and specify the required Cicode command.
Parameter |
Description |
Example |
---|---|---|
On Page Entry |
This code initializes the list array to be populated when the page is displayed. |
FUNCTION ListInfo_Init()
|
On Page Exit |
When the user exits the page, clear the information stored in the array. |
FUNCTION ListInfo_Exit()
|
FUNCTION ListInfo_Exit()
//Clear Equipment List
INT hEquipRefArray = PageGetInt("__EquipRefArray");
ArrayDestroy(hEquipRefArray);
ArrayDestroyByAn(DspGetAnFromName("MyList"));
Debug_Trace("ReferenceInfo", "ListInfo_Exit", "Closing Infoe_Default page.", TRACE_Information);
END
FUNCTION ListInfo_Init()
INT hEquipRefArray;
INT nListAN = DspGetAnFromName("MyList");
INT nListHeight = 160;
INT nListRowHeight = 24;
INT nListWidth = 370;
INT nListCreatedFlag = 0;
STRING sFontPostfix = "";
STRING sResolution = "HD1080";
Debug_Trace("ListInfo", "ListInfo_Init", "Initializing Info_Default page.", TRACE_Information);
hEquipRefArray = ArrayCreate("EquipRef_" + nReferencesListAN:#, 5, 1000); // Max of 1000 equip references
PageSetInt("__EquipRefArray", hEquipRefArray); //Cache the array handle
_ArrayView_Initialize(); //Initialize the array
nListCreatedFlag = GenericListCreate(nListAN, nListWidth-14, nListHeight , nListRowHeight, 1, "SideEquipRef", DspFontHnd("SA_AlmRow" + sFontPostFix), DspFontHnd("SA_AlarmHeaderB" + sFontPostFix));
ArraySetIntByAn(nListAN, 5, 1, ARRAY_INFORMATION_ROW, 2);
Debug_Trace("ListInfo", "ListInfo_Init", "List_Default page is initialized with " + nListCreatedFlag:#, TRACE_Information);
END
FUNCTION ReferenceInfo_GetData(INT nListAN, STRING sEquipmentContext) INT hSession; INT nRecords; INT nStatus; INT nRow; INT nLength; INT nOffset; INT hModel = PageGetInt("__EquipRefArray"); INT iArrayRow = 1; STRING sFilter; STRING sFields = "REFCLUST,REFEQUIP,REFITEM,REFCAT" STRING sRefCategory; STRING sRefCluster; STRING sRefEquipment; STRING sRefItem; STRING sEquipment; STRING sRefEquipItem; STRING sRefItemValue; IF (sEquipmentContext <> "") THEN nLength = StrLength(sEquipmentContext); nOffset = StrSearch(0, sEquipmentContext, ".") sEquipment = StrRight(sEquipmentContext, nLength - nOffset - 1); sFilter = "EQUIP=" + sEquipment; Debug_Trace("ReferenceInfo", "ReferenceInfo_GetData", "Populating the equipment reference for " + sEquipment, TRACE_Information); hSession = EquipRefBrowseOpen(sFilter, sFields); IF (hSession <> BAD_HANDLE) THEN nRecords = EquipRefBrowseNumRecords(hSession); IF nRecords > 0 THEN nStatus = EquipRefBrowseFirst(hSession); FOR nRow = 0 TO (nRecords - 1) DO sRefCategory = EquipRefBrowseGetField(hSession, "REFCAT"); sRefCluster = EquipRefBrowseGetField(hSession, "REFCLUST"); sRefEquipment = EquipRefBrowseGetField(hSession, "REFEQUIP"); sRefItem = EquipRefBrowseGetField(hSession, "REFITEM"); sRefEquipItem = sRefEquipment + "." + sRefItem; sRefItemValue = TagRead(sRefEquipItem, 0, sRefCluster); SleepMS(10); ArraySetInt(hModel,0,0, iArrayRow); ArraySetString(hModel, sRefCluster, 1, iArrayRow); ArraySetString(hModel, sRefEquipItem, 2, iArrayRow); ArraySetString(hModel, sRefItemValue, 3, iArrayRow); ArraySetString(hModel, sRefCategory, 4, iArrayRow); iArrayRow = iArrayRow + 1; EquipRefBrowseNext(hSession); END END EquipRefBrowseClose(hSession); END END IF (nRecords <= 0) THEN FOR nRow = 0 TO ArrayGetInfo(hModel, 1) DO ArraySetInt(hModel,0,0, iArrayRow); ArraySetString(hModel, "", 1, iArrayRow); ArraySetString(hModel, "", 2, iArrayRow); ArraySetString(hModel, "", 3, iArrayRow); ArraySetString(hModel, "", 4, iArrayRow); //iArrayRow = iArrayRow + 1; END END ArraySetInt(hModel, iArrayRow, 0, 0); END
See also
Published June 2018