[kepler-users] retrieving name of a container at run time.

Christopher Brooks cxh at eecs.berkeley.edu
Fri Feb 11 16:45:47 PST 2011


Hi Bob,

Const actors are, well, um constant.  :-)
Sorry.  :-)

My understanding is that the value of the Constant actor is
calculated once during execution and then expected not to change.

I've attached a model that uses Expression actors that call the
this.getContainer().getName().  I'm not sure if this will notice
when the container changes during run time, you will have to check.

Ptolemy II 8.0.1 includes enhancements to ObjectToken, I've included
the documentation for some of that work.  The docs are from
ptII/doc.

It might be easiest to write an actor that calls getContainer().getName()
each time it fires and use that.

Your question is a good question, long ago I tried to write a model
that would plot the memory usage of itself but ran into problems because
the Expression actor was only evaluating its expression once.  I'm not
sure if that is still the case.

_Christopher

On 2/11/11 11:25 AM, Bob Weber wrote:
> I have discovered that setting the value of a constant actor to the expression getContainer().getName will retrieve the name of the next level up container. But, the constant actor only evaluates the
> expression when the expression changes, not when the constant fires. Therefore, if the name of the container changes, the old name will be output by the constant, not the new name.
>
> I know that Ptolemy offers a Name Parameter that does the reverse of what I want--it sets the name of the container. But then the container cannot be easily re-instantiated or copy-pasted because the
> new instance gets the name set by the Name Parameter (which doesn't seem to check for, or gracefully, handle name collisions).
>
> I have tried to use the getContainer().getName in an Expression actor and in a Python actor to get the expression to be evaluated at run time but neither of those actors recognizes the function.
>
> I understand that I could create a constant equal to the string I'm trying to retrieve but I was hoping to use the rename command accessed by right clicking on the container to provide a smoother,
> more consistent user interface.
>
> So, is there a way to programmatically retrieve the name of an actor's container?
>
> Thanks,
> Bob Weber
>
>
>
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at kepler-project.org
> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841      	                      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Objects.xml
Type: text/xml
Size: 17298 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20110211/5588cef1/attachment.xml>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20110211/5588cef1/attachment.htm>


More information about the Kepler-users mailing list