Say I have an abstract function block AValve
that I extend for various types of valve. I extend that AValve
in order to implement it as a BasicValve
. Also I have a function block that takes an array of AValve
, which looks like this
FUNCTION_BLOCK ValveDispatch
VAR_IN_OUT
valves : ARRAY[*] OF AVALVE;
END_VAR
If I try to pass an array of BasicValve
into this function block, I'm met with:
Cannot convert type 'ARRAY [0..5] OF BasicValve' to type 'ARRAY [*] OF AVALVE' of VAR_IN_OUT 'valves'
Thinking that maybe codesys just couldn't handle both extended types AND variable length arrays at the same time, I've tried doing a set length array as an input, just for testing as I need the variable length. Doing so gives a slightly different error that seems to mean the same thing:
Type `ARRAY[0..5] of BasicValve' is not equal to type 'ARRAY [0..5] OF AVALVE' of VAR_IN_OUT 'valves'
Is there a way I can make this work? Passing a single extended object into an input expecting its base type works fine, but doing so with arrays seems to be unsupported.