Bug #4549
openString Replace actor "remembers" previous execution values
0%
Description
1. Build a workflow with an SDF director (set iterations to 1), an RExpression (turn off graphics output), and a Display actor. Hook the RExpression graphicsFileName port to the Display input port.
2. Run this workflow. There should be no noticeable output, as no token was passed to the Display actor. An Rplots.pdf file should have been generated in the appropriate subfolder of .kepler.
3. Add a String Replace actor. Hook the RExpression graphicsFileName port to the String Replace stringToEdit port, and hook the String Replace output port to the Display input port.
4. Run this workflow. Notice now that a Display actor window opens. A blank token of some sort was passed to the Display actor (I it's a "" string token). Again, another Rplots.pdf file should have been generated.
5. Turn on graphics output in the RExpression and run the workflow. The expected RExpression-1.png file should have been generated, and the Display actor should open and display the filename. Pay attention to the timestamp on the folder.
6. Turn off graphics output in the RExpression and run the workflow. The Display actor should open again and display the png filename from the previous execution. If you browse the .kepler, you should see the correct folder with the expected Rplots.pdf file.
Updated by ben leinfelder almost 15 years ago
changed in the ptolemy code to not fire the old token if a new one did not exist
Updated by Christopher Brooks almost 15 years ago
Unfortunately, this fix causes one of the tests to fail:
------------------ testing $PTII/ptolemy/actor/lib/string/test/auto/StringReplace2.xml
auto.tcl: Setting watchdog for 200 seconds at Tue Jan 12 23:26:36 PST 2010
3 ms. Memory: 2448K Free: 847K (35%)
Exception in thread "Thread-30" java.lang.RuntimeException: Execution failed
at ptolemy.moml.MoMLSimpleApplication$1.run(MoMLSimpleApplication.java:117)
Caused by: ptolemy.kernel.util.IllegalActionException: Channel index 0 is out of range, because width is only 0.
in .StringReplace2.StringReplace4.stringToEdit
at ptolemy.actor.IOPort.hasToken(IOPort.java:1885)
at ptolemy.actor.lib.string.StringReplace.fire(StringReplace.java:156)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:469)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:188)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:457)
at ptolemy.actor.Manager.iterate(Manager.java:714)
at ptolemy.actor.Manager.execute(Manager.java:349)
at ptolemy.actor.Manager.run(Manager.java:1120)
at ptolemy.actor.Manager$3.run(Manager.java:1161)
util.testsuite.WatchDog.cancel(): canceling Tue Jan 12 23:26:36 PST 2010
The change was:
Modified: trunk/ptolemy/actor/lib/string/StringReplace.java
===================================================================
--- trunk/ptolemy/actor/lib/string/StringReplace.java 2010-01-13 02:15:04 UTC (rev 56879)
++ trunk/ptolemy/actor/lib/string/StringReplace.java 2010-01-13 07:05:39 UTC (rev 56880)@ -153,6 +153,9
@
if (_debugging) {
_debug("Called fire()");
}
if (!stringToEdit.getPort().hasToken(0)) {
+ return;
+ }
replacement.update();
stringToEdit.update();
pattern.update();
I'm going to comment out this change temporarily.
I'm not sure, but one possible problem is that stringToEdit is a PortParameter.
If the StringReplace actor has stringToEdit set as a Parameter (not as a Port),
then what does getPort().hasToken() return.
It's late and I don't fully understand the test case without replicating the
instructions. A test model that does not use RExpression might help track this
down. There could be a generic problem with all actors that have PortParameters
or PortParameters and RExpression.
Updated by ben leinfelder almost 15 years ago
added a check for the channel width.
ran the tests - passed.
committed r56911
Now the actor will not fire if there is no input on stringToEdit which seems reasonable (as opposed to firing with the last known token it had).
Updated by Christopher Brooks almost 15 years ago
A test is failing with this change:
------------------ testing $PTII/ptolemy/actor/lib/string/test/auto/StringReplace2.xml
auto.tcl: Setting watchdog for 200 seconds at Thu Jan 14 09:53:24 PST 2010
4 ms. Memory: 2480K Free: 1153K (46%)
Exception in thread "Thread-30" java.lang.RuntimeException: Execution failed
at ptolemy.moml.MoMLSimpleApplication$1.run(MoMLSimpleApplication.java:117)
Caused by: ptolemy.kernel.util.IllegalActionException: Test fails in iteration 0.
Empty input on channel 0
in .StringReplace2.Test
at ptolemy.actor.lib.Test.fire(Test.java:233)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:469)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:188)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:457)
at ptolemy.actor.Manager.iterate(Manager.java:714)
at ptolemy.actor.Manager.execute(Manager.java:349)
at ptolemy.actor.Manager.run(Manager.java:1120)
at ptolemy.actor.Manager$3.run(Manager.java:1161)
util.testsuite.WatchDog.cancel(): canceling Thu Jan 14 09:53:24 PST 2010
I believe there is a problem with either RExpression or with PortParameters.
Updated by ben leinfelder almost 15 years ago
[i know you think i didn't test it, but i did...that's confusing since now it is erring for me, too]
How should this work, then?
My assumption is that the StringReplace actor should not fire/emit an output token if it has no new token on the stringToEdit input port. This case happens with the RExpression graphicsFileName actor is connected to the stringToEdit port but graphics output is disabled (no file is passed to the stringToEdit port).
Now the "Test" actor downstream from StringReplace isn't getting the token it expects because there is no token being sent.