I’m trying to generate a 1-column list and populate a drop-down list when a numeric label changes value.
The data is read using OPC and any duplicate values are not added to the list.
When it attempts to convert the List into a dataset I get the error below at the line
dataset = system.dataset.toDataSet(header,oList)
ERROR MESSAGE:
java.lang.ClassCastException: java.lang.ClassCastException: org.python.core.PyInteger cannot be cast to org.python.core.PySequence
PRINT of the List (oList):
[0, 13, 14, 8, 122]
CODE:
if event.propertyName == “value”:
oTags = []
for i in range(60):
oTags.append("Tagname_" + str(i) +"_")
oValues = system.tag.readAll(oTags)
oList = []
for x in range(len(oTags)):
nValue = oValues[x].value
#add new number to droplist
if not (nValue in oList):
oList.append(nValue)
header = ["Value"]
dataset = system.dataset.toDataSet(header,oList)
sortDataSet = system.dataset.sort(dataset,"Value")
event.source.parent.getComponent('droplist_1').data = sortDataSet
You could keep it a flat list (so you can easily check membership) and only convert it to a nested list at the last moment before creating the dataset: system.dataset.toDataSet(header, [[i] for i in oList])
How would you do the reverse, take a List of Rows and return only a flat List?
I have a returned List from an OPC writeValues call and would like to parse through the list and
generate a flat list. If a returned value is [GOOD], insert a “1” otherwise a “0” into the flat list.
Or is there a better way just to return a value of “1” if all of the List rows = “GOOD” otherwise a “0”?
Looking for a elegant solution to determine if there was any error during the OPC writeValues call.