001/* A unit system as defined by a set of base and derived units. 002 003 Copyright (c) 2001-2007 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 */ 027package ptolemy.data.unit; 028 029import ptolemy.data.expr.ScopeExtendingAttribute; 030import ptolemy.kernel.util.IllegalActionException; 031import ptolemy.kernel.util.NameDuplicationException; 032import ptolemy.kernel.util.NamedObj; 033 034////////////////////////////////////////////////////////////////////////// 035//// UnitSystem 036 037/** 038 <p>A unit system as defined by a set of base and derived units.</p> 039 <p> 040 The various measurement units of a unit system are represented by the 041 parameters of an instance of UnitSystem. 042 The units belong to a number of categories, such as length and time 043 in the International System of Units (SI). Each category has a base unit, 044 for example meter in the length category.</p> 045 <p> 046 Several basic unit systems are provided with Ptolemy II. They are specified 047 using MoML. Customized unit systems can be created following these examples. 048 </p> 049 050 @author Xiaojun Liu 051 @version $Id$ 052 @since Ptolemy II 2.0 053 @Pt.ProposedRating Red (liuxj) 054 @Pt.AcceptedRating Red (liuxj) 055 */ 056public class UnitSystem extends ScopeExtendingAttribute { 057 // FIXME: these issues should be addressed (cxh 8/02) 058 // 1. The entire notion of a category being indexed into a vector by an 059 // integer is a little strange. I don't think we have quite the right 060 // storage structure here. In anycase, it would be good to 061 // discuss the implementation details in a comment inside the UnitSystem 062 // method 063 // 064 // 2. Having static data makes for somewhat less robust code, especially 065 // when there is no way to reset the static data, which is why I added a 066 // reset() method. UnitSystem has no way of removing a unit from 067 // the static structures - what do I do if I screw up and add a bad unit? 068 069 /** Construct a unit system with the given name contained by the specified 070 * entity. The container argument must not be null, or a 071 * NullPointerException will be thrown. This attribute will use the 072 * workspace of the container for synchronization and version counts. 073 * If the name argument is null, then the name is set to the empty string. 074 * Increment the version of the workspace. 075 * @param container The container. 076 * @param name The name of this attribute. 077 * @exception IllegalActionException If the attribute is not of an 078 * acceptable class for the container, or if the name contains a period. 079 * @exception NameDuplicationException If the name coincides with 080 * an attribute already in the container. 081 */ 082 public UnitSystem(NamedObj container, String name) 083 throws IllegalActionException, NameDuplicationException { 084 super(container, name); 085 } 086}