[kepler-dev] A weird behavior

Edward A. Lee eal at eecs.berkeley.edu
Tue Jan 9 17:12:24 PST 2007


There is also the fundamental Java issue with cloning:
If the class contains a private reference to something it
allocates on the heap, then after cloning, both the original
and the new object will refer to the same object.  Thus, usually,
the clone method needs to be overridden to create a new copy
of the private object.

Edward

At 02:22 PM 1/9/2007, Christopher Brooks wrote:
>If it is a cloning problem, then two common problems:
>
>1) The name of the field that refers to the port or parameter
>and the name assigned to it are different.
>
>Right:
>
>    public Ramp(CompositeEntity container, String name)
>            throws NameDuplicationException, IllegalActionException {
>        super(container, name);
>...
>        init = new Parameter(this, "init");
>        init.setExpression("0");
>...
>    }
>...
>    public Parameter init;
>
>Wrong:
>
>    public Ramp(CompositeEntity container, String name)
>            throws NameDuplicationException, IllegalActionException {
>        super(container, name);
>... 
>        init = new Parameter(this, "initization value");  //WRONG
>        init.setExpression("0");
>...
>    }
>..
>    public Parameter init;
>
>
>If you want to display a different name, use setDisplayName().
>
>or 
>
>2) Some actors need a clone method that properly sets the type
>constraints.
>See the Designing Actors chapter of the 1st volume of the design doc.
>http://ptolemy.eecs.berkeley.edu/papers/05/ptIIdesign1-intro/
>
>
>Note that the tests in ptolemy/configs looks for this sort of problem
>in a configuration.
>
>In Ptolemy II 6.0, The ptolemy.actor.gui.Configuration method includes
>a check() method that checks the configuration for common problems.
>
>
>The Configuration class comment says:
>
> To access the configuration from a random place, if you have a
> NamedObj, then you can call Configuration.findEffigy().  This is a
> static method.  Then call Effigy.toplevel(). The result will always be
> the configuration.
>
>So, in principle, you could write some code to get the Configuration
>and call check() on it.  I'll see if I can hack something up, but
>it would require updating Ptolemy II.
>
>_Christopher
>--------
>    
>    Hi,
>    
>    I tried to modify the web service actor, which inherits from
>    TypedAtomicActor.
>    
>    Here is the problem: I found out that, after cloning the actor
>    instances, or after opening a saved file, the actor instances could not
>    behave properly. However, if I instantiate the actor and set the
>    parameters again, it would work properly. Can anyone tell me what might
>    go wrong here?
>    
>    thanks,
>    Alex
>    
>    --===============0412506775==
>    Content-Type: text/plain; charset="us-ascii"
>    MIME-Version: 1.0
>    Content-Transfer-Encoding: 7bit
>    Content-Disposition: inline
>    
>    _______________________________________________
>    Kepler-dev mailing list
>    Kepler-dev at ecoinformatics.org
>    http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>    
>    --===============0412506775==--
>--------
>_______________________________________________
>Kepler-dev mailing list
>Kepler-dev at ecoinformatics.org
>http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev

------------ 
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
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal  



More information about the Kepler-dev mailing list