I will use a very simple example to show my problem.
I created a DUT (data unit type) named MY_COMPLEX in the PLC as follows:
TYPE MY_COMPLEX :
STRUCT
p1:INT;
p2:INT;
END_STRUCT
END_TYPE
I created a variable in structured text by:
my_complex: MY_COMPLEX:=(p1:=1,p2:=2);
Now I'm able to read the value of 'p1' using Python and ctrlx_datalayer by:
address = "/plc/app/Application/sym/PLC_PRG/my_complex/p1"
result, data = client.read_sync(address)
value = data.get_int16()
# value == 1
But I would like to read both values, p1 and p2, at once.
I do not want to use the BulkRead possibilities, because when the number of addresses increase it will get much slower than a single read.
Should I investigate the flatbuffers type? If so, how to create this in the PLC?
Are there other possibilities?
Note that in my real application I would like to have an array of DUT types, and I would use both read and write.
Ideally I would do conversions at Python side to convert to/from bytes, and send bytes using the datalayer.