コード例 #1
0
ファイル: LengthUnit.cs プロジェクト: gsemac/OurFoodChain.Bot
 public LengthUnit(string name, string abbreviation, double meterConversionFactor, LengthUnitType type)
 {
     this.Name                  = name;
     this.Abbreviation          = abbreviation;
     this.MeterConversionFactor = meterConversionFactor;
     this.Type                  = type;
 }
コード例 #2
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);
            }
        }
コード例 #3
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;
 }
コード例 #4
0
        public LengthMeasurement ToNearestUnits(LengthUnitType type, params string[] allowedUnits)
        {
            if (Units.Type == type)
            {
                return(new LengthMeasurement(Value, Units));
            }

            // Find the unit with the closest conversion factor to ours.

            ILengthUnit unit = Units.ToNearestUnits(type, allowedUnits);

            return(To(unit));
        }
コード例 #5
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));
            }
        }
コード例 #6
0
        public static LengthUnitType GetUnitAsEnum(string unitString)
        {
            IDictionaryEnumerator myEnumerator = unitStringTable.GetEnumerator();
            String         name;
            LengthUnitType type = LengthUnitType.Meter;

            while (myEnumerator.MoveNext())
            {
                name = myEnumerator.Value as String;
                if (name.Equals(unitString))
                {
                    type = (LengthUnitType)myEnumerator.Key;
                    break;
                }
            }
            return(type);
        }
コード例 #7
0
ファイル: LengthUnit.cs プロジェクト: gsemac/OurFoodChain.Bot
        public ILengthUnit ToNearestUnits(LengthUnitType type, params string[] allowedUnits)
        {
            if (Type == type)
            {
                return(new LengthUnit(this));
            }

            // Find the unit with the closest conversion factor to ours.

            ILengthUnit result = knownUnits.Value.Values
                                 .Where(unit => unit.Type == type)
                                 .Where(unit => allowedUnits.Count() <= 0 || allowedUnits.Any(allowedUnit => unit.Equals(allowedUnit)))
                                 .OrderBy(unitu => Math.Abs(MeterConversionFactor - unitu.MeterConversionFactor))
                                 .FirstOrDefault();

            return(result);
        }
コード例 #8
0
        private double getMultiplier(LengthUnitType type)
        {
            switch (type)
            {
            case LengthUnitType.Nanometre:
                return(1);

            case LengthUnitType.Micrometre:
                return(1000);

            case LengthUnitType.Milimetre:
                return(1000000);

            case LengthUnitType.Santimetre:
                return(10000000);

            case LengthUnitType.Desimetre:
                return(100000000);

            case LengthUnitType.Metre:
                return(1000000000);

            case LengthUnitType.Kilometre:
                return(1000000000000);

            case LengthUnitType.Inc:
                return(25400000);

            case LengthUnitType.Fut:
                return(304800000);

            case LengthUnitType.Yarda:
                return(914400000);

            case LengthUnitType.Mil:
                return(1609344000000);

            case LengthUnitType.DenizMili:
                return(1852000000000);

            default:
                throw new ArgumentException("Hatalı ölçü birimi seçildi.");
            }
        }
コード例 #9
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);
        }
コード例 #10
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;
 }
コード例 #11
0
        /// <summary>
        /// Converts internal imperial units to metric length units.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="type">The type of unit to convert to.</param>
        /// <param name="decimals">The decimal spaces precision.</param>
        /// <returns></returns>
        public double ConvertToMetric(double value, LengthUnitType type, int decimals)
        {
            switch (type)
            {
            case LengthUnitType.milimeter:
                return(Math.Round(value * 304.8, decimals));

            case LengthUnitType.centimeter:
                return(Math.Round(value * 30.48, decimals));

            case LengthUnitType.decimeter:
                return(Math.Round(value * 3.048, decimals));

            case LengthUnitType.meter:
                return(Math.Round(value * 0.3048, decimals));

            case LengthUnitType.kilometer:
                return(Math.Round(value * 0.0003048, decimals));

            default:
                return(value);
            }
        }
コード例 #12
0
 private Dimension(LengthUnitType unitType, float length)
 {
     this.UnitType = unitType;
     this.Length   = length;
 }
コード例 #13
0
 public ElevationSettingsType() {
     this.zOffsetTypeField = ElevationTypeType.RelativeToGround;
     this.unitField = LengthUnitType.Centimeters;
 }
コード例 #14
0
 public static string GetUnitAsString(LengthUnitType unitType)
 {
     return(unitStringTable[unitType] as String);
 }
コード例 #15
0
        public static double ConvertFromSIValue(LengthUnitType unitType, double meterValue)
        {
            double convertionCoeff = (double)coeffTable[unitType];

            return(meterValue / convertionCoeff);
        }
コード例 #16
0
        public static double ConvertToSIValue(LengthUnitType unitType, double toBeConvertedValue)
        {
            double convertionCoeff = (double)coeffTable[unitType];

            return(convertionCoeff * toBeConvertedValue);
        }
コード例 #17
0
 /// <summary>
 /// Handles the SelectedIndexChanged event of the cmbUnitType control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void cmbUnitType_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     unitType = (LengthUnitType)cmbUnitType.SelectedValue;
 }
コード例 #18
0
 public LengthUnit(double value, LengthUnitType type)
 {
     Value = value;
     _type = type;
 }
コード例 #19
0
ファイル: TagWallLayersForm.cs プロジェクト: JieGou/cbb
 /// <summary>
 /// Handles the SelectedIndexChanged event of the cmbUnitType control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void cmbUnitType_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     //unitType = (LengthUnitType)cmbUnitType.SelectedValue;
     unitType = ((KeyValuePair <string, LengthUnitType>)cmbUnitType.SelectedItem).Value;
     //
 }