[kepler-users] PN Director Question

Peter Reutemann fracpete at gmail.com
Wed Oct 21 16:28:11 PDT 2009


> I am trying to implement an actor that has two input ports-input and window.
> In the implementation, I want that the actor should execute different set of
> lines depending on if the tokens are present or not present at the window
> port. I am trying to do something like:
> if(window.hasToken()){
>   ArrayToken tokenD = (ArrayToken) input.get(0);
> System.out.println("There is a token at the window port");
> }
> else
>  System.out.println("There is no token at the window port");
>
> I observer that when I use a PN director, the value of  window.hasToken() is
> true even if there is no token at the window port. I actually used an
> arraytosequence actor to output the array tokens to my actor.So even if the
> input to arraytosequence is { }, my actor returns true for window.hasToken()
> and enters the "if" block. However after executing the first line of the
> "if" block, it stops i.e it does not print the next line. Can someone tell
> me why the PN director sets the value false when there is no token at the
> window port?

Stumbled across that myself...

>From what I understand: the PN domain always assumes that there are
tokens available in the queues, at one point or another (the
ptolemy.domains.pn.kernel.PNQueueReceiver class always returns "true"
in the "hasToken()" method). Only when using the "get(int)"-method of
the port it is attempted to obtain a token. If none is present at the
moment, then the method won't exit until a token shows up or the
workflow terminates.

Cheers, Peter
-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/           Ph. +64 (7) 858-5174



More information about the Kepler-users mailing list