示例#1
0
 public UnitSystem(string name, bool readOnly, TemperatureUnitType temperature,
                   PressureUnitType pressure, LiquidHeadUnitType liquidHead, MassFlowRateUnitType massFlowRate,
                   VolumeFlowRateUnitType volumeFlowRate, VolumeRateFlowLiquidsUnitType volumeRateFlowLiquids,
                   VolumeRateFlowGasesUnitType volumeRateFlowGases, MoistureContentUnitType moistureContent,
                   FractionUnitType fraction, SpecificEnergyUnitType enthalpy, SpecificEntropyUnitType entropy,
                   SpecificHeatUnitType specificHeat, EnergyUnitType energy, PowerUnitType power, DensityUnitType density,
                   SpecificVolumeUnitType specificVolume,
                   DynamicViscosityUnitType dynamicViscosity, KinematicViscosityUnitType kinematicViscosity,
                   ThermalConductivityUnitType conductivity, HeatTransferCoefficientUnitType heatTransferCoefficient,
                   VolumeHeatTransferCoefficientUnitType volumeHeatTransferCoefficient, FoulingFactorUnitType foulingFactor, HeatFluxUnitType heatFlux,
                   DiffusivityUnitType diffusivity, SurfaceTensionUnitType surfaceTension, VelocityUnitType velocity,
                   MassUnitType mass, LengthUnitType length, SmallLengthUnitType smallLength, MicroLengthUnitType microLength,
                   AreaUnitType area, VolumeUnitType volume, MassVolumeConcentrationUnitType massVolumeConcentration, TimeUnitType time,
                   PlaneAngleUnitType planeAngle, MoleFlowRateUnitType moleFlowRate)
 {
     this.name                          = name;
     this.temperature                   = temperature;
     this.pressure                      = pressure;
     this.liquidHead                    = liquidHead;
     this.massFlowRate                  = massFlowRate;
     this.volumeFlowRate                = volumeFlowRate;
     this.volumeRateFlowLiquids         = volumeRateFlowLiquids;
     this.volumeRateFlowGases           = volumeRateFlowGases;
     this.moistureContent               = moistureContent;
     this.fraction                      = fraction;
     this.enthalpy                      = enthalpy;
     this.entropy                       = entropy;
     this.specificHeat                  = specificHeat;
     this.energy                        = energy;
     this.power                         = power;
     this.density                       = density;
     this.specificVolume                = specificVolume;
     this.dynamicViscosity              = dynamicViscosity;
     this.kinematicViscosity            = kinematicViscosity;
     this.conductivity                  = conductivity;
     this.diffusivity                   = diffusivity;
     this.heatTransferCoefficient       = heatTransferCoefficient;
     this.volumeHeatTransferCoefficient = volumeHeatTransferCoefficient;
     this.foulingFactor                 = foulingFactor;
     this.heatFlux                      = heatFlux;
     this.surfaceTension                = surfaceTension;
     this.velocity                      = velocity;
     this.mass                          = mass;
     this.length                        = length;
     this.smallLength                   = smallLength;
     this.microLength                   = microLength;
     this.area                          = area;
     this.volume                        = volume;
     this.massVolumeConcentration       = massVolumeConcentration;
     this.time                          = time;
     this.planeAngle                    = planeAngle;
     this.moleFlowRate                  = moleFlowRate;
     this.readOnly                      = readOnly;
 }
示例#2
0
        public virtual void SetObjectData(SerializationInfo info, StreamingContext context)
        {
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionUnitSystem", typeof(int));

            if (persistedClassVersion >= 1)
            {
                this.name                          = (string)info.GetValue("Name", typeof(string));
                this.readOnly                      = (bool)info.GetValue("IsReadOnly", typeof(bool));
                this.area                          = (AreaUnitType)info.GetValue("AreaUnit", typeof(AreaUnitType));
                this.density                       = (DensityUnitType)info.GetValue("DensityUnit", typeof(DensityUnitType));
                this.diffusivity                   = (DiffusivityUnitType)info.GetValue("DiffusivityUnit", typeof(DiffusivityUnitType));
                this.dynamicViscosity              = (DynamicViscosityUnitType)info.GetValue("DynamicViscosityUnit", typeof(DynamicViscosityUnitType));
                this.energy                        = (EnergyUnitType)info.GetValue("EnergyUnit", typeof(EnergyUnitType));
                this.foulingFactor                 = (FoulingFactorUnitType)info.GetValue("FoulingFactorUnit", typeof(FoulingFactorUnitType));
                this.fraction                      = (FractionUnitType)info.GetValue("FractionUnit", typeof(FractionUnitType));
                this.heatFlux                      = (HeatFluxUnitType)info.GetValue("HeatFluxUnit", typeof(HeatFluxUnitType));
                this.heatTransferCoefficient       = (HeatTransferCoefficientUnitType)info.GetValue("HeatTransferCoefficientUnit", typeof(HeatTransferCoefficientUnitType));
                this.volumeHeatTransferCoefficient = (VolumeHeatTransferCoefficientUnitType)info.GetValue("VolumeHeatTransferCoefficientUnit", typeof(VolumeHeatTransferCoefficientUnitType));
                this.kinematicViscosity            = (KinematicViscosityUnitType)info.GetValue("KinematicViscosityUnit", typeof(KinematicViscosityUnitType));
                this.length                        = (LengthUnitType)info.GetValue("LengthUnit", typeof(LengthUnitType));
                this.liquidHead                    = (LiquidHeadUnitType)info.GetValue("LiquidHeadUnit", typeof(LiquidHeadUnitType));
                this.massFlowRate                  = (MassFlowRateUnitType)info.GetValue("MassFlowRateUnit", typeof(MassFlowRateUnitType));
                this.mass                          = (MassUnitType)info.GetValue("MassUnit", typeof(MassUnitType));
                this.massVolumeConcentration       = (MassVolumeConcentrationUnitType)info.GetValue("MassVolumeConcentrationUnit", typeof(MassVolumeConcentrationUnitType));
                this.microLength                   = (MicroLengthUnitType)info.GetValue("MicroLengthUnit", typeof(MicroLengthUnitType));
                this.moistureContent               = (MoistureContentUnitType)info.GetValue("MoistureContentUnit", typeof(MoistureContentUnitType));
                this.planeAngle                    = (PlaneAngleUnitType)info.GetValue("PlaneAngleUnit", typeof(PlaneAngleUnitType));
                this.power                         = (PowerUnitType)info.GetValue("PowerUnit", typeof(PowerUnitType));
                this.pressure                      = (PressureUnitType)info.GetValue("PressureUnit", typeof(PressureUnitType));
                this.smallLength                   = (SmallLengthUnitType)info.GetValue("SmallLengthUnit", typeof(SmallLengthUnitType));
                this.enthalpy                      = (SpecificEnergyUnitType)info.GetValue("SpecificEnergyUnit", typeof(SpecificEnergyUnitType));
                this.entropy                       = (SpecificEntropyUnitType)info.GetValue("SpecificEntropyUnit", typeof(SpecificEntropyUnitType));
                this.specificHeat                  = (SpecificHeatUnitType)info.GetValue("SpecificHeatUnit", typeof(SpecificHeatUnitType));
                this.specificVolume                = (SpecificVolumeUnitType)info.GetValue("SpecificVolumeUnit", typeof(SpecificVolumeUnitType));
                this.surfaceTension                = (SurfaceTensionUnitType)info.GetValue("SurfaceTensionUnit", typeof(SurfaceTensionUnitType));
                this.temperature                   = (TemperatureUnitType)info.GetValue("TemperatureUnit", typeof(TemperatureUnitType));
                this.conductivity                  = (ThermalConductivityUnitType)info.GetValue("ThermalConductivityUnit", typeof(ThermalConductivityUnitType));
                this.time                          = (TimeUnitType)info.GetValue("TimeUnit", typeof(TimeUnitType));
                this.velocity                      = (VelocityUnitType)info.GetValue("VelocityUnit", typeof(VelocityUnitType));
                this.volumeFlowRate                = (VolumeFlowRateUnitType)info.GetValue("VolumeFlowRateUnit", typeof(VolumeFlowRateUnitType));
                this.volumeRateFlowGases           = (VolumeRateFlowGasesUnitType)info.GetValue("VolumeRateFlowGasesUnit", typeof(VolumeRateFlowGasesUnitType));
                this.volumeRateFlowLiquids         = (VolumeRateFlowLiquidsUnitType)info.GetValue("VolumeRateFlowLiquidsUnit", typeof(VolumeRateFlowLiquidsUnitType));
                this.volume                        = (VolumeUnitType)info.GetValue("VolumeUnit", typeof(VolumeUnitType));
            }
            if (persistedClassVersion >= 2)
            {
                this.moleFlowRate = (MoleFlowRateUnitType)info.GetValue("MoleFlowRateUnit", typeof(MoleFlowRateUnitType));
            }
        }
示例#3
0
        private double getMultiplier(MassUnitType type)
        {
            switch (type)
            {
            case MassUnitType.Miligram:
                return(1);

            case MassUnitType.Santigram:
                return(10);

            case MassUnitType.Desigram:
                return(100);

            case MassUnitType.Gram:
                return(1000);

            case MassUnitType.Dekagram:
                return(10000);

            case MassUnitType.Hektogram:
                return(100000);

            case MassUnitType.Kilogram:
                return(1000000);

            case MassUnitType.Ton:
                return(10000000);

            case MassUnitType.Kiloton:
                return(100000000);

            case MassUnitType.Pound:
                return(453592.37d);

            case MassUnitType.Kilopound:
                return(453592370);

            case MassUnitType.Karat:
                return(200);

            case MassUnitType.Ons:
                return(28349.523125d);

            default:
                throw new ArgumentException("Hatalı ölçü birimi seçildi.");
            }
        }
示例#4
0
        public static MassUnitType GetUnitAsEnum(string unitString)
        {
            IDictionaryEnumerator myEnumerator = unitStringTable.GetEnumerator();
            String       name;
            MassUnitType type = MassUnitType.Kilogram;

            while (myEnumerator.MoveNext())
            {
                name = myEnumerator.Value as String;
                if (name.Equals(unitString))
                {
                    type = (MassUnitType)myEnumerator.Key;
                    break;
                }
            }
            return(type);
        }
示例#5
0
        public void Commit(UnitSystem us)
        {
            this.name                          = us.Name; //ep
            this.temperature                   = us.temperature;
            this.pressure                      = us.pressure;
            this.liquidHead                    = us.liquidHead;
            this.massFlowRate                  = us.massFlowRate;
            this.volumeFlowRate                = us.volumeFlowRate;
            this.volumeRateFlowLiquids         = us.volumeRateFlowLiquids;
            this.volumeRateFlowGases           = us.volumeRateFlowGases;
            this.moistureContent               = us.moistureContent;
            this.fraction                      = us.fraction;
            this.enthalpy                      = us.enthalpy;
            this.entropy                       = us.entropy;
            this.specificHeat                  = us.specificHeat;
            this.energy                        = us.energy;
            this.power                         = us.power;
            this.density                       = us.density;
            this.specificVolume                = us.specificVolume;
            this.dynamicViscosity              = us.dynamicViscosity;
            this.kinematicViscosity            = us.kinematicViscosity;
            this.conductivity                  = us.conductivity;
            this.diffusivity                   = us.diffusivity;
            this.heatTransferCoefficient       = us.heatTransferCoefficient;
            this.volumeHeatTransferCoefficient = us.volumeHeatTransferCoefficient;
            this.foulingFactor                 = us.foulingFactor;
            this.heatFlux                      = us.heatFlux;
            this.surfaceTension                = us.surfaceTension;
            this.velocity                      = us.velocity;
            this.mass                          = us.mass;
            this.length                        = us.length;
            this.smallLength                   = us.smallLength;
            this.microLength                   = us.microLength;
            this.area                          = us.area;
            this.volume                        = us.volume;
            this.massVolumeConcentration       = us.massVolumeConcentration;

            this.time         = us.time;
            this.planeAngle   = us.planeAngle;
            this.moleFlowRate = us.moleFlowRate;

            this.OnUnitSystemChanged(this);
        }
示例#6
0
 public UnitSystem()
 {
     this.name                          = "SI"; //ep
     this.temperature                   = TemperatureUnitType.Kelvin;
     this.pressure                      = PressureUnitType.Kilopascal;
     this.liquidHead                    = LiquidHeadUnitType.Meter;
     this.massFlowRate                  = MassFlowRateUnitType.KgPerHour;
     this.volumeFlowRate                = VolumeFlowRateUnitType.CubicMeterPerHour;
     this.volumeRateFlowLiquids         = VolumeRateFlowLiquidsUnitType.CubicMeterPerHour;
     this.volumeRateFlowGases           = VolumeRateFlowGasesUnitType.CubicMeterPerHour;
     this.moistureContent               = MoistureContentUnitType.KgPerKg;
     this.fraction                      = FractionUnitType.Percent;
     this.enthalpy                      = SpecificEnergyUnitType.KilojoulePerKg;
     this.entropy                       = SpecificEntropyUnitType.KilojoulePerKgKelvin;
     this.specificHeat                  = SpecificHeatUnitType.KilojoulePerKgKelvin;
     this.energy                        = EnergyUnitType.Kilojoule;
     this.power                         = PowerUnitType.Kilowatt;
     this.density                       = DensityUnitType.KgPerCubicMeter;
     this.specificVolume                = SpecificVolumeUnitType.CubicMeterPerKg;
     this.dynamicViscosity              = DynamicViscosityUnitType.PascalSecond;
     this.kinematicViscosity            = KinematicViscosityUnitType.SquareMeterPerSec;
     this.conductivity                  = ThermalConductivityUnitType.WattPerMeterKelvin;
     this.diffusivity                   = DiffusivityUnitType.SquareMeterPerSec;
     this.velocity                      = VelocityUnitType.MeterPerSec;
     this.mass                          = MassUnitType.Kilogram;
     this.length                        = LengthUnitType.Meter;
     this.smallLength                   = SmallLengthUnitType.Centimeter;
     this.microLength                   = MicroLengthUnitType.Micrometer;
     this.heatTransferCoefficient       = HeatTransferCoefficientUnitType.WattPerSquareMeterKelvin;
     this.volumeHeatTransferCoefficient = VolumeHeatTransferCoefficientUnitType.WattPerCubicMeterKelvin;
     this.foulingFactor                 = FoulingFactorUnitType.SquareMeterKelvinPerWatt;
     this.surfaceTension                = SurfaceTensionUnitType.NewtonPerMeter;
     this.area                          = AreaUnitType.SquareMeter;
     this.volume                        = VolumeUnitType.CubicMeter;
     this.massVolumeConcentration       = MassVolumeConcentrationUnitType.KgPerCubicMeter;
     this.time                          = TimeUnitType.Second;
     this.heatFlux                      = HeatFluxUnitType.WattPerSquareMeter;
     this.planeAngle                    = PlaneAngleUnitType.Radian;
     this.moleFlowRate                  = MoleFlowRateUnitType.KmolePerSec;
     this.readOnly                      = true;
 }
示例#7
0
        private void CreateDefaultUnit(string name, TemperatureUnitType temperature, PressureUnitType pressure,
                                       LiquidHeadUnitType liquidHead, MassFlowRateUnitType massFlowRate, VolumeFlowRateUnitType volumeFlowRate,
                                       VolumeRateFlowLiquidsUnitType volumeRateFlowLiquids, VolumeRateFlowGasesUnitType volumeRateFlowGases,
                                       MoistureContentUnitType moistureContent, FractionUnitType fraction, SpecificEnergyUnitType specificEnergy,
                                       SpecificEntropyUnitType specificEntropy, SpecificHeatUnitType specificHeat,
                                       EnergyUnitType energy, PowerUnitType power, DensityUnitType density,
                                       SpecificVolumeUnitType specificVolume, DynamicViscosityUnitType dynamicViscosity,
                                       KinematicViscosityUnitType kinematicViscosity, ThermalConductivityUnitType thermalConductivity,
                                       HeatTransferCoefficientUnitType heatTransferCoefficient, VolumeHeatTransferCoefficientUnitType volumeHeatTransferCoefficient,
                                       FoulingFactorUnitType foulingFactor,
                                       HeatFluxUnitType heatFluxDensity, DiffusivityUnitType diffusivity,
                                       SurfaceTensionUnitType surfaceTension, VelocityUnitType velocity, MassUnitType mass,
                                       LengthUnitType length, SmallLengthUnitType smallLength, MicroLengthUnitType microLength,
                                       AreaUnitType area, VolumeUnitType volume, MassVolumeConcentrationUnitType massVolumeConcentration,
                                       TimeUnitType time, PlaneAngleUnitType planeAngle)
        {
            UnitSystem us = new UnitSystem(name, true, temperature, pressure, liquidHead, massFlowRate,
                                           volumeFlowRate, volumeRateFlowLiquids, volumeRateFlowGases, moistureContent,
                                           fraction, specificEnergy, specificEntropy, specificHeat, energy, power,
                                           density, specificVolume, dynamicViscosity, kinematicViscosity, thermalConductivity,
                                           heatTransferCoefficient, volumeHeatTransferCoefficient, foulingFactor, heatFluxDensity,
                                           diffusivity, surfaceTension, velocity, mass, length, smallLength, microLength, area, volume,
                                           massVolumeConcentration, time, planeAngle);

            unitSystemList.Add(us);
            if (!us.IsReadOnly)
            {
                us.UnitSystemChanged += new UnitSystemChangedEventHandler(unitSystem_UnitSystemChanged);
            }
        }
示例#8
0
 public MassUnit(double value, MassUnitType type)
 {
     Value = value;
     _type = type;
 }
示例#9
0
 public static string GetUnitAsString(MassUnitType unitType)
 {
     return(unitStringTable[unitType] as String);
 }
示例#10
0
        public static double ConvertFromSIValue(MassUnitType unitType, double kgValue)
        {
            double convertionCoeff = (double)coeffTable[unitType];

            return(kgValue / convertionCoeff);
        }
示例#11
0
        public static double ConvertToSIValue(MassUnitType unitType, double toBeConvertedValue)
        {
            double convertionCoeff = (double)coeffTable[unitType];

            return(convertionCoeff * toBeConvertedValue);
        }
示例#12
0
        public static MassType GetXmlMassType(XElement xmlElement, string name, bool required, MassUnitType defaultUnits)
        {
            if (xmlElement.Element(name) == null)
            {
                if (required)
                    Messages.Add(new Message
                                  	{
                                  		Type = MessageType.Error,
                                  		Text = String.Format("Required MassType element '{0}' is missing.", name)
                                  	});
                return null;
            }

            string str = xmlElement.Element(name).Value;
            decimal decVal;

            string strUnit = str.ParseOffUnits();
            MassUnitType units = defaultUnits;
            try
            {
                // mg, g, kg, lb, oz
                if (!strUnit.IsNullOrEmpty())
                    units = (MassUnitType) Enum.Parse(typeof (MassUnitType), strUnit);
            }
            catch
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid MassType '{0}' value or units is missing.", name)
                              	});
                return null;
            }
            if (!strUnit.IsNullOrEmpty())
                str = str.Replace(strUnit, null).Trim();

            if (str.IsNullOrEmpty() || !Decimal.TryParse(str, out decVal))
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid MassType '{0}' value or units is missing.", name)
                              	});
                return null;
            }

            return new MassType {mass = units, Value = decVal};
        }