EcoStruxure Geo SCADA Expert Forum
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:13 PM . Last Modified: 2023-05-03 12:28 AM
>>Message imported from previous forum - Category:ClearSCADA Software<<
User: hardin4019, originally posted: 2019-02-04 22:37:59 Id:359
I have a template for multiple sites with up to 5 wireless sensors reporting back to the master radio at each site (acting as the Modbus RTU) we are recording 3 Modbus Advacned Analog variables per pressure sensor for, so as many as 15 points at a site.
Sensor 1 Pressure
Sensor 1 Battery Voltage
Sensor 1 RSSI
Sensor 2 Pressure
Sensor 2 Battery Voltage
Sensor 2 RSSI
Sensor 3, etc...
Each Pressure Sensor Analog point has specific information I want to show in the first 3 columns of a table, "Station Name", "Pressure Source", and "Line Name". Pressure Source and Line name are unique to each pressure sensor, and I have some Metadata fields setup called ObjProperty01, ObjProperty02, ObjProperty03 that contains this info for each active Pressure Sensor. Then after those 3 columns I want to show the value of Pressure Sensor 1, Pressure Sensor 1 Battery Voltage, Pressure Sensor 1 RSSI, then repeat for each pressure sensor.
Where I am having issues is probably just lack of experience with SQL Queries, but it is very simple to get a Query like:
Select
ID, FullName AS "_FullName", ObjProperty01 AS "Station Name", ObjProterty02 AS "Pressure Source", ObjProperty03 AS "Line Name", CurrentValueFormated AS "Pressure"
From CDBPoint
But is there a way to specify that I want the value of the battery voltage for the same sensor in the next column, and RSSI in the last column?
I have also tried mapping out all 15 points to the Group Points and have successfully gotten the first Pressure Sensor and related values to show up in a single row, but need help with how to get the query to repeat for each Pressure Sensor after the first. That Query looks something like:
Select
ID, FullName AS "_FullName", GPoint01-ObjProperty01 AS "Station Name", GPoint01-ObjProterty02 AS "Pressure Source", GPoint03-ObjProperty03 AS "Line Name", GPoint01-CurrentValueFormated AS "Pressure", GPoint01 AS "_ID01", GPoint02-CurrentValueFormated AS "Battery Voltage", GPoint03-CurrentValueFormated AS "RSSI"
FROM CGroup
But I want this query to continue on with the next line as GPoint04 (the next pressure sensor), GPoint05 (the next sensor battery voltage), and GPoint06 (the next sensor RSSI) using the same columns and names as the query above, and then repeat for sensors 3-5.
I'm hoping someone has some suggestions and is better at SQL Queries than I am!
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:13 PM
>>Responses imported from previous forum
Reply From User: sbeadle, posted: 2019-02-04 23:13:19
I'd strongly consider a Data Set for this. It is possible with SQL, but could be less efficient. You can have multiple rows of a Data Set within a single instance
Reply From User: dmercer, posted: 2019-02-05 05:12:08
I find that these work best when you set up the database folder structure in a way that makes the divisions between the sites and the sensors clear. eg.
-Site1
--Sensor1
---Value
---Battery Voltage
---RSSI
--Sensor2
---Value
---Battery Voltage
---RSSI
-Site2
--Sensor1
---Value
---Battery Voltage
---RSSI
With that group structure, something like the below query should work (I haven't tested it)
SELECT TVal.SensorId-FullName AS "Name", TVal.CurrentValue, TRSSI.CurrentValue, TBatt.CurrentValue FROM
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE NOT "Name" = 'RSSI' AND NOT "Name' = 'Battery Voltage') AS TVal
INNER JOIN
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE "Name" = 'RSSI' ) AS TRSSI
ON TVal.SensorId= TRSSI.SensorId
INNER JOIN
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE "Name" = 'Battery Voltage' ) AS TBatt
ON TVal.SensorId= TBatt.SensorId
As sbeadle said, a dataset will make it more efficient. The difference may or may not matter in your system.
Reply From User: tfranklin, posted: 2019-02-05 14:24:37
That metadata looks eerily familiar! If the sites are structured like [at]dmercer suggested, then you can easily use the query that you already wrote and just tack on a where clause for WHERE objType = 'Sensor' or something to that degree.
Reply From User: hardin4019, posted: 2019-02-05 16:47:15
I tried both ways. The method [at]dmercer suggested is providing the most favorable results for now as it lets me use a custom pick action script to trend the points and access the point menu.
Now I'm down the rabbit hole of getting my pick action script to give me a ".~Detail Faceplate" from the Parent group holding all of the sub groups with sensor values.... So much fun!
"Set obj = Server.LookupObject(rowID)
ShowOnDetailHead "SCX:////CMimic/" & obj.FullName & ".Detail Faceplate" " is giving me the full name of the sensor folder. Changine obj.FullName to obj.Parent is giving me the ID of the parent folder and not the name. Any thoughts?
Reply From User: hardin4019, posted: 2019-02-05 17:46:46
Fixed my issue with getting the Parent Group path instead of getting the ID number and now have a workable solution. Thanks all!
Reply From User: sbeadle, posted: 2019-02-05 17:47:09
Should you use .ParentGroupName?
Reply From User: hardin4019, posted: 2019-02-05 17:53:13
[at]sbeadle said:
Should you use .ParentGroupName?
Tried that, its not one of the supported "ServerObject Properties". The .Parent is supported, but returns the ID instead of the name. So I ended up with something like below.
dim ojb, ojb2
set obj = Server.LookupObject(rowID)
set rowID = ojb.Parent
set obj2 = Server.LookupObject(rowID)
ShowPopUp "SCX:////CMimic/" & obj2.FullName & ".Detail Faceplate" ,10,10,25,40
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:13 PM
>>Responses imported from previous forum
Reply From User: sbeadle, posted: 2019-02-04 23:13:19
I'd strongly consider a Data Set for this. It is possible with SQL, but could be less efficient. You can have multiple rows of a Data Set within a single instance
Reply From User: dmercer, posted: 2019-02-05 05:12:08
I find that these work best when you set up the database folder structure in a way that makes the divisions between the sites and the sensors clear. eg.
-Site1
--Sensor1
---Value
---Battery Voltage
---RSSI
--Sensor2
---Value
---Battery Voltage
---RSSI
-Site2
--Sensor1
---Value
---Battery Voltage
---RSSI
With that group structure, something like the below query should work (I haven't tested it)
SELECT TVal.SensorId-FullName AS "Name", TVal.CurrentValue, TRSSI.CurrentValue, TBatt.CurrentValue FROM
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE NOT "Name" = 'RSSI' AND NOT "Name' = 'Battery Voltage') AS TVal
INNER JOIN
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE "Name" = 'RSSI' ) AS TRSSI
ON TVal.SensorId= TRSSI.SensorId
INNER JOIN
(SELECT ParentGroupId AS "SensorId", ParentGroupId-ParentGroupId AS SiteId, ParentGroupName, CurrentValue
FROM CAdvModbusAnalogIn
WHERE "Name" = 'Battery Voltage' ) AS TBatt
ON TVal.SensorId= TBatt.SensorId
As sbeadle said, a dataset will make it more efficient. The difference may or may not matter in your system.
Reply From User: tfranklin, posted: 2019-02-05 14:24:37
That metadata looks eerily familiar! If the sites are structured like [at]dmercer suggested, then you can easily use the query that you already wrote and just tack on a where clause for WHERE objType = 'Sensor' or something to that degree.
Reply From User: hardin4019, posted: 2019-02-05 16:47:15
I tried both ways. The method [at]dmercer suggested is providing the most favorable results for now as it lets me use a custom pick action script to trend the points and access the point menu.
Now I'm down the rabbit hole of getting my pick action script to give me a ".~Detail Faceplate" from the Parent group holding all of the sub groups with sensor values.... So much fun!
"Set obj = Server.LookupObject(rowID)
ShowOnDetailHead "SCX:////CMimic/" & obj.FullName & ".Detail Faceplate" " is giving me the full name of the sensor folder. Changine obj.FullName to obj.Parent is giving me the ID of the parent folder and not the name. Any thoughts?
Reply From User: hardin4019, posted: 2019-02-05 17:46:46
Fixed my issue with getting the Parent Group path instead of getting the ID number and now have a workable solution. Thanks all!
Reply From User: sbeadle, posted: 2019-02-05 17:47:09
Should you use .ParentGroupName?
Reply From User: hardin4019, posted: 2019-02-05 17:53:13
[at]sbeadle said:
Should you use .ParentGroupName?
Tried that, its not one of the supported "ServerObject Properties". The .Parent is supported, but returns the ID instead of the name. So I ended up with something like below.
dim ojb, ojb2
set obj = Server.LookupObject(rowID)
set rowID = ojb.Parent
set obj2 = Server.LookupObject(rowID)
ShowPopUp "SCX:////CMimic/" & obj2.FullName & ".Detail Faceplate" ,10,10,25,40
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.