コード例 #1
0
 public void RegisterReactionProcessor(ReactionProcessor rp)
 {
     if (m_reactionProcessor == null)
     {
         m_reactionProcessor = rp;
     }
     else
     {
         throw new ApplicationException("Attempt to register a new reaction processor into a BasicReactionSupporter that already has one. This is prohibited.");
     }
 }
コード例 #2
0
            private void Initialize(BasicReactionSupporter brs)
            {
                MaterialCatalog   mcat = brs.MyMaterialCatalog;
                ReactionProcessor rp   = brs.MyReactionProcessor;

                //                        Model  Name    Guid           SpecGrav SpecHeat
                mcat.Add(new MaterialType(null, "Water", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Hydrochloric Acid", Guid.NewGuid(), 1.1890, 2.5500, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Caustic Soda", Guid.NewGuid(), 2.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sodium Chloride", Guid.NewGuid(), 2.1650, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sulfuric Acid 98%", Guid.NewGuid(), 1.8420, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Hydroxide", Guid.NewGuid(), 1.3000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Sulfate", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Nitrous Acid", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sodium Nitrite", Guid.NewGuid(), 2.3800, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Nitrite", Guid.NewGuid(), 1.9150, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Aluminum Hydroxide", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Ammonia", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Ammonium Hydroxide", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Bromine", Guid.NewGuid(), 3.1200, 4.1800, MaterialState.Liquid));

                Reaction r1 = new Reaction(null, "Reaction 1", Guid.NewGuid());

                r1.AddReactant(mcat["Caustic Soda"], 0.5231);
                r1.AddReactant(mcat["Hydrochloric Acid"], 0.4769);
                r1.AddProduct(mcat["Water"], 0.2356);
                r1.AddProduct(mcat["Sodium Chloride"], 0.7644);
                rp.AddReaction(r1);

                Reaction r2 = new Reaction(null, "Reaction 2", Guid.NewGuid());

                r2.AddReactant(mcat["Sulfuric Acid 98%"], 0.533622);
                r2.AddReactant(mcat["Potassium Hydroxide"], 0.466378);
                r2.AddProduct(mcat["Water"], 0.171333);
                r2.AddProduct(mcat["Potassium Sulfate"], 0.828667);
                rp.AddReaction(r2);

                Reaction r3 = new Reaction(null, "Reaction 3", Guid.NewGuid());

                r3.AddReactant(mcat["Caustic Soda"], 0.459681368);
                r3.AddReactant(mcat["Nitrous Acid"], 0.540318632);
                r3.AddProduct(mcat["Water"], 0.207047552);
                r3.AddProduct(mcat["Sodium Nitrite"], 0.792952448);
                rp.AddReaction(r3);

                Reaction r4 = new Reaction(null, "Reaction 4", Guid.NewGuid());

                r4.AddReactant(mcat["Potassium Hydroxide"], 0.544102);
                r4.AddReactant(mcat["Nitrous Acid"], 0.455898);
                r4.AddProduct(mcat["Water"], 0.174698);
                r4.AddProduct(mcat["Potassium Nitrite"], 0.825302);
                rp.AddReaction(r4);
            }
コード例 #3
0
 /// <summary>
 /// Deserializes this object from the specified XmlSerializatonContext.
 /// </summary>
 /// <param name="xmlsc">The XmlSerializatonContext from which this object is to be reconstituted.</param>
 public void DeserializeFrom(XmlSerializationContext xmlsc)
 {
     m_materialCatalog   = (MaterialCatalog)xmlsc.LoadObject("MaterialCatalog");
     m_reactionProcessor = (ReactionProcessor)xmlsc.LoadObject("ReactionProcessor");
 }