Esempio n. 1
0
        /// <summary>
        /// Gets the name of the SI unit associated with the unit category, e.g. Pascals for pressure.
        /// </summary>
        /// <remarks>
        /// <para>The SI unit is the basis for conversions between any two units of the same category, either SI or
        /// customary.
        /// </para>
        /// </remarks>
        /// <returns>The Aspen(TM) display unit that corresponds to the current unit.</returns>
        /// <param name="unit">The unit to get the Aspen (TM) unit for.</param>
        public static String AspenUnit(String unit)
        {
            String retVal   = String.Empty;
            String category = String.Empty;
            bool   found    = false;

            for (int i = 0; i < units.Count; i++)
            {
                CapeOpen.unit current = (CapeOpen.unit)units[i];
                if (current.Name == unit)
                {
                    category = current.Category;
                    found    = true;
                }
            }
            for (int i = 0; i < unitCategories.Count; i++)
            {
                CapeOpen.unitCategory current = (CapeOpen.unitCategory)unitCategories[i];
                if (current.Name == category)
                {
                    retVal = current.AspenUnit;
                    found  = true;
                }
            }
            if (!found)
            {
                throw new CapeOpen.CapeBadArgumentException(String.Concat("Unit: ", unit, " was not found"), 1);
            }
            return(retVal);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the SI unit associated with the unit.
        /// </summary>
        /// <remarks>A unit category represents a specific combination of dimsionality values. Examples would be
        /// pressure or temperature. This method would return the SI unit for the category, such as Kelvin (K) for
        /// temperature or Pascal (N/m^2) for pressure..</remarks>
        /// <param name="Unit">The unit to get the SI unit of.</param>
        /// <returns>The SI unit that corresponds to the unit.</returns>
        public static String FindSIUnit(String Unit)
        {
            String retVal   = String.Empty;
            String category = UnitCategory(Unit);

            for (int i = 0; i < unitCategories.Count; i++)
            {
                CapeOpen.unitCategory current = (CapeOpen.unitCategory)unitCategories[i];
                if (current.Name == category)
                {
                    retVal = current.SI_Unit;
                }
            }
            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// The dimensioality of the unit of measure.
        /// </summary>
        /// <remarks>
        /// <para>The dimensionality of the parameter represents the physical dimensional axes of this parameter. It
        /// is expected that the dimensionality must cover at least 6 fundamental axes (length, mass, time, angle,
        /// temperature and charge). A possible implementation could consist in being a constant length array vector
        /// that contains the exponents of each basic SI unit, following directives of SI-brochure (from
        /// http://www.bipm.fr/). So if we agree on order &lt;m kg s A K,&gt; ... velocity would be &lt;1,0,-1,0,0,0&gt;:
        /// that is m1 * s-1 =m/s. We have suggested to the  CO Scientific Committee to use the SI base units plus the
        /// SI derived units with special symbols (for a better usability and for allowing the definition of angles).
        /// </para>
        /// </remarks>
        /// <param name="unit">The unit to get the dimensionality of.</param>
        /// <returns>The dimenality of the unit.</returns>
        public static double[] Dimensionality(String unit)
        {
            string category = CapeOpen.CDimensions.UnitCategory(unit);

            double[] retVal = { 0, 0, 0, 0, 0, 0, 0, 0 };
            for (int i = 0; i < unitCategories.Count; i++)
            {
                CapeOpen.unitCategory current = (CapeOpen.unitCategory)unitCategories[i];
                if (current.Name == category)
                {
                    retVal[0] = current.Length;
                    retVal[1] = current.Mass;
                    retVal[2] = current.Time;
                    retVal[3] = current.ElectricalCurrent;
                    retVal[4] = current.Temperature;
                    retVal[5] = current.AmountOfSubstance;
                    retVal[6] = current.Luminous;
                    retVal[7] = current.Currency;
                }
            }
            return(retVal);
        }