[kepler-users] Problem with PN director

Christopher Brooks cxh at eecs.berkeley.edu
Tue Jun 21 07:31:46 PDT 2011


Hi Vincenzo,
Without sample code, it is hard to say for sure, but I believe
you need to check the for the token in fire()

if (input.hasToken(0)) {
}

Page 194 of the Designing Actors chapter in Volume 1 of the Design Doc at
http://ptolemy.eecs.berkeley.edu/ptolemyII/designdoc.htm
says:

> * A domain-polymorphic actor cannot assume that there is data at all the input ports. Most domainpolymorphic
> actors will read at most one input token from each port, and if there are sufficient
> inputs, produce exactly one token on each output port.
> * Some domains invoke the fire() method multiple times, working towards a converged solution.
> Thus, each invocation of fire() can be thought of as doing a tentative computation with tentative
> inputs and producing tentative outputs. Thus, the fire() method should not update persistent state.
> Instead, that should be done in the postfire() method, as discussed in the next section.

_Christopher

On 6/21/11 1:18 AM, Vincenzo Forchi wrote:
> Hi All,
>
> I have a problem with the PN director on kepler 2.2. I have a simple workflow: string constant -> file reader -> custom actor.
> The string constant fires only once, but my acotr is triggered twice, and the second times it fails because there is no token on the input port. I defined the token consumption rate for the input
> port, I have overridden prefire to return true only if a token is present on the input port, but the actor is still fired twice.
>
> This is a snippet from my fire method:
>
> System.out.println(myPort.hasToken(0));
> String xml = ((StringToken) myPort.get(0)).stringValue();
>
> This is the command line output, I caught the exception and printed the stack trace
>
> [run] true
> [run] ERROR (org.kepler.gui.MenuMapper:getActionFor:269) Exception trying to create an Action for classname: <org.kepler.gui.RunWithFeedbackChkBoxAction>:
> [run] java.lang.IllegalArgumentException: RunWithFeedbackChkBoxAction constructor could not get actions for DEBUG->ANIMATE EXECUTION or DEBUG->STOP ANIMATING (java.lang.reflect.InvocationTargetException)
> [run] ERROR (org.kepler.gui.MenuMapper:getActionFor:269) Exception trying to create an Action for classname: <org.kepler.gui.RunWithFeedbackChkBoxAction>:
> [run] java.lang.IllegalArgumentException: RunWithFeedbackChkBoxAction constructor could not get actions for DEBUG->ANIMATE EXECUTION or DEBUG->STOP ANIMATING (java.lang.reflect.InvocationTargetException)
> [run] ptolemy.actor.process.TerminateProcessException:
> [run] at ptolemy.domains.pn.kernel.PNQueueReceiver.get(PNQueueReceiver.java:198)
> [run] at ptolemy.actor.IOPort.get(IOPort.java:885)
> [run] at MyClass.fire(MyClass.java:119)
> [run] at ptolemy.actor.process.ProcessThread.run(ProcessThread.java:229)
>
> The very same code works flawlessly with the DDF director: any ideas?
>
> Thanks and cheers,
> Vincenzo
>

-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841      	                      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670



More information about the Kepler-users mailing list