I have a report that I have designed. every 5min I have a timer that checks to see if it is time to print the report.
Can I, from within the timer script, using a if clause, print the report?
Here is the code I have tried.
z= fpmi.tag.getTagValue('[]pc')
y= fpmi.tag.getTagValue('[]print_lock')
print y,z
if z == 1 and y==1:
fpmi.tag.writeToTag('[]pc',0)
fpmi.tag.writeToTag('[]print_lock',0)
job = fpmi.print.createPrintJob(event.source.parent.getComponent('Report'))
job.print(none,0)
job1 = fpmi.print.createPrintJob(event.source.parent.getComponent('Report1'))
job1.print(none,0)
else:
print "no"
I am sure it is probably something stupidly simple staring right at me. Or who knows maybe the idea can not be done in the way I am trying. That is why I am hoping the experts on here will let me know.
The error message I get when I run the above timer script is as follows:
Traceback (innermost last):
File “<TimerScript:update (15000) [Delay, Shared]>”, line 8, in ?
NameError: event
at org.python.core.Py.NameError(Py.java)
at org.python.core.PyFrame.getglobal(PyFrame.java)
at org.python.core.PyFrame.getname(PyFrame.java)
at org.python.pycode._pyx225.f$0(<TimerScript:update (15000) [Delay, Shared]>:8)
at org.python.pycode._pyx225.call_function(<TimerScript:update (15000) [Delay, Shared]>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.factorypmi.application.script.ScriptManager.runCode(ScriptManager.java:245)
at com.inductiveautomation.factorypmi.application.script.TimerScriptTask.run(TimerScriptTask.java:63)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
FactoryPMI v3.3.1 (build 2549)
Java: Sun Microsystems Inc. 1.6.0_04
Thanks and have a great day.