{}

Our Brands

Impact-Company-Logo-English Black-01-177x54

Welcome to the Schneider Electric Website

Welcome to our website.
Search FAQs
How to use scripting to select items from embedded lists
DISCLAIMER

The example below is intended to demonstrate one or more features or methods and is presented as a configuration example only. Schneider Electric assumes no liability for the use or application of this example or any portion thereof.


One of the best features in ClearSCADA is the use of embedded lists on mimics. The embedded lists can be used not only to show data, but we can select a row on the list, retrieve information about that row from script and use it to perform some other task. Information about a selected row can be achieved by accessing embedded list properties, some of those are listed below:
  • CurrentRowIdx—This animation property is only available for embedded Queries Lists and embedded Alarms Lists on Mimics. An animation for the CurrentRowIdx property returns the index number of the currently selected row (0 is the top row, 1 is the next row down, 2 the next row down and so on). If -1 is returned, it means that there is no row currently selected.
  • CurrentRowId—This animation property is only available for embedded Queries Lists on Mimics. An animation for the CurrentRowId property returns the ID of the database item represented by the currently selected row. If -1 is returned, it means that there is no row currently selected or the ID for the relevant database item is unavailable.
  • CurrentRowName—This animation property is only available for embedded Queries Lists on Mimics. An animation for the CurrentRowName property returns the name of the database item represented by the currently selected row. If nothing is returned, it means that there is no row currently selected.
Attached there is an example (SDE file, can be imported on ClearSCADA 2015 R2 or newer), which has a script that will run when a row is selected on embedded list "Lst_1", retrieve the "CurrentRowId", which is the Id of a point and use it to change the query linked to another embedded list, "Lst_2", so it will show historic data for the point selected (please hand control the points in the example to add historic data before testing).
The mimic looks like the following picture:



Below the script linked to the "Pick Action > Script" animation on the top embedded list:

sub test()

' Retrieve the "CurrentRowId" property from the selected row on the top embedded list
rowId = Mimic.Layers(0).Item("Lst_1").CurrentRowId


' If there is a selection, format SQL query retrieving historic data from the selected point and link the query to the bottom embedded list
if rowId <> -1 then
sql = "SELECT TOP( 100000 )   ""RecordId"", ""RecordTime"" AS ""~Time"", ""FormattedValue"", ""StateDesc"", ""QualityDesc"", ""ReasonDesc"", ""StatusDesc"", ""SuppressionTypeDesc"", ""Foreground"", ""Background"", ""Blink"", ""FileOffset"" AS ""_FileOffset""  FROM   CDBHISTORIC  WHERE   ""Id"" = "
sql = sql + CStr(rowId)
sql = sql + " AND ""~Time"" BETWEEN { OPC 'Hour - 23 Hours' } AND { OPC 'Hour - 23 Hours+1 Day' }  ORDER BY   ""~Time"" DESC, ""_FileOffset"" DESC"

Mimic.Layers(0).Item("Lst_2").sql = sql
else
msgbox "No row selected"
end if

end sub



Schneider Electric Canada

Attachment(s)
Embedded List Item Selection.sde [1014.56 KB]
Explore more
Range:
Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.
Explore more
Range: