Hi Paolo,

> From: [EMAIL PROTECTED] (Paolo Lacatena)
> To: ptolemy-hackers@bennett.EECS.Berkeley.EDU
> Subject: BaseUnit & UnitCategory class
> Date: Tue, 07 Mar 2006 17:38:27 +0100
> 
> Hi all,
> when an UnitSystem is added to a Ptolemy model through Vergil interface, 
> a MoML command like the following is sent in MoMLChangeRequest:  
> 
>     <property name="cm" class="ptolemy.data.unit.BaseUnit" value="1.0">
>         <property name="Length" class="ptolemy.data.unit.UnitCategory">
>         </property>
>     </property>
>     <property name="meter" class="ptolemy.data.expr.Parameter" 
> value="100*cm">
>     </property>
> 
> Wich are the differences between ptolemy.data.unit.BaseUnit and 
> ptolemy.data.expr.Parameter? 

I don't have that much experience with the Unit system.

ptolemy.data.unit.BaseUnit extends ptolemy.data.expr.Parameter.

It looks like the primary difference between the two is that
BaseUnit.getToken() returns a token that contians " the unit
information specified by the unit category property."

I think in your example:
        <property name="cm" class="ptolemy.data.unit.BaseUnit" value="1.0">
            <property name="Length" class="ptolemy.data.unit.UnitCategory">
            </property>
        </property>
        <property name="meter" class="ptolemy.data.expr.Parameter" 
    value="100*cm">
        </property>

The difference is that BaseUnit is the basic unit of Length and
the the Parameter is a derived value that refers to the BaseUnit.

> Are there any difference between them regarding to the computing?
> Even if the MoMLParser accept the following MoML code:
> 
>     <property name="meter" class="ptolemy.data.expr.Parameter" 
> value="100*cm">
>         <property name="Length" class="ptolemy.data.unit.UnitCategory">
>         </property>
>     </property>
> 
> is it correct?

I'm not sure.  It would look like meter is being defined to
have a Length UnitCategory.  If no other Length UnitCategory
is defined, then this would be the default Length.

In the current implementation, it looks like the the first Length
UnitCategory gets registered and subsequent Lenth UnitCategorys are
ignored.

UnitCategory.java contains:
    public UnitCategory(NamedObj container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        UnitUtilities.registerUnitCategory(((BaseUnit) this.getContainer())
                .getName());
    }

UnitUtilities.java:

    /** Register the specified unit category name.
     *  If the category is not already registered, assign a unique index
     *  for the category.
     *  This method is static, so a category added here will be
     *  available throughout the system.
     *  <p>Note that the
     *  [EMAIL PROTECTED] UnitCategory#UnitCategory(NamedObj, String)} 
constructor
     *  calls this method.
     *
     *  @param categoryName The unit categoryName to be registered.
     */
    public static void registerUnitCategory(String categoryName) {
        synchronized (_indexTable) {
            Integer index = (Integer) _indexTable.get(categoryName);

            if (index != null) {
                return;
            } else {
                index = new Integer(_categories);
                _indexTable.put(categoryName, index);
                ++_categories;
                _categoryList.add(categoryName);
            }
        }
    }


> If so, what are the changes in the computing?
> 
> Thanks in advance
> Paolo

_Christopher

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to