How can we help you today?
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:
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
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.
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
Released for:Schneider Electric USA
Attachment(s)
Explore more
Range:
Explore more
Range: