It is currently Tue Jul 29, 2014 12:41 am




Post new topic Reply to topic  [ 4 posts ] 
 Request Help Printing a report 
Author Message
General
General

Joined: Tue Jul 03, 2007 5:18 am
Posts: 322
Location: PA
Post Request Help Printing a report
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.

Code:
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.


Thu Mar 22, 2012 9:06 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: Request Help Printing a report
You don't have the event object for client event scripts. They only exist on event handlers on components. You should either put a timer component on the window or try to get the window first:
Code:
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)
   rc = fpmi.gui.getWindow("WindowThatReportIsOn").getRootContainer()
   job = fpmi.print.createPrintJob(rc.getComponent('Report'))
   job.print(none,0)
   job1 = fpmi.print.createPrintJob(rc.getComponent('Report1'))
   job1.print(none,0)
else:   
   print "no"

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Thu Mar 22, 2012 9:35 am
Profile WWW
General
General

Joined: Tue Jul 03, 2007 5:18 am
Posts: 322
Location: PA
Post Re: Request Help Printing a report
Travis, thank you for the assistance on this. It worked as planned.

Now I only have one other question.

Is there a way to simulate a button click from within this same lines of code?

I have tried the doClick command it errors with the information the doClick is not a valid statement or something like that.

:prayer:


Mon Mar 26, 2012 7:10 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: Request Help Printing a report
You can force a button to click by using the following:
Code:
event.source.parent.getComponent("Button").doClick()

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Mon Mar 26, 2012 3:01 pm
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: