#596 PLCgen: differentiate between reading and writing CIF variables.
A few shortcuts for simplifying PLC statement construction, and a bigger extension to the expression generator. The latter is explained in more detail below (same as in the commit message).
Reading a value should return a PlcExpression, while writing a value should be a PlcVarExpression.
As suggested in !600 (closed) I generalized ExprGenResult
to ExprGenResult<E extends PlcExpression>
with type E
for the ExprGenResult.value
and added again PlcValueResult
and PlcAddressableResult
as derived classes.
This mostly works, except for dumping lists of either derived class into the constructor for copying the code and variables. You must make a copy to List<ExprGenResult<?>>
. Alternatively you can use a List<ExprGenResult<?>>
immediately for the parent results but then the value
becomes unusable.
The problem may be solvable by adding constructors for both List<PlcValueResult>
and List<PlcAddressableResult>
cases in both derived classes at least. Not a very nice solution though.
The ExpressionGenerator
external interface now has ExprValueResult convertValue(Expression)
instead of the old convertExpr
method and ExprAddressableResult convertAdressable(Expression)
for the modifiable variant.
-
The
ExpressionGenerator.convertAdressable(Expression)
variant doesn't handle the f().field case, but that is fine as it is not addressable in CIF either. -
CifDataProvider methods now has "Value" prefixes (for the existing methods) if the data is meant for reading, and additional "Addressable" variants for modifying discrete and continuous variables. For simplicity I assumed derivative are writable, this may have to change at some point.
-
DefaultVariableStorage returns the same PLC variables for CIF variables but that is all still testing code currently.
-
ExprGeneratorTest
existingrunTest
is nowrunValueTest
, and an additionalrunAdddressableTest
has been added for testing writing to discrete and continuous variables.
Addresses #596 (closed)