FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
11-21-2023 09:40 PM
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.
Solved! Go to Solution.
11-22-2023 09:31 AM
Hello,
Flatbuffers is what you need. There is a simple example here:
https://github.com/boschrexroth/ctrlx-automation-sdk/tree/main/samples-iec61131
Mauro 🙂
11-23-2023 08:43 PM
Thanks for pointing me in this direction. I will try this soon.
11-24-2023 10:57 AM
I'm trying to follow the readme in `ctrlx-automation-sdk/samples-iec61131/fbs-read-write` but I stuck at the following:
* Select PLC node Application, right click and select context menu item 'Import from Flatbuffers File...'
I cannot find the "Import from Flatbuffers File ..." menu item. When I right click the PLC node Application I can Login or Add an object but nothing related to a Flatbuffers file.
Any idea what I'm doing wrong?
11-24-2023 01:41 PM
Currently I have ctrlx WORKS version 1.20, but I should have ctrlx WORKS version >= 2.3
I have another question posted here:
https://developer.community.boschrexroth.com/t5/ctrlX-PLC/Where-to-download-ctrlX-WORKS-version-2-3/...