Ask Me About Webinar: Data Center Assets - Modeling, Cooling, and CFD Simulation
Join our 30-minute expert session on July 10, 2025 (9:00 AM & 5:00 PM CET), to explore Digital Twins, cooling simulations, and IT infrastructure modeling. Learn how to boost resiliency and plan power capacity effectively. Register now to secure your spot!
Geo SCADA Knowledge Base
Access vast amounts of technical know-how and pro tips from our community of Geo SCADA experts.
Link copied. Please paste this link to share this article on your social media post.
Originally published on Geo SCADA Knowledge Base by Anonymous user | June 10, 2021 01:03 AM
📖 Home Back
The DATABASE_OBJECT structure does not allow calling methods or writing to properties of aggregates using Logic. However there is a way that this can be done using two structured text programs. The example code below writes to the ControlMinimum and ControlMaximum properties of all Modbus analog points within a group.
The first program, uses DATABASE_OBJECT to get the list of points to operate on. This program can update any of the properties of these points in the class defined by DATABASE_OBJECT, for example, ZeroScale and FullScale. The SQL and DATABASE_OBJECT should also return the FullName property from the class. It accepts an input variable that determines which group it should search in the SQL query. The program uses two Double variables to set the ZeroScale and FullScale named "Range Max" and "Range Min".
As part of the processing of each point, call a second ST program (in the example this is called Sub and is in the same directory as the first program) and pass in the object FullName as an input variable.
Note that both ST programs should be set to "On Interval" with an interval of 0.
TYPE
ModbusAlgTagName : DATABASE_OBJECT(CModbusPointAlg)
FullScale : INT;
ZeroScale : INT;
FullName : STRING;
END_DATABASE_OBJECT;
END_TYPE
PROGRAM ConfigurePoints
VAR_INPUT
sGroupFullName : STRING;
END_VAR
METHOD
CallSub AT %M(.Sub.Execute) : STRING;
END_METHOD
VAR
ModbusAlgTags AT %S(SELECT Id, Units, FullScale, ZeroScale, TrendMaximum, TrendMinimum, FullName FROM CModbusPointAlg WHERE FullName LIKE ? || '%') : RESULTSET OF ModbusAlgTagName WITH_PARAMS sGroupFullName;
END_VAR
VAR
iRangeMax AT %I(.Range Max) : INT;
iRangeMin AT %I(.Range Min) : INT;
END_VAR
WHILE ModbusAlgTags.Valid DO
ModbusAlgTags.Value.FullScale := iRangeMax;
ModbusAlgTags.Value.ZeroScale := iRangeMin;
CallSub(ModbusAlgTags.Value.FullName);
ModbusAlgTags.Next();
END_WHILE;
END_PROGRAM
The second program creates read/write variables that point at the required properties, generating the variable using the FullName which is passed in in the VAR_INPUT block.
Note that we have checked whether or not the Control aggregate is enabled first by checking the $Enabled property to avoid errors when attempting to write to properties on an aggregate that is not enabled.
PROGRAM Sub
VAR_INPUT
FullName : STRING;
END_VAR
VAR
CtrlMax AT %M({FullName}.Control.ControlMaximum) : INT;
CtrlMin AT %M({FullName}.Control.ControlMinimum) : INT;
Enabled AT %M({FullName}.Control.$Enabled) : BOOL;
END_VAR
VAR
iRangeMax AT %I(.Range Max) : INT;
iRangeMin AT %I(.Range Min) : INT;
END_VAR
IF Enabled THEN
CtrlMax := iRangeMax;
CtrlMin := iRangeMin;
END_IF;
END_PROGRAM
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.