Ok I figured it out. the Trigger on the part number change was working but I was looking at the database to find the last Part No, Part Count, and Timestamp to update my calculation. The problem is that sometime the data is stored before forwarding to the database so the last record I was looking at in the database is old and not really the last transaction.
How can I store the last triggers values in Ignition so that I can do my expressions to calculate the Cycle Time, change over time, or Downtime.
Example of what I am doing.
Context. The machine counters are different between all my factory machines this one only has a total running count and I am not able to make changes to the PLC.
PartCount = (Triggered Expression)
if({[~]Memory_LastPartNo}={Machine/PartNo_Formated},{[~]Memory_LastPartCount}+1,1)
Memory_LastPartCount (Triggered Expression)
{[~]PartCount}
Memory_LastPartNo = (OPC TAG)
{Machine/PartNo_Formated}
Memory_LastPartCaptureTime = (Triggered Expression)
NOW()
RealCycleTime = (Run-Always Expression)
secondsBetween({[~]Memory_LastPartCaptureTime},Now())
MyCycle Time = (Run-Always Expression)
(if({[~]ChangeOverTime}+{[~]Downtime}>0,0,if({[~]RealCycleTime}>900,0,{[~]RealCycleTime})))
ChangeOverTime = (Run-Always Expression)
if(({[~]Memory_LastPartNo}!={Machine/PartNo}),if({[~]RealCycleTime}<90,0,if({[~]RealCycleTime}<7200,{[~]RealCycleTime},0)),0)
Downtime =(Run-Always Expression)
if({[~]RealCycleTime}>175,if(({[~]Memory_LastPartNo}!={Crippa 980MX1/PartNo_Formated}),0,if({[~]RealCycleTime}<7200,{[~]RealCycleTime},0)),0)
I have tried to create a Memory Tag to store the last transaction data, but I am unable to figure out how to write the values to the Memory tags when the trigger activates.
Currently the Memory_LastPartNo is changing when the OPC tag changes even though it should only update on the triggered expression.
Prevent trigger cuase by group start CHECKED
Trigger condition
Active on value change CHECKED
The database part was working for a long time but as soon as I added another machine, I believe it started storing data before sending to the database which has now changed the way everything was working.