Hi,
I'm using the tag valueChanged event to implement a process log: the process tag is a boolean variable read from an AB CompactLogix plc through an Ignition device.
My logic should be as follows: each time I see an OFF->ON transition of the variable, I add a process record in a table of an SQL Server database with its start datetime - let's say process X has been added; each time I see an ON->OFF transition, I "close" process X, by updating its end time.
The python script in the valueChanged event is:
if not initialChange and currentValue.quality.isGood():
if currentValue.value:
#add a new process record in the database
else:
#update process end datetime
What it's weird is that whenever I restart the PC or shutdown/startup Ignition service or disconnect/connect the PLC, if the process boolean variable is true when the system comes on again, a new process record gets added: that is not right, because the process variable was already true and Ignition did not catch any transition in my opinion. I thought that if not initialChange condition was the solution, but it isn't.
Any suggestion? Is anyone exactly aware of when the valueChanged event is called on a variable? The event comment says
But I'm not quite sure
Thanks in advance, regards