hello everyone!
I have a Tree View (Yuso, SCADA and EMS), where all are on a single EasyChart that share signals (tags). Now, the problem is that SCADA and Yuso contain the same, while EMS does not. So, I want a function that, when selecting EMS in the Tree View, will deselect the signals that are already selected to avoid problems.
I already have this implemented (I share the script).
already_selectable = system.tag.readBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable")[0].value
desired_selectable = system.tag.readBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/desired_selectable ")[0].value
if not desired_selectable and not already_selectable:
pensDataset = self.pens
modifiedRows = []
for rowIndex in range(pensDataset.getRowCount()):
row = [pensDataset.getValueAt(rowIndex, colIndex) for colIndex in range(pensDataset.getColumnCount())]
row[7] = False
modifiedRows.append(row)
columnNames = list(pensDataset.getColumnNames())
newPensDataset = system.dataset.toDataSet(columnNames, modifiedRows)
self.pens = newPensDataset
system.tag.writeBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable", True)
elif desired_selectable:
system.tag.writeBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable", False)
However, the problem is that the performance with this script is quite slow. I would like to know if there is any other method to achieve what I need.
cell update? i was thinking of an if = ems deselect enable colum..but I can't use conditions in those fields
I didn't look close, but you are constructing the dataset multiple times (for every row), instead of once after the loop.
2 Likes
You're also writing to the tag multiple times in the loop.
1 Like
What recommendations would you give me? I could modify the script following your suggestions, but I would like to know if there is any other particular method that Ignition has to achieve what I need. The script is in an EasyChart configureChart.
Uploading: image.png…
Start with moving the constructing of the dataset after you have iterated through making modifiedRows
tagsPaths = [
"[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable",
"[BALEN]System/Scada_control/Management/Topics Monitoring/desired_selectable "
]
tagsIn = system.tag.readBlocking(tagsIn)
already_selectable = tagsIn[0].value
desired_selectable = tagsIn[1].value
if not desired_selectable and not already_selectable:
pensDataset = self.pens
modifiedRows = []
for rowIndex in range(pensDataset.getRowCount()):
row = [pensDataset.getValueAt(rowIndex, colIndex) for colIndex in range(pensDataset.getColumnCount())]
row[7] = False
modifiedRows.append(row)
columnNames = list(pensDataset.getColumnNames())
self.pens = system.dataset.toDataSet(columnNames, modifiedRows)
system.tag.writeBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable", True)
elif desired_selectable:
system.tag.writeBlocking("[BALEN]System/Scada_control/Management/Topics Monitoring/already_selectable", False)
1 Like
thanks, I didn't know that readBlocking could read several tags at the same time.
Yes, but note that setting the pens is outside of the for loop. Your original script was making a new dataset, setting the pens, and writing to the tag each time it went through the loop. As @pturmel intimated, that is where your time is being taken up. The tag read at the beginning was a tiny optimaization compared to the loop.
1 Like
yes i see it! how can you change a code with so little heheh thank you very much. it's running much smoother now.