I feel I should know how to approach this but don't!
The data is in the form,
Array index |
RECORD_NUM |
SKU_NAME |
0 |
0 |
"Product 1" |
1 |
1 |
"Product 2" |
2 |
2 |
"Product 3" |
Since the RECORD_NUM is the same as the array index, I don't need to read that - so I only need to read the 500 SKU_NAME entries.
I also only need to read and write the whole array by script (so no direct component bindings to each SKU_NAME).
Any suggestions for how to do this efficiently?
Is SKU_NAME
a quasi-string UDT that is defined by your program? Why isn't it a "regular" string?
You're up very early or very late, Kevin!
I don't know. I can find out tomorrow and will post here.
Thanks.
I think whoever programmed this screwed up.
If the two members were named LEN
and DATA
the driver would recognize this is a String and reading all of these values would be much more straight forward.
2 Likes
I don't know if it's relevant, but the data is downloaded to the PLC from a C-More HMI. There might be some quirky requirement on the structure for that reason.
That looks like a pre v21 AB Firmware?
If the entire array is being read and written to you can just use system.opc.readValues and system.opc.writeValues and it will work to the actual OPC paths, usually the array name gets doubled up and you just put .STRING on the end of the path.
Or get the PLC upgraded to a newer firmware and use the newer ControlLogix driver.
1 Like
Well spotted. It's V16, I think.
What's the significance of that? What did Rockwell change in V21?
If the entire array is being read and written to you can just use system.opc.readValues and system.opc.writeValues and it will work to the actual OPC paths, ...
Oooh, I've never had to use those before. The manual isn't quite clear: can I use that to read from and write to the PLC without having to create 500 Ignition OPC tags per machine? (I'd like this to be true!)
Or get the PLC upgraded to a newer firmware and use the newer ControlLogix driver.
It's validated medical device manufacturing equipment. 15 minute firmware upgrade + several days of validation and paperwork.
Or an Ignition script?
Guess which!
Correct, you just feed it the raw opc paths. I normally use list comprehension to build out my paths when I use this in scripted transactions.
2 Likes
What happens if I update CELL_RECIPE_DATA.CELL_RECIPE_DATA[12].SKU_NAME.STRING
with a longer string? (They vary between four and about ten characters long.)
Does SKU_NAME.LEN
get updated by the PLC?
Are there any traps for the unwary (or ignorant)?
No. For proper automation, those inner structures are supposed to be actual Logix String types. (You can make additional string types that have different max lengths.)
When made properly, the string type will have LEN and DATA members and you would point Ignition at the structure, not the array of bytes.
1 Like
So how would I write safely to the string using system.opc.writeValues | Ignition User Manual given the current PLC data structure?
You will have to write the length and the individual bytes of the string in a single call.