Hi,
I have an issue that I'm struggling to figure out the reason for.
In a factory I have a set of views divided on different areas of the factory floor. So one view will contain a set of light columns machines and another view some other. These views have their own dashboard component with a 'on change script' on the widget property;
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
from com.inductiveautomation.ignition.common import TypeUtilities
jsonWidgets = TypeUtilities.pyToGson(self.props.widgets)
serializedWidgets = system.util.jsonEncode(jsonWidgets)
dashboardID = self.view.params.dashboardID
productionLineID = self.view.params.productionLineID
dbCon = system.tag.read("[default]/My Tags/DB_con").value
dUpdated = system.date.now()
dateUpdated = system.date.format(dUpdated, "yyyy-MM-dd HH:mm:ss")
system.db.runPrepUpdate("UPDATE tblAreaOverviewConfiguration_rev2 SET newWidgets = ?,dateUpdatedPROMO = ? WHERE dashboardID = ? AND productionLineID = ?",(serializedWidgets,dateUpdated,dashboardID,productionLineID),dbCon)
For some unknown reason I get the view of one part overwritten to another.
So for example view 'One' contains widgets 'A' & 'B' and another view 'Two' contains 'C' & 'D'. Every now and then 'Two's widgets will be overwritten with 'A' & 'B' instead of 'C' & 'D'. Here is the startup script when you load the view;
def runAction(self):
dbCon = system.tag.read("[default]/My Tags/DB_con").value
dashboardID = self.view.params.dashboardID
productionLineID = self.view.params.productionLineID
serializedWidgets = system.db.runScalarPrepQuery("SELECT newWidgets FROM tblAreaOverviewConfiguration_rev2 WHERE dashboardID =? AND productionLineID =?", [dashboardID,productionLineID],dbCon)
self.getChild("dshAreaOverView").props.widgets = system.util.jsonDecode(serializedWidgets)
Can't see where it goes wrong, could you help me out?
Best regards,
Rickard Nordwall