Hey folks,
7.9.7 x64
Java 1.8.0_144
Windows 7
We have a boolean notification tag from the PLC that, on value change, triggers a SQL query.
The script is executing, and the query is correct. The problem I am experiencing is that the script appears to run 2x every time the tag changes. I’ve confirmed that it is only changing one time in the PLC, hoping someone can spot something in my script causing the issue:
if not initialChange:
DB= "Tank_Temp"
now = system.date.now()
t_stamp = system.date.format(now, "yyyy-MM-dd HH:mm:ss")
Mode = system.tag.read("[.]Mode").value
B_SP = system.tag.read("[.]Bottom_SP").value
Delta_T = system.tag.read("[.]Delta_T").value
TankNum = system.tag.read("[.]Tank_Number").value
Blend = system.tag.read("[.]Blend").value
BT = system.tag.read("[.]Bottom_Temp").value
TT = system.tag.read("[.]Top_Temp").value
Quality = system.tag.read("[.]PV Notification Tag").quality
PrevValue = previousValue.value
CurValue = currentValue.value
updateAudit = "INSERT INTO TTC_Audit
(Mode, Bot_Setpoint, Delta_T, Bot_Temp,
Top_Temp, TankNum, t_stamp, User, Note, Blend, PrevValue, CurValve)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
system.db.runPrepUpdate(updateAudit,
[Mode, B_SP, Delta_T, BT, TT, TankNum, t_stamp, 'PanelView',
'Tank Settings', Blend, PrevValue, CurValue], DB)
Cheers,
Andrew