Edward and Hackers,

Thanks for the response. I have tried a similar solution in the past (and I've since reimplemented the code you suggested below), but I get an error. Essentially what happens is the model is running and we're repeatedly checking the status of the simulation. Then we execute a number of commands which inject a token into an input port which seems to work. After a while, however, we get the following error:

com.cybernet.vsil.modeling.ExecutionError: Error executing model: ptolemy.kernel.util.IllegalActionException: Attempt to queue an event in the past: Current time is 0.03 while event time is 0.0
in .demo5.SLOT_MobilitySystem.MobilitySystemBradley_20070606_CYB
at com.cybernet.vsil.modeling.SEE.executionError(Unknown Source)
at ptolemy.actor.Manager.notifyListenersOfThrowable(Manager.java:706)
at ptolemy.actor.Manager.run(Manager.java:1013)
at ptolemy.actor.Manager$2.run(Manager.java:1066)

The error takes place some amount of time after the last "SET" command is sent and confirmed.

The error is thrown from the DEDirector code.

Any help would be much appreciated.

Ryan

Edward A. Lee wrote:
I suspect a race condition. Your code is presumably running in
a different thread from the model execution.

One thing you could try is to inject the signal in a ChangeRequest.
E.g., do something like this:

final IOPort port = (IOPort)parm;

ChangeRequest request = new ChangeRequest(... args here ...) {
  protected void _execute() {
     for(int i = 0;i < port.getWidthInside();i++) {
        port.sendClearInside(i);
        port.sendInside(i,new IntToken(setValue));
     }
  }};
port.getContainer().requestChange(request);


This will cause the "send" to occur between iterations
of the scheduler.  Depending on what director you are using (DE?),
this should occur safely between increments of time.

Edward


At 10:20 AM 6/4/2007, Ryan O'Grady wrote:
Hello Hackers,

I'm getting an exception when I attempt to inject tokens into a port from an outside 
source.  Basically, we have a command line interface that allows the loading and 
executing of a model.  There are some additional commands, but the salient one is 
"SET".  It's used to either change the value of a variable (which works) or set 
the value of the token on a port.  For an input port, the code does roughly the following:

--------
IOPort port = (IOPort)parm;

for(int i = 0;i < port.getWidthInside();i++) {
 port.sendClearInside(i);
 port.sendInside(i,new IntToken(setValue));
}
--------

The code works for my simple test cases, but when we try it on the large 
models, it works for a time then throws the following exception:

SEE ERR: Exception in thread "Thread-6" SEE ERR: 
com.cybernet.vsil.modeling.ExecutionError: Error executing model: 
ptolemy.kernel.util.IllegalActionException: Missed a firing at 0.0. The outside time is 
already 1.0.
in 
.demo5.SLOT_VetronicsSystem.VetronicsSystemBradley_20070525_CYB.SLOT_DriversIntegratedDisplay.DriversIntegratedDisplay_20061026_RRR.DE
 Director
SEE ERR:     at com.cybernet.vsil.modeling.SEE.executionError(Unknown 
Source)SEE ERR:
SEE ERR:     at 
ptolemy.actor.Manager.notifyListenersOfThrowable(Manager.java:706)SEE ERR:
SEE ERR:     at ptolemy.actor.Manager.run(Manager.java:1013)
      at ptolemy.actor.Manager$2.run(Manager.java:1066)

Any help is appreciated.

Ryan O'Grady


----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]


------------ Edward A. Lee
Chair of EECS and Robert S. Pepper Distinguished Professor
231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253, fax: 510-642-2845
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to