Beispiel #1
0
        public ErrorMessage FinishSpecifications(string materialName, bool isNew)
        {
            ErrorMessage errorMsg = null;

            if (materialComponentList.Count < 1)
            {
                string msg = "The specified drying material contains no substance.";
                errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, "Inappropriate Specification", msg);
            }
            DoNormalization();
            CompositeSubstance dryMat = new CompositeSubstance(materialName, materialComponentList);

            //ArrayList dryMaterialCompList = new ArrayList();
            //dryMaterialCompList.Add(s);
            //dryMaterialCompList.Add(moistureSubstance);

            if (isNew)
            {
                dryingMaterial = new DryingMaterial(materialName, materialType, dryMat, moistureSubstance, true);
                dryingMaterial.DuhringLines = duhringLines;
                catalog.AddDryingMaterial(dryingMaterial);
            }
            else
            {
                dryingMaterial.Name                = materialName;
                dryingMaterial.MaterialType        = materialType;
                dryingMaterial.AbsoluteDryMaterial = dryMat;
                dryingMaterial.Moisture            = moistureSubstance;
                dryingMaterial.DuhringLines        = duhringLines;
                catalog.UpdateDryingMaterial(dryingMaterial);
            }

            return(errorMsg);
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            bool isEqual          = false;
            CompositeSubstance cs = obj as CompositeSubstance;

            if (name.Equals(cs.Name) && this.components.Count == cs.Components.Count)
            {
                MaterialComponent mc1;
                MaterialComponent mc2;
                for (int i = 0; i < this.components.Count; i++)
                {
                    mc1 = (MaterialComponent)(this.components[i]);
                    mc2 = (MaterialComponent)(cs.components[i]);
                    if (mc1.Substance == mc2.Substance && Math.Abs(mc1.GetMassFractionValue() - mc2.GetMassFractionValue()) < 1.0e-6)
                    {
                        isEqual = true;
                    }
                    else
                    {
                        isEqual = false;
                        break;
                    }
                }
            }
            return(isEqual);
        }
Beispiel #3
0
        public override ErrorMessage FinishSpecifications(string gasName, bool isNew)
        {
            DoNormalization();
            Substance s = new CompositeSubstance(gasName, materialComponentList);

            DryingGas dg = new DryingGas(gasName, s, true);

            catalog.AddDryingGas(dg);
            return(null);
        }
Beispiel #4
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("ClassPersistenceVersionMaterialComponent", CLASS_PERSISTENCE_VERSION, typeof(int));

            //has to store substance in a special way since it may be a compisite substance
            CompositeSubstance.StoreSubstance(info, substance);

            info.AddValue("MassFraction", massFraction, typeof(ProcessVarDouble));
            info.AddValue("MoleFraction", moleFraction, typeof(ProcessVarDouble));
        }
Beispiel #5
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionMaterialComponent", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.substance = CompositeSubstance.RecallSubstance(info);

                this.massFraction = RecallStorableObject("MassFraction", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.moleFraction = RecallStorableObject("MoleFraction", typeof(ProcessVarDouble)) as ProcessVarDouble;
            }
        }
Beispiel #6
0
        public CompositeSubstance Clone()
        {
            CompositeSubstance newCS         = (CompositeSubstance)this.MemberwiseClone();
            ArrayList          newComponents = new ArrayList();
            MaterialComponent  newPC;

            foreach (MaterialComponent mc in this.components)
            {
                newPC = mc.Clone();
                newComponents.Add(newPC);
            }
            newCS.components = newComponents;
            return(newCS);
        }
Beispiel #7
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("ClassPersistenceVersionDryingMaterial", CLASS_PERSISTENCE_VERSION, typeof(int));
            info.AddValue("Name", this.name, typeof(string));
            info.AddValue("IsUserDefined", this.isUserDefined, typeof(bool));

            //has to store absoluteDryMaterial substance in a special way since it may be a compisite substance
            CompositeSubstance.StoreSubstance(info, absoluteDryMaterial);

            info.AddValue("MoistureName", moisture.Name, typeof(string));
            info.AddValue("MaterialType", materialType, typeof(MaterialType));
            info.AddValue("SolutionType", solutionType, typeof(SolutionType));
            info.AddValue("DuhringLines", duhringLines, typeof(CurveF[]));
        }
Beispiel #8
0
        private void InitializeCatalog()
        {
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            Substance        absoluteDryMaterial = sc.GetSubstance("Dry Material");
            Substance        moisture            = sc.GetSubstance("Water");
            ArrayList        dryMatComponents    = new ArrayList();

            dryMatComponents.Add(new MaterialComponent(absoluteDryMaterial));
            CompositeSubstance dryMat = new CompositeSubstance("Generic Dry Material", dryMatComponents);
            DryingMaterial     dm     = new DryingMaterial("Generic Material", MaterialType.GenericMaterial, dryMat, moisture, false);
            //materialList.Add(dm);
            DryingMaterial milk = (DryingMaterial)dm.Clone();

            milk.Name         = "Milk";
            milk.MaterialType = MaterialType.SpecialFood;
            //materialList.Add(milk);
        }
Beispiel #9
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionDryingMaterial", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.name          = (string)info.GetValue("Name", typeof(string));
                this.isUserDefined = (bool)info.GetValue("IsUserDefined", typeof(bool));

                this.absoluteDryMaterial = CompositeSubstance.RecallSubstance(info);

                this.moisture     = Substance.RecallSubstance(info, "MoistureName");
                this.materialType = (MaterialType)info.GetValue("MaterialType", typeof(MaterialType));
                this.solutionType = (SolutionType)info.GetValue("SolutionType", typeof(SolutionType));
                this.duhringLines = (CurveF[])RecallArrayObject("DuhringLines", typeof(CurveF[]));
            }
        }
Beispiel #10
0
        //public DryingMaterialCatalog(IList list) {
        //   materialList = list;
        //}

        private void InitializeCatalog()
        {
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            //Substance absoluteDryMaterial = sc.GetSubstance("Dry Material");
            Substance absoluteDryMaterial = sc.GetGenericSubstance();
            Substance moisture            = sc.GetSubstance(Substance.WATER);
            ArrayList dryMatComponents    = new ArrayList();

            dryMatComponents.Add(new MaterialComponent(absoluteDryMaterial));
            CompositeSubstance dryMat = new CompositeSubstance("Generic Dry Material", dryMatComponents);

            if (!IsInCatalog(DryingMaterial.GENERIC_DRYING_MATERIAL))
            {
                DryingMaterial dm = new DryingMaterial(DryingMaterial.GENERIC_DRYING_MATERIAL, MaterialType.GenericMaterial, dryMat, moisture, false);
                materialList.Add(dm);
            }

            //DryingMaterial milk = (DryingMaterial)dm.Clone();
            //milk.Name = "Milk";
            //milk.MaterialType = MaterialType.SpecialFood;
            //materialList.Add(milk);
        }
Beispiel #11
0
        public override bool Equals(object obj)
        {
            bool isEqual = false;
            MaterialComponent  mc1;
            MaterialComponent  mc2;
            CompositeSubstance cs = obj as CompositeSubstance;

            //This is to account for the Generic Dry Material with a generic substance
            if (this.components.Count == cs.Components.Count && this.components.Count == 1)
            {
                mc1 = (MaterialComponent)(this.components[0]);
                mc2 = (MaterialComponent)(cs.Components[0]);
                if (mc1.Substance == mc2.Substance)
                {
                    isEqual = true;
                }
            }
            else if (name.Equals(cs.Name) && this.components.Count == cs.Components.Count)
            {
                for (int i = 0; i < this.components.Count; i++)
                {
                    mc1 = (MaterialComponent)(this.components[i]);
                    mc2 = (MaterialComponent)(cs.components[i]);
                    if (mc1.Substance == mc2.Substance && Math.Abs(mc1.GetMassFractionValue() - mc2.GetMassFractionValue()) < 1.0e-6)
                    {
                        isEqual = true;
                    }
                    else
                    {
                        isEqual = false;
                        break;
                    }
                }
            }
            return(isEqual);
        }
Beispiel #12
0
        public ErrorMessage FinishSpecifications(string materialName, bool isNew)
        {
            ErrorMessage errorMsg = null;

            if (materialComponentList.Count < 1)
            {
                string msg = "The specified drying material contains no substance.";
                errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, "Inappropriate Specification", msg);
            }
            DoNormalization();
            CompositeSubstance dryMat = new CompositeSubstance(materialName, materialComponentList);

            //ArrayList dryMaterialCompList = new ArrayList();
            //dryMaterialCompList.Add(s);
            //dryMaterialCompList.Add(moistureSubstance);

            if (isNew)
            {
                if (catalog.IsInCatalog(materialName))
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "There is already in the material catalog a material called " + materialName);
                }
                else if (materialType == MaterialType.GenericMaterial && specificHeatOfAbsoluteDryMaterial.Value <= 0.0)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Specific heat of absolute dry material cannot be less than or equal to 0");
                }
                else
                {
                    dryingMaterial = new DryingMaterial(materialName, materialType, dryMat, moistureSubstance, true);
                    dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = specificHeatOfAbsoluteDryMaterial.Value;
                    dryingMaterial.DuhringLines = duhringLines;
                    errorMsg = catalog.AddDryingMaterial(dryingMaterial);
                }
            }
            else
            {
                if (!materialName.Equals(dryingMaterial.Name) && catalog.GetDryingMaterial(materialName) != null)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "There is already in the material catalog a material called " + materialName);
                }
                else if (materialType == MaterialType.GenericMaterial && specificHeatOfAbsoluteDryMaterial.Value <= 0.0)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Specific heat of absolute dry material cannot be less than or equal to 0");
                }
                else
                {
                    //dryingMaterial.Name = materialName;
                    //dryingMaterial.MaterialType = materialType;
                    //dryingMaterial.AbsoluteDryMaterial = dryMat;
                    //dryingMaterial.Moisture = moistureSubstance;
                    //dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = specificHeatOfAbsoluteDryMaterial.Value;
                    //dryingMaterial.DuhringLines = duhringLines;
                    double   originalSpecificHeatOfAbsoluteDryMaterial = dryingMaterial.SpecificHeatOfAbsoluteDryMaterial;
                    CurveF[] originalDuhringLines = dryingMaterial.DuhringLines;
                    if (originalDuhringLines != null)
                    {
                        originalDuhringLines.Clone();
                    }

                    try {
                        dryingMaterial.Update(materialName, specificHeatOfAbsoluteDryMaterial.Value, duhringLines);
                        errorMsg = catalog.UpdateDryingMaterial(dryingMaterial);
                    }
                    catch (Exception) {
                        dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = originalSpecificHeatOfAbsoluteDryMaterial;
                        dryingMaterial.DuhringLines = originalDuhringLines;
                        errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Either specified absolute material specific heat or duhring lines are not appropriate.");
                    }
                }
            }

            return(errorMsg);
        }