示例#1
0
 private void UpdateVariableValue(UnitSystem unitSystem)
 {
     if (this.var is ProcessVarDouble)
     {
         ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
         double           val       = UnitSystemService.GetInstance().ConvertFromSIValue(this.var.Type, varDouble.Value);
         if (varDouble.Value == Constants.NO_VALUE)
         {
             this.Text = "";
         }
         else
         {
             this.Text = val.ToString(this.iNumericFormat.NumericFormatString);
         }
     }
     else if (this.var is ProcessVarInt)
     {
         ProcessVarInt varInt = (ProcessVarInt)this.var;
         if (varInt.Value == Constants.NO_VALUE_INT)
         {
             this.Text = "";
         }
         else
         {
             this.Text = varInt.Value.ToString(UI.DECIMAL);
         }
     }
 }
示例#2
0
        /*public ParticleDistributions GetParticleDistributions() {
         * return new ParticleDistributions(this);
         * }
         *
         * internal ArrayList ParticleSizeFractionAndEfficiencyList {
         * get {return particleSizeFractionAndEfficiencyList;}
         * set {particleSizeFractionAndEfficiencyList = value;}
         * }*/

        #endregion

        public CycloneRatingModel(IGasSolidSeparator owner) : base(owner)
        {
            //this.cycloneOwner = (Cyclone) owner;
            numberOfCyclones = new ProcessVarInt(StringConstants.NUMBER_OF_CYCLONES, PhysicalQuantity.Unknown, 1, VarState.Specified, ownerUnitOp);

            //particleDensity = new ProcessVarDouble(StringConstants.PARTICLE_DENSITY, PhysicalQuantity.Density, VarState.Specified, ownerUnitOp);
            //particleBulkDensity = new ProcessVarDouble(StringConstants.PARTICLE_BULK_DENSITY, PhysicalQuantity.Density, VarState.Specified, ownerUnitOp);
            cutParticleDiameter = new ProcessVarDouble(StringConstants.CUT_PARTICLE_DIAMETER, PhysicalQuantity.MicroLength, VarState.Specified, ownerUnitOp);

            inletConfiguration                = CycloneInletConfiguration.Tangential;
            inletWidth                        = new ProcessVarDouble(StringConstants.INLET_WIDTH, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            inletHeight                       = new ProcessVarDouble(StringConstants.INLET_HEIGHT, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            inletHeightToWidthRatio           = new ProcessVarDouble(StringConstants.INLET_HEIGHT_TO_WIDTH_RATIO, PhysicalQuantity.Unknown, VarState.Specified, ownerUnitOp);
            inletVelocity                     = new ProcessVarDouble(StringConstants.INLET_VELOCITY, PhysicalQuantity.Velocity, VarState.Specified, ownerUnitOp);
            cycloneDiameter                   = new ProcessVarDouble(StringConstants.CYCLONE_DIAMETER, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            outletInnerDiameter               = new ProcessVarDouble(StringConstants.OUTLET_INNER_DIAMETER, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            outletWallThickness               = new ProcessVarDouble(StringConstants.OUTLET_WALL_THICKNESS, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            diplegDiameter                    = new ProcessVarDouble(StringConstants.DIPLEG_DIAMETER, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            outletTubeLengthBelowRoof         = new ProcessVarDouble(StringConstants.OUTLET_TUBE_LENGTH_BELOW_ROOF, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            outletBelowRoofToInletHeightRatio = new ProcessVarDouble(StringConstants.OUTLET_BELOW_ROOF_TO_INLET_HEIGHT_RATIO, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            naturalVortexLength               = new ProcessVarDouble(StringConstants.NATURAL_VORTEX_LENGTH, PhysicalQuantity.Length, VarState.AlwaysCalculated, ownerUnitOp);
            externalVesselDiameter            = new ProcessVarDouble(StringConstants.EXTERNAL_VESSEL_DIAMETER, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);

            coneAngle            = new ProcessVarDouble(StringConstants.CONE_ANGLE, PhysicalQuantity.PlaneAngle, VarState.Specified, ownerUnitOp);
            barrelLength         = new ProcessVarDouble(StringConstants.BARREL_LENGTH, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            coneLength           = new ProcessVarDouble(StringConstants.CONE_LENGTH, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);
            barrelPlusConeLength = new ProcessVarDouble(StringConstants.BARREL_PLUS_CONE_LENGTH, PhysicalQuantity.Length, VarState.Specified, ownerUnitOp);

            //particleSizeFractionAndEfficiencyList.Add(new ParticleSizeFractionAndEfficiency(ownerUnitOp));
            //particleSizeFractionAndEfficiencyList.Add(new ParticleSizeFractionAndEfficiency());
            particleType = ParticleTypeGroup.A;

            InitializeVarListAndRegisterVars();
        }
示例#3
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionHXRatingModelPlateAndFrame", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.channelWidth             = RecallStorableObject("ChannelWidth", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.projectedChannelLength   = RecallStorableObject("ProjectedChannelLength", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.enlargementFactor        = RecallStorableObject("EnlargementFactor", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.projectedPlateArea       = RecallStorableObject("ProjectedPlateArea", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.actualEffectivePlateArea = RecallStorableObject("ActualEffectivePlateArea", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.platePitch = RecallStorableObject("PlatePitch", typeof(ProcessVarDouble)) as ProcessVarDouble;
                //this.chevronAngle = RecallStorableObject("ChevronAngle", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.numberOfPlates = RecallStorableObject("NumberOfPlates", typeof(ProcessVarInt)) as ProcessVarInt;
                this.hotSidePasses  = RecallStorableObject("HotSidePasses", typeof(ProcessVarInt)) as ProcessVarInt;
                this.coldSidePasses = RecallStorableObject("ColdSidePasses", typeof(ProcessVarInt)) as ProcessVarInt;

                this.portDiameter              = RecallStorableObject("PortDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.horizontalPortDistance    = RecallStorableObject("HorizontalPortDistance", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.verticalPortDistance      = RecallStorableObject("VerticalPortDistance", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.compressedPlatePackLength = RecallStorableObject("CompressedPlatePackLength", typeof(ProcessVarDouble)) as ProcessVarDouble;

                this.hotSideVelocity  = RecallStorableObject("HotSideVelocity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.coldSideVelocity = RecallStorableObject("ColdSideVelocity", typeof(ProcessVarDouble)) as ProcessVarDouble;
            }
        }
示例#4
0
        public HXRatingModelPlateAndFrame(HeatExchanger heatExchanger) : base(heatExchanger)
        {
            channelWidth             = new ProcessVarDouble(StringConstants.CHANNEL_WIDTH, PhysicalQuantity.Length, 0.63, VarState.Specified, heatExchanger);
            projectedChannelLength   = new ProcessVarDouble(StringConstants.PROJECTED_CHANNEL_LENGTH, PhysicalQuantity.Length, 1.55, VarState.Specified, heatExchanger);
            enlargementFactor        = new ProcessVarDouble(StringConstants.ENLARGEMENT_FACTOR, PhysicalQuantity.Unknown, 1.25, VarState.Specified, heatExchanger);
            projectedPlateArea       = new ProcessVarDouble(StringConstants.PROJECTED_PLATE_AREA, PhysicalQuantity.Area, VarState.AlwaysCalculated, heatExchanger);
            actualEffectivePlateArea = new ProcessVarDouble(StringConstants.ACTUAL_EFFECTIVE_PLATE_AREA, PhysicalQuantity.Area, VarState.AlwaysCalculated, heatExchanger);
            platePitch = new ProcessVarDouble(StringConstants.PLATE_PITCH, PhysicalQuantity.SmallLength, 0.0036, VarState.Specified, heatExchanger);
            //chevronAngle = new ProcessVarDouble(StringConstants.CHEVRON_ANGLE, PhysicalQuantity.PlaneAngle, Math.PI/4.0, VarState.Specified, heatExchanger);
            numberOfPlates = new ProcessVarInt(StringConstants.NUMBER_OF_PLATES, PhysicalQuantity.Unknown, 105, VarState.Specified, heatExchanger);
            hotSidePasses  = new ProcessVarInt(StringConstants.HOT_SIDE_PASSES, PhysicalQuantity.Unknown, 1, VarState.Specified, heatExchanger);
            coldSidePasses = new ProcessVarInt(StringConstants.COLD_SIDE_PASSES, PhysicalQuantity.Unknown, 1, VarState.Specified, heatExchanger);

            portDiameter              = new ProcessVarDouble(StringConstants.PORT_DIAMETER, PhysicalQuantity.Length, 0.2, VarState.Specified, heatExchanger);
            horizontalPortDistance    = new ProcessVarDouble(StringConstants.HORIZONTAL_PORT_DISTANCE, PhysicalQuantity.Length, VarState.Specified, heatExchanger);
            verticalPortDistance      = new ProcessVarDouble(StringConstants.VERTICAL_PORT_DISTANCE, PhysicalQuantity.Length, VarState.Specified, heatExchanger);
            compressedPlatePackLength = new ProcessVarDouble(StringConstants.COMPRESSED_PLATE_PACK_LENGTH, PhysicalQuantity.Length, VarState.Specified, heatExchanger);

            hotSideVelocity  = new ProcessVarDouble(StringConstants.HOT_SIDE_VELOCITY, PhysicalQuantity.Unknown, VarState.AlwaysCalculated, owner);
            coldSideVelocity = new ProcessVarDouble(StringConstants.COLD_SIDE_VELOCITY, PhysicalQuantity.Unknown, VarState.AlwaysCalculated, owner);

            wallThickness.Name  = StringConstants.PLATE_WALL_THICKNESS;
            wallThickness.Value = 0.0006;

            hotSideHeatTransferCoefficient.State  = VarState.AlwaysCalculated;
            coldSideHeatTransferCoefficient.State = VarState.AlwaysCalculated;
            totalHeatTransferCoefficient.State    = VarState.AlwaysCalculated;
            totalHeatTransferArea.State           = VarState.AlwaysCalculated;

            InitializeVarListAndRegisterVars();
        }
示例#5
0
        public static string GetVariableValue(ProcessVar var, UnitSystem unitSystem, string numericFormatStr)
        {
            string valStr = null;

            if (var is ProcessVarDouble)
            {
                ProcessVarDouble varDouble = (ProcessVarDouble)var;
                double           val       = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, varDouble.Value);
                if (varDouble.Value == Constants.NO_VALUE)
                {
                    valStr = "";
                }
                else
                {
                    valStr = val.ToString(numericFormatStr);
                }
            }
            else if (var is ProcessVarInt)
            {
                ProcessVarInt varInt = (ProcessVarInt)var;
                if (varInt.Value == Constants.NO_VALUE_INT)
                {
                    valStr = "";
                }
                else
                {
                    valStr = varInt.Value.ToString(UI.DECIMAL);
                }
            }
            return(valStr);
        }
示例#6
0
        public ErrorMessage Specify(ProcessVarInt pv, int aValue)
        {
            if (pv.Value != aValue)
            {
                pv.Value = aValue;
                pv.State = VarState.Specified;
                OnProcessVarValueCommitted(pv);
            }

            return(null);
        }
示例#7
0
 private void EraseOldValue(ProcessVar var)
 {
     if (var is ProcessVarDouble)
     {
         ProcessVarDouble pvd = var as ProcessVarDouble;
         pvd.Value = Constants.NO_VALUE;
     }
     else if (var is ProcessVarInt)
     {
         ProcessVarInt pvi = var as ProcessVarInt;
         pvi.Value = Constants.NO_VALUE_INT;
     }
 }
示例#8
0
        internal override void PrepareGeometry()
        {
            CalculateTubeDiameters();
            CalculateBaffleSpacing();

            if (owner.BeingSpecifiedProcessVar is ProcessVarDouble)
            {
                ProcessVarDouble pv = owner.BeingSpecifiedProcessVar as ProcessVarDouble;
                if (pv == ratingModel.TubeInnerDiameter)
                {
                    if (ratingModel.TubeWallThickness.HasValue && ratingModel.TubeWallThickness.IsSpecified && pv.Value != Constants.NO_VALUE)
                    {
                        TubeOuterDiameterChanged();
                    }
                }
                else if (pv == ratingModel.TubeOuterDiameter)
                {
                    TubeOuterDiameterChanged();
                }
                else if (pv == ratingModel.TubeWallThickness)
                {
                    if (ratingModel.TubeInnerDiameter.HasValue && ratingModel.TubeInnerDiameter.IsSpecified && pv.Value != Constants.NO_VALUE)
                    {
                        TubeOuterDiameterChanged();
                    }
                }
                else if (pv == ratingModel.TubePitch)
                {
                    CalculateCrossFlowArea();
                }
                else if (pv == ratingModel.ShellInnerDiameter)
                {
                    CalculateBaffleWindowArea();
                    CalculateCrossFlowArea();
                }
                else if (pv == ratingModel.BaffleCut)
                {
                    CalculateBaffleWindowArea();
                }
            }
            else if (owner.BeingSpecifiedProcessVar is ProcessVarInt)
            {
                ProcessVarInt pv = owner.BeingSpecifiedProcessVar as ProcessVarInt;
                if (pv == ratingModel.TubesPerTubePass)
                {
                    CalculateBaffleWindowArea();
                }
            }

            CalculateHeatTransferArea();
        }
示例#9
0
        internal override ErrorMessage CheckSpecifiedValueRange(ProcessVarInt pv, int aValue)
        {
            ErrorMessage retValue = null;

            if (pv == numberOfPlates)
            {
                if (aValue < 10 || aValue > 700)
                {
                    retValue = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Number of plates must be in the range of 10 to 700");
                }
            }

            return(retValue);
        }
示例#10
0
        internal override ErrorMessage CheckSpecifiedValueRange(ProcessVarInt pv, int aValue)
        {
            ErrorMessage retValue = null;

            if (pv == numberOfPlates)
            {
                if (aValue < 10 || aValue > 700)
                {
                    retValue = owner.CreateSimpleGenericInappropriateSpecifiedValueErrorMessage("Number of plates must be in the range of 10 to 700");
                }
            }

            return(retValue);
        }
示例#11
0
        /// <summary>
        /// need to send event to grid to update the UI
        /// </summary>
        /// <param name="unitSystem"></param>
        private void UpdateVariableValue(UnitSystem unitSystem)
        {
            if (this.var is ProcessVarDouble)
            {
                ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                double           val       = UnitSystemService.GetInstance().ConvertFromSIValue(this.var.Type, varDouble.Value);
                if (varDouble.Value == Constants.NO_VALUE)
                {
                    this.value = "";
                }
                else
                {
                    this.value = val.ToString(this.iNumericFormat.NumericFormatString);
                }

                if (this.var.IsSpecified)
                {
                    //this.ReadOnly = false;
                    //this.BackColor = Color.White;
                }
                else
                {
                    //this.ReadOnly = true;
                    //this.BackColor = Color.Gainsboro;
                }
            }
            else if (this.var is ProcessVarInt)
            {
                ProcessVarInt varInt = (ProcessVarInt)this.var;
                if (varInt.Value == Constants.NO_VALUE_INT)
                {
                    this.value = "";
                }
                else
                {
                    this.value = varInt.Value.ToString(UI.DECIMAL);
                }

                if (this.var.IsSpecified)
                {
                    // this.ReadOnly = false;
                    // this.BackColor = Color.White;
                }
                else
                {
                    // this.ReadOnly = true;
                    // this.BackColor = Color.Gainsboro;
                }
            }
        }
示例#12
0
        private object GetNewValue()
        {
            object newVal = null;

            if (this.textBoxNewValue.Text.Trim().Equals(""))
            {
                if (this.var is ProcessVarDouble)
                {
                    newVal = Constants.NO_VALUE;
                }
                else if (this.var is ProcessVarInt)
                {
                    newVal = Constants.NO_VALUE_INT;
                }
            }
            else
            {
                if (this.var is ProcessVarDouble)
                {
                    try
                    {
                        ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                        double           val       = Double.Parse(this.textBoxNewValue.Text);
                        double           val2      = UnitSystemService.GetInstance().ConvertToSIValue(this.var.Type, val);
                        newVal = val2;
                    }
                    catch (FormatException)
                    {
                        newVal = Constants.NO_VALUE;
                    }
                }
                else if (this.var is ProcessVarInt)
                {
                    try
                    {
                        ProcessVarInt varInt = (ProcessVarInt)this.var;
                        int           val    = Int32.Parse(this.textBoxNewValue.Text);
                        newVal = val;
                    }
                    catch (FormatException)
                    {
                        newVal = Constants.NO_VALUE_INT;
                    }
                }
            }
            return(newVal);
        }
示例#13
0
        public ErrorMessage Specify(ProcessVarInt pv, int aValue)
        {
            ErrorMessage retMsg = null;

            if (pv.Value == aValue)
            {
                return(retMsg);
            }
            else
            {
                retMsg = CheckSpecifiedValueRange(pv, aValue);
                if (retMsg != null)
                {
                    return(retMsg);
                }
            }

            //remember currently being specified variable value
            int oldValue = pv.Value;

            beingSpecifiedProcVar = pv;

            pv.Value = aValue;
            pv.State = VarState.Specified;

            try {
                unitOpSystem.OnCalculationStarted(); //must tell UI calculation has started already
                HasBeenModified(true);
                unitOpSystem.OnCalculationEnded();   //must tell UI calculation has ended already
            }
            catch (Exception e)
            {
                pv.Value = oldValue;
                retMsg   = HandleException(e);
                //HasBeenModified(true);
            }

            OnProcessVarValueCommitted(pv);

            return(retMsg);
        }
示例#14
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionCyclone", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.owner            = info.GetValue("Owner", typeof(Cyclone)) as Cyclone;
                this.procVarList      = info.GetValue("ProcVarList", typeof(ArrayList)) as ArrayList;
                this.numberOfCyclones = RecallStorableObject("NumberOfCyclones", typeof(ProcessVarInt)) as ProcessVarInt;

                this.particleType = (ParticleTypeGroup)info.GetValue("ParticleType", typeof(ParticleTypeGroup));

                //this.particleDensity = RecallStorableObject("ParticleDensity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                //this.particleBulkDensity = RecallStorableObject("ParticleBulkDensity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.cutParticleDiameter = RecallStorableObject("CutParticleDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;

                this.inletConfiguration      = (CycloneInletConfiguration)info.GetValue("InletConfiguration", typeof(CycloneInletConfiguration));
                this.inletWidth              = RecallStorableObject("InletWidth", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.inletHeight             = RecallStorableObject("InletHeight", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.inletHeightToWidthRatio = RecallStorableObject("InletHeightToWidthRatio", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.inletVelocity           = RecallStorableObject("InletVelocity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.cycloneDiameter         = RecallStorableObject("CycloneDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.outletInnerDiameter     = RecallStorableObject("OutletInnerDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.outletWallThickness     = RecallStorableObject("OutletWallThickness", typeof(ProcessVarDouble)) as ProcessVarDouble;

                this.outletTubeLengthBelowRoof         = RecallStorableObject("OutletTubeLengthBelowRoof", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.outletBelowRoofToInletHeightRatio = RecallStorableObject("OutletBelowRoofToInletHeightRatio", typeof(ProcessVarDouble)) as ProcessVarDouble;

                this.naturalVortexLength    = RecallStorableObject("NaturalVortexLength", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.diplegDiameter         = RecallStorableObject("DiplegDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.externalVesselDiameter = RecallStorableObject("ExternalVesselDiameter", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.coneAngle            = RecallStorableObject("ConeAngle", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.barrelLength         = RecallStorableObject("BarrelLength", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.coneLength           = RecallStorableObject("ConeLength", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.barrelPlusConeLength = RecallStorableObject("BarrelPlusConeLength", typeof(ProcessVarDouble)) as ProcessVarDouble;

                //this.particleSizeFractionAndEfficiencyList = RecallArrayListObject("ParticleSizeFractionAndEfficiencyList");
            }
        }
示例#15
0
 protected virtual ErrorMessage CheckSpecifiedValueRange(ProcessVarInt pv, int aValue)
 {
     return(null);
 }
示例#16
0
        /// <summary>
        ///  check the input value before start computing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ProcessVarObj_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ErrorMessage error      = null;
            string       inputValue = sender.ToString();

            if (inputValue.Trim().Equals(""))
            {
                if (this.var.IsSpecified)
                {
                    if (this.var is ProcessVarDouble)
                    {
                        ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                        error = this.var.Owner.Specify(varDouble, Constants.NO_VALUE);
                    }
                    else if (this.var is ProcessVarInt)
                    {
                        ProcessVarInt varInt = (ProcessVarInt)this.var;
                        error = this.var.Owner.Specify(varInt, Constants.NO_VALUE_INT);
                    }
                    if (error != null)
                    {
                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        UI.ShowError(error);
                    }
                }
            }
            else
            {
                try
                {
                    if (this.var is ProcessVarDouble)
                    {
                        ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                        double           val       = Double.Parse(inputValue);
                        double           val2      = 0.0;
                        try
                        {
                            if (this.var.IsSpecified)
                            {
                                val2  = UnitSystemService.GetInstance().ConvertToSIValue(this.var.Type, val);
                                error = this.var.Owner.Specify(varDouble, val2);
                                if (error != null)
                                {
                                    if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsInappropriate)
                                    {
                                        ProcVarsInappropriateForm form = new ProcVarsInappropriateForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count == 1)
                                    {
                                        ProcVarsOnlyOneOutOfRangeForm form = new ProcVarsOnlyOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count > 1)
                                    {
                                        ProcVarsMoreThenOneOutOfRangeForm form = new ProcVarsMoreThenOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueOutOfRange)
                                    {
                                        ProcVarOutOfRangeForm form = new ProcVarOutOfRangeForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else
                                    {
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                        UI.ShowError(error);
                                    }
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            e.Cancel = true;
                            string message1 = ex1.ToString();
                            MessageBox.Show(message1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        }
                    }
                    else if (this.var is ProcessVarInt)
                    {
                        ProcessVarInt varInt = (ProcessVarInt)this.var;
                        int           val    = Int32.Parse(value);
                        try
                        {
                            if (this.var.IsSpecified)
                            {
                                error = this.var.Owner.Specify(varInt, val);
                                if (error != null)
                                {
                                    if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsInappropriate)
                                    {
                                        ProcVarsInappropriateForm form = new ProcVarsInappropriateForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count == 1)
                                    {
                                        ProcVarsOnlyOneOutOfRangeForm form = new ProcVarsOnlyOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count > 1)
                                    {
                                        ProcVarsMoreThenOneOutOfRangeForm form = new ProcVarsMoreThenOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueOutOfRange)
                                    {
                                        ProcVarOutOfRangeForm form = new ProcVarOutOfRangeForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else
                                    {
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                        UI.ShowError(error);
                                    }
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            e.Cancel = true;
                            string message1 = ex1.ToString();
                            MessageBox.Show(message1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        }
                    }
                }
                catch (FormatException)
                {
                    e.Cancel = true;
                    string message2 = "Please enter a numeric value!";
                    MessageBox.Show(message2, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                }
            }
        }
示例#17
0
        internal override void PrepareGeometry()
        {
            CalculateTubeDiameters();
            CalculateBaffleSpacing();
            CalculateTubeBundleDiameter();

            if (owner.BeingSpecifiedProcessVar is ProcessVarDouble)
            {
                ProcessVarDouble pv = owner.BeingSpecifiedProcessVar as ProcessVarDouble;
                if (pv == ratingModel.TubeInnerDiameter)
                {
                    if (ratingModel.TubeWallThickness.Value != Constants.NO_VALUE && ratingModel.TubeWallThickness.IsSpecified && pv.Value != Constants.NO_VALUE)
                    {
                        TubeOuterDiameterChanged();
                    }
                }
                else if (pv == ratingModel.TubeOuterDiameter)
                {
                    TubeOuterDiameterChanged();
                }
                else if (pv == ratingModel.TubeWallThickness)
                {
                    if (ratingModel.TubeInnerDiameter.Value != Constants.NO_VALUE && ratingModel.TubeInnerDiameter.IsSpecified && pv.Value != Constants.NO_VALUE)
                    {
                        TubeOuterDiameterChanged();
                    }
                }

                else if (pv == ratingModel.TubePitch)
                {
                    CalculateTubePitchesAndRelated();
                    //above method includes the flowing calls
                    //CalculateTubeRowsInOneCrossFlowSetion();
                    //CalculateCrossFlowRowsInEachWindow();
                    //CalculateCrossFlowArea();
                }
                else if (pv == ratingModel.ShellInnerDiameter)
                {
                    CalculateTubeRowsInOneCrossFlowSetion();
                    //the following methods includs
                    //CalculateTubeToBaffleLeakageArea(); and
                    //CalculateAreaForFlowThroughWindowAndEquivalentDiameterOfWindow();
                    CalculateFractionOfTotalTubesInCrossFlow();
                    CalculateCrossFlowArea();
                    CalculateShellToBaffleLeakageArea();
                }
                else if (pv == ratingModel.BundleToShellDiametralClearance)
                {
                    CalculateFractionOfTotalTubesInCrossFlow();
                    CalculateCrossFlowArea();
                }
                else if (pv == ratingModel.BaffleCut)
                {
                    CalculateTubeRowsInOneCrossFlowSetion();
                    CalculateFractionOfTotalTubesInCrossFlow();
                    CalculateCrossFlowRowsInEachWindow();
                    CalculateShellToBaffleLeakageArea();
                }
                else if (pv == ratingModel.ShellToBaffleDiametralClearance)
                {
                    CalculateShellToBaffleLeakageArea();
                }
            }
            else if (owner.BeingSpecifiedProcessVar is ProcessVarInt)
            {
                ProcessVarInt pv = owner.BeingSpecifiedProcessVar as ProcessVarInt;
                if (pv == ratingModel.TubesPerTubePass || pv == ratingModel.TubePassesPerShellPass)
                {
                    CalculateTubeToBaffleLeakageArea();
                    CalculateAreaForFlowThroughWindowAndEquivalentDiameterOfWindow();
                }
            }

            CalculateHeatTransferArea();
        }