|
|
 | | From: | Stephan Fabrizek | | Subject: | Missing initial tokens | | Date: | Thu, 2 Dec 2004 11:53:16 +0100 |
|
|
 | Hi,
my name is Stephan Fabrizek and I'm working on my master theses with the task to implement an AutoFocus Frontend for Ptolemy II. Therefore I have created a new AutoFocus Director which is based on SDF. In the AutoFocus semantics there are delayed ports which means that information that is sent over these ports are available in the next iteration. I can simulate this by using a SampleDelayActor in Ptolemy. Now my idea was to add a parameter to every port, indicating wheather the port is delayed or not. During preinitialize of the director an initial token should be created for every delayed port, so that during execution there should be two tokens on every delayed channel one of the former computation and the token just created. I have done this by using code of the SampleDelay actor. Now the problem is that the tokens created initially seem not to be there. If I create an integer token with value 1 for example and add a monitor to that port, the value will not be displayed during execution. Here is the code I have added to preinitialize of the sdf director:
//look at every output port of the contained actors Iterator actors = ((CompositeActor)container).deepEntityList().iterator(); while (actors.hasNext()) { Actor actor = (Actor)actors.next(); if (_debugging) _debug("Invoking preinitialize(): ", ((NamedObj)actor).getFullName()); Iterator outputPorts = actor.outputPortList().iterator(); while (outputPorts.hasNext()) { IOPort port = (IOPort) outputPorts.next(); //only ports with the isDelayed attribute should be considered Parameter delayedParameter =(Parameter)port.getAttribute("isDelayed"); if (delayedParameter!=null) { TypedIOPort outputPort = (TypedIOPort)port; boolean isDelayed = ((BooleanToken)delayedParameter.getToken()).booleanValue(); try { Parameter output_tokenInitProduction = (Parameter)outputPort.getAttribute("tokenInitProduction"); if(output_tokenInitProduction==null){ output_tokenInitProduction = new Parameter(outputPort, "tokenInitProduction"); } output_tokenInitProduction.setExpression("0"); output_tokenInitProduction.setVisibility(Settable.EXPERT); output_tokenInitProduction.setTypeEquals(BaseType.INT); output_tokenInitProduction.setPersistent(false); if (isDelayed) { Parameter initialOutputs = (Parameter)outputPort.getContainer().getAttribute("initialOutputs"); if(initialOutputs==null){ initialOutputs=new Parameter(outputPort.getContainer(), "initialOutputs"); } initialOutputs.setTypeEquals(BaseType.UNKNOWN); initialOutputs.setVisibility(Settable.EXPERT); initialOutputs.setExpression("0"); output_tokenInitProduction.setExpression("1"); outputPort.setTypeEquals(contents.getType()); this.invalidateResolvedTypes(); outputPort.send(0, contents); } else { output_tokenInitProduction.setExpression("0"); } } catch (NameDuplicationException ex) {} } } }
Thanks Stephan Fabrizek
---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: ptolemy-hackers-request@ptolemy.eecs.berkeley.edu
|
|
|