Hello! I have a PLC which has a global variable (named SystemVars
) that is an array of iSystemVars
structs. I am using Ignition Perspective and want to create a table that displays the structs that makeup SystemVars
, and have the value
column be editable in such a way that the modified value is propagated down to the PLC. I am able to edit the table cell, but the modified value does not propagate to the PLC.
TYPE iSystemVar : STRUCT
name: string;
value: INT;
END_STRUCT
END_TYPE
My PLC broadcasts the SystemVars
variable on it's OPC UA server which I have created a tag for. So far, I have been able to create a table in Perspective that is able to take the SystemVars
tag and populate the table.
Since the tag is of type String
, I have the data
prop of the table binded to the following script:
def transform(self, value, quality, timestamp):
import json
# retrieve and format the raw tag data into something sensible
raw_tag = system.tag.readBlocking("[edge]systemConfig/SystemVars")[0].value
sys_vars= json.loads(raw_tag) # arr[dict[str, str/float]]
cols = ["Name", "Value"]
rows = []
for sv in sys_vars:
if sv["index"] == -1: # empty / placeholder var
continue
tmp = []
tmp.append(sv["name"])
tmp.append(sv["value"])
rows.append(tmp)
# return the dataset with the desired cols&rows
return system.dataset.toDataSet(cols, rows)
To edit the table cell, I am using the following script for the onEditCellCommit
component event.
def runAction(self, event):
# update the table's data prop to reflect the change
self.props.data = system.dataset.setValue(
self.props.data,
event.rowIndex,
event.column,
event.value
)
# write the new array to the tag
system.tag.writeBlocking(["[edge]systemConfig/SystemVars"], [self.props.data])
With this script, I am able to edit the cells in the Value
row, but the modified value does not propagate to the PLC. The SystemVars
array in the PLC does not change. No errors or anything.
I've made sure that the tag is not read-only, and that I have 2 way communication enabled in Perspective. Any ideas? Please let me know if I need to clarify anything or offer more information. Thank you!!