[kepler-dev] difference between moml class and entity

Chad Berkley berkley at nceas.ucsb.edu
Mon Dec 12 09:33:19 PST 2005


right, so i have a class, and i want to export an instance.  can I do 
that?  it seems to me the way ptII gets around this problem is to hard 
code the <entity> into the actor library.  If I don't want to hard code 
it, how can I get an entity?  The only information I have a priori is 
the name of the class (i.e. ptolemy.actor.lib.Sinewave).  I don't even 
know that it's a moml class instead of a java class.

chad

Edward A. Lee wrote:
> 
> The way the library works is that when you drag something into
> a model, the entity in the library is treated as a template.
> The drag-and-drop code asks the template to exportMoML(), and
> then interprets that MoML in the context of the drop destination.
> Thus, if the template is a class, then you will get a class
> in the drop destination.  If the template is an instance, then
> you will get an instance.
> 
> The Sinewave actor in the library is an instance of a class
> defined in a separate file. In the library it is defined as:
> 
> <entity name="Sinewave" class="ptolemy.actor.lib.Sinewave"/>
> 
> There is a file $PTII/ptolemy/actor/lib/Sinewave.xml that contains
> 
> <class name="Sinewave" extends="ptolemy.actor.TypedCompositeActor">
>  ...
> </class>
> 
> 
> Hope this helps...
> 
> Edward
> 
> At 03:08 PM 12/9/2005 -0800, Chad Berkley wrote:
> 
>> exportMoML() is what i meant by serialize.  When i'm adding a moml 
>> class to the library, i get a class exported, but that seems 
>> problematic because the class is actually an instance (if that makes 
>> any sense). The question i've been wondering about is, why is Sinewave 
>> declared (in the actor library) as an entity when it is, in fact, 
>> defined as a class (in it's moml definition); and how can i 
>> programatically do that if that is required to create an instance?
>>
>> I feel like i'm missing something here, but I'm not sure what.
>>
>> chad
>>
>> Edward A. Lee wrote:
>>
>>>
>>> I'm confused... What do you mean by "serialize"?
>>> If I do exportMoML() on an instance, I will get an instance.
>>> If I do exportMoML() on a class, I will get a class...
>>> Seems right to me...
>>> Edward
>>>
>>> At 10:24 AM 12/9/2005 -0800, Chad Berkley wrote:
>>>
>>>> Hi,
>>>>
>>>> I've run into a problem when trying to differentiate whether a 
>>>> composite
>>>> should be serialized to moml as a <class> or as an <entity>.  In 
>>>> PTII, a
>>>> Composite is defined as a <class> within its own moml file.  Take
>>>> Sinewave (ptolemy/actor/lib/Sinewave.xml) for example:
>>>>
>>>> <class name="Sinewave" extends="ptolemy.actor.TypedCompositeActor">
>>>> ....</class>
>>>>
>>>> However, within the actor library CompositeEntity, Sinewave is refered
>>>> to as an entity (/ptolemy/actor/lib/sequencesources.xml):
>>>>
>>>> <entity name="Sinewave" class="ptolemy.actor.lib.Sinewave"/>
>>>>
>>>> Programmatically, if I serialize Sinewave's moml, the momlParser 
>>>> returns
>>>> a class element.  This is problematic because I'm altering the actor
>>>> library programmatically.  When I do a
>>>> Sinewave.setContainer("actorLibrary"), it serializes as a class.  This
>>>> wouldn't be bad, except that when you drag it onto the canvas, it is
>>>> then interpreted as a class that needs to be instantiated instead of as
>>>> an instance (i.e. the purple box is drawn around it).
>>>>
>>>> Is there a way to tell it to give me the instance moml instead of the
>>>> class moml?
>>>>
>>>> thanks,
>>>> chad
>>>> _______________________________________________
>>>> Kepler-dev mailing list
>>>> Kepler-dev at ecoinformatics.org
>>>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev 
>>>>
>>>
>>>
>>> ------------
>>> Edward A. Lee
>>> Professor, Chair of the EE Division, Associate Chair of EECS
>>> 231 Cory Hall, UC Berkeley, Berkeley, CA 94720
>>> phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
>>> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
> 
> 
> ------------
> Edward A. Lee
> Professor, Chair of the EE Division, Associate Chair of EECS
> 231 Cory Hall, UC Berkeley, Berkeley, CA 94720
> phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal 



More information about the Kepler-dev mailing list