I have a list of Ingredients where each Ingredient contains a structure of variables.
The structure of variables is common to all Ingredients; however, occasionally an Ingredient will have a unique variable, in which case the variable is not in the structure but defined as a class variable.
I have separated the Ingredients into classes in an attempt to use the factory pattern, 'Ingredient' being the base class and other derived classes with unique parameters and overridden methods.
When I create a list of Ingredients, only the structure of variables is passed to the list, and child ingredients' extra parameters are lost.
I cannot create a list of Ingredient interfaces because of the way the system persists objects - only instantiated objects may be persisted (stored to file).
Do I just add the parameters of the child class to the structure of variables even though the parameter won't be used in most cases? This seems 'clunky' to me, but I can't seem to think of another way to save the parameter data.
You should be able to store Function Blocks as Persistent. From what I understand, you are trying to store a list of Interfaces in the Persistent memory. CODESYS always treats variables declared with the type of an interface as references, so instead of storing references (kinda like pointers) as persistent, store the initialized objects themselves and use their interfaces in code. If you do this, try to avoid creating big Function blocks, because the function block instance is stored entirely in permanent memory and not just the marked variable.