As it stands now, I have a Global Script Timer:
alarms = fpmi.db.runQuery("SELECT L.AlarmLog_ndx AS ID, Date_Format(L.active_time, '%Y-%m-%d %H:%i:%s') AS active_time, Date_Format(L.clear_time, '%Y-%m-%d %H:%i:%s') AS clear_time, L.item_name, L.state_name, L.state_id, L.active_value, L.clear_value, L.severity, L.point_path, L.printed, (SELECT R.recipe FROM recipe R WHERE R.line_id=LEFT(L.item_name, 3) AND R.t_stamp < L.active_time ORDER BY R.t_stamp DESC LIMIT 1) as recipe, (SELECT B.batch_number FROM batches B WHERE B.line_id=LEFT(L.item_name, 3) AND B.t_stamp < L.active_time ORDER BY B.t_stamp DESC LIMIT 1) as batch FROM alarmlog L WHERE alarm_moved = '0' LIMIT 1")
ip = fpmi.net.getIpAddress()
##if len(alarms)>0:
if ip == "10.24.14.112" and len(alarms)>0:
alarm = alarms[0]
a = alarm["ID"]
b = alarm["active_time"]
c = alarm["clear_time"]
d = alarm["item_name"]
e = alarm["state_name"]
f = alarm["state_id"]
g = alarm["active_value"]
h = alarm["clear_value"]
i = alarm["severity"]
j = alarm["point_path"]
k = alarm["printed"]
l = alarm["recipe"]
m = alarm["batch"]
def insertQuery(insert="INSERT INTO alarm_matrix (ID, active_time, clear_time, item_name, state_name, state_id, active_value, clear_value, severity, point_path, printed, recipe, batch) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"%(a,b,c,d,e,f,g,h,i,j,k,l,m)):
import fpmi
fpmi.db.runUpdateQuery(insert)
fpmi.system.invokeLater(insertQuery)
fpmi.db.runPrepStmt("UPDATE alarmlog SET alarm_moved=1 WHERE alarmlog_ndx = ?", [a])
How would I use something similar in FSQL??