I am new to Object-Oriented Programming (OOP) in Structured Text (ST), but both familiar with OOP in C/C++ and ST. I would like to understand what is the difference between Properties (with a corresponding VAR to get/set) and a VAR_IN_OUT? Also, when should I use one instead of the other (in Structured Text OOP)?
Let’s say that we have the abstract object “Device” that has a name:
FUNCTION_BLOCK ABSTRACT Device
VAR
Name_ : STRING(8);
END_VAR
with the following property:
PROPERTY PUBLIC Name : STRING(8)
with the getter:
Name := Name_;
and the setter:
Name_ := Name;
What would be the difference with this:
FUNCTION_BLOCK ABSTRACT Device
VAR_IN_OUT
Name : STRING(8);
END_VAR
In other words, when should I use the property and when should I use the VAR_IN_OUT? Similarly, when should I use a property with only a getter/setter or a VAR_OUTPUT/VAR_INPUT, respectively?
drl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.