Thanks Carl.
Ok… Now the easy stuff is all working, when I get an alarm, the report pops up, it prints automatically, and the window closes.
NOW comes the hard part. First of all, when I have lets say 3 alarms come up at once, I notice the report pops up, prints then closes. I get three print outs, but I only see one popup. I am sure there is some TIMER or invoke later that I am missing, but I can’t be sure.
So, what I feel this global timer needs to do is only select ONE alarm at a time not select ALL, then once the query is ran, I need it to SOME HOW pass certain column info, like
id = alarm["AlarmLog_ndx"]
name = alarm["item_name"]
into dynamic properties now contained in my report.
I already use a couple of windows that pass parameters to another window and OPEN said window. Of course this is “Configure action” and then using the NAV tab. But i imagine the code would be similar.
Used and proven in OTHER project:
# This script was generated automatically by the navigation
# script builder. You may modify this script, but if you do,
# you will not be able to use the navigation builder to modify
# this script without overwriting your changes.
param1 = event.source.parent.GanntTable
param2 = event.source.parent.getComponent('Filter').getComponent('Line').selectedLabel
fpmi.nav.swapTo('Delay Chart', {'GanntTable' : param1, 'linename' : param2})
Now, what i have tried but does not work (my Dynamic property I have in the report is ‘Alarm’:
# Get a list of the alarms that have not yet been printed
alarms = fpmi.db.runQuery("SELECT * FROM alarmlog WHERE printed = '0' AND severity = '1'")
for alarm in alarms:
# Loop through the alarms, open a window associated with each one
# and print it out.
id = alarm["AlarmLog_ndx"]
name = alarm["item_name"]
window = "Report"
def openAndPrint(Report=window):
import fpmi
fpmi.nav.openWindow(Report, {'Alarm' : name}))
def printLater(Report=Report):
import fpmi
window = fpmi.gui.getWindow(Report)
report = window.getRootContainer().getComponent('Report Viewer')
report.print(None, 0)
fpmi.system.invokeLater(printLater, 1000)
fpmi.system.invokeLater(openAndPrint)
def closeAfterPrint(Report=window):
import fpmi
fpmi.nav.closeWindow(Report)
fpmi.system.invokeLater(closeAfterPrint, 3000)
fpmi.db.runPrepStmt("UPDATE alarmlog SET printed=1 WHERE alarmlog_ndx = ?", [id])
The error i get is
Traceback (innermost last):
File "<TimerScript:alarm_log_print (20000) [Delay, Shared]>", line 12, in openAndPrint
NameError: name
Thanks,
-Chris