#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.
While the difference is small, adding a type parameter for the "value" field in the ExprGenResult class causes havoc throughout the expression code, due to type erasure and my desire not to have to write ExprGenResult<PlcExpression> everywhere so I can have a handful of ExprGenResult<PlcVarExpression>.
In the end I created two specializations of the ExprGenResulr class:
-
ExprValueResultfor results that read the expression value, and -
ExprAddressableResultfor results that modify the expression value. -
ExprGenResultis now a base-class without "value" field, with two derived classesExprValueResultandExprAddressableResult.
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)variabnt doesn't handle thef().fieldcase, but that is fine as it is not addressable in CIF either. -
CifDataProvidermethods 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.DefaultVariableStoragereturns the same PLC variables for CIF variables but that is all still testing code currently. -
ExprGeneratorTestexistingrunTestis nowrunValueTest, and an additionalrunAdddressableTesthas been added for testing writing to discrete and continuous variables.
Addresses #596 (closed)