Ignition Trend Config Storage

Hello All, we are currently allowing users to save trend configs such that the next time they are opened all previous settings are restored. Have a look at the code for the save trend button below.

TagName = event.source.parent.LoopData

udtPath = 'TrendFiles/' + TagName
if not system.tag.exists(udtPath):
	system.tag.addTag(parentPath='TrendFiles', name=TagName, tagType="UDT_INST",attributes={"UDTParentType":"TrendConfiguration"})

tagPath = udtPath + "/Pens"
pensStringPath = udtPath + "/PensString"
axesPath =udtPath + "/Axes"
axesStringPath = udtPath + "/AxesString"
subplotsPath = udtPath + "/SubPlots"
subplotsStringPath = udtPath + "/SubPlotsString"
durationPath = udtPath + "/TrendDuration"
unitsPath = udtPath + "/Unit"

Value = system.dataset.toCSV(event.source.parent.getComponent('Easy Chart').tagPens,1,1,0)
system.tag.write(pensStringPath,Value)

Value = system.dataset.toCSV(event.source.parent.getComponent('Easy Chart').axes,1,1,0)
system.tag.write(axesStringPath,Value)

Value = system.dataset.toCSV(event.source.parent.getComponent('Easy Chart').subplots,1,1,0)
system.tag.write(subplotsStringPath,Value)

system.tag.write(durationPath,event.source.parent.getComponent('Easy Chart').unitCount)
system.tag.write(unitsPath,event.source.parent.getComponent('Easy Chart').unit)

I am wondering if we can leverage some of the new JSON functions to do this more cleanly going forward with V8. Your thoughts?

1 Like

Hello Hello Hello is there anybody out there???

There’s lots of us out here. But you seem to be blazing a new trail. That makes you the expert. (:

2 Likes

Me the expert, I wish!!!