Passing Custom Parameters in Easy chart dataset-Vision

Hi,

I would like to add custom parameters to the easy chart tagpaths via scripting.

chart = event.source.parent.getComponent('Easy Chart')
process = event.source.parent.Process
machine = event.source.parent.MachineNo


newRow = [["Line Speed", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_machinespeed", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0],
			["Diameter", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_diameter", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0]]
chart.tagPens = system.dataset.addRow(chart.tagPens, newRow)

But I am getting error in the tagpaths. Am i missing something?
how to concatenate the parameters with the tagpaths?
Thanks in advance

You won’t be able to directly edit the dataset. Create a copy of the dataset in your script, edit it, and then, set it back.

Edit: For some reason, I had it in my head that this had to be a two step process, but the addRow function works just fine. When I tried your code, the error I got was being caused by a column number mismatch. The way you were writing to the dataset wasn't the problem at all

But I m getting error in the paths in row 2. Is there any error in the syntax ?

Possibly, I wasnt in front of my computer, and I responded from my phone. Give me a second, and I’ll get you something that’s tested from my computer.

Yeah. Sure

This code works:

chart = event.source.parent.getComponent(‘Easy Chart’)
process = “Process 1”
machine = “Machine 2”

lineSpeedRow = ["Line Speed", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_machinespeed", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0]
diameterRow = 	["Diameter", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_diameter", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0]
dataSet = system.dataset.addRow(chart.tagPens, lineSpeedRow)
dataSet = system.dataset.addRow(dataSet, diameterRow)
chart.tagPens=dataSet

You’ll have to substitute your custom parameters for the strings I used in the process and machine variables

This set up also works, and is more in keeping with your original example:

chart = event.source.parent.getComponent('Easy Chart')
process = "Process 1"
machine = "Machine 2"

newRow = [["Line Speed", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_machinespeed", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0],
	["Diameter", "[baseHistorian/ignition-stl:default]base/"+process+"/"+process+"-"+machine+"/mes/actual/actual_diameter", "MinMax", "Default Axis",1, 0, "0,0,255","", 1, 1, 0, 1, 0, "MachineParameters",0,0,0,1,"",0]]
for row in newRow:
	chart.tagPens = system.dataset.addRow(chart.tagPens, row)

Edit: I was able to simplify this even more

Hey Justin,

This works as expected. Thanks

1 Like