Exemplo n.º 1
0
        /// <summary>
        /// Загрузить список расходомеров
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public static RgrList Load(XmlNode root)
        {
            try
            {
                if (root != null && root.Name == "RgrList")
                {
                    if (root.HasChildNodes)
                    {
                        RgrList lst = new RgrList();
                        foreach (XmlNode child in root.ChildNodes)
                        {
                            if (child.Name == "rgr")
                            {
                                Rgr rgr = Rgr.Load(child);
                                if (rgr != null)
                                {
                                    lst.Add(rgr);
                                }
                            }
                        }

                        return(lst);
                    }
                }
            }
            catch { }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Загрузить настройки технологии
        /// </summary>
        public void Load(XmlNode root)
        {
            try
            {
                if (root != null && root.Name == TechRoot)
                {
                    if (root.HasChildNodes)
                    {
                        if (root.ChildNodes.Count == 6)
                        {
                            tech_consumption.DeserializeFromXml(root.ChildNodes.Item(0));
                            tech_volume.DeserializeFromXml(root.ChildNodes.Item(1));
                            tech_density.DeserializeFromXml(root.ChildNodes.Item(2));
                            tech_pressure.DeserializeFromXml(root.ChildNodes.Item(3));
                            tech_temperature.DeserializeFromXml(root.ChildNodes.Item(4));
                            tech_proccessVolume.DeserializeFromXml(root.ChildNodes.Item(5));
                        }
                        else
                        {
                            if (root.ChildNodes.Count == 7)
                            {
                                tech_consumption.DeserializeFromXml(root.ChildNodes.Item(0));
                                tech_volume.DeserializeFromXml(root.ChildNodes.Item(1));
                                tech_density.DeserializeFromXml(root.ChildNodes.Item(2));
                                tech_pressure.DeserializeFromXml(root.ChildNodes.Item(3));
                                tech_temperature.DeserializeFromXml(root.ChildNodes.Item(4));
                                tech_proccessVolume.DeserializeFromXml(root.ChildNodes.Item(5));

                                rgrs = RgrList.Load(root.ChildNodes.Item(6));
                                if (rgrs.Count < 8)
                                {
                                    int n_count = 8 - rgrs.Count;
                                    for (int i = 0; i < n_count; i++)
                                    {
                                        rgrs.Add(new Rgr());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        public Tech()
        {
            stages = new TechStages(this);

            tech_volume        = new TechParameter();
            tech_volume.Format = "{0:F2}";

            tech_consumption        = new TechParameter();
            tech_consumption.Format = "{0:F1}";

            tech_density        = new TechParameter();
            tech_density.Format = "{0:F3}";

            tech_pressure        = new TechParameter();
            tech_pressure.Format = "{0:F1}";

            tech_temperature        = new TechParameter();
            tech_temperature.Format = "{0:F3}";

            tech_proccessVolume = new TechParameter();

            tech_volume.gType      = "ADDDFF1B-92CE-42C4-BB4B-E50B8382A531";
            tech_consumption.gType = "6919E0F5-31FE-4386-9328-54C0E76D198C";

            tech_density.gType  = "D20E521B-A0FD-4EBB-BD49-AE8E706F50EC";
            tech_pressure.gType = "999C94B9-DA92-4010-ACBF-EB885D9BDC7C";

            tech_temperature.gType    = "D5A1B201-81C9-4702-A78F-FE35C5C72B3A";
            tech_proccessVolume.gType = "574E8874-42A3-4262-A251-523399E2EA79";

            rgrs = new RgrList();
            for (int i = 0; i < 8; i++)
            {
                rgrs.Add(new Rgr());
            }
        }
Exemplo n.º 4
0
        //private float lastVolume = float.NaN;

        /// <summary>
        /// Выполнить копирование данных с учетом технологии этапа.
        /// Вычислить параметры этапа.
        /// </summary>
        public void Calculate(RgrList rgrs)
        {
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(100))
                {
                    blocked = true;
                    switch (stateRgr)
                    {
                    case StateRGR.Pressed:

                        /*if (float.IsNaN(lastVolume) || float.IsInfinity(lastVolume) ||
                         *  float.IsPositiveInfinity(lastVolume) || float.IsNegativeInfinity(lastVolume))
                         * {
                         *  lastVolume = _tech.Volume.Value;
                         * }
                         *
                         * float currentVolume = _tech.Volume.Value;
                         * if (lastVolume > currentVolume)
                         * {
                         *  constVolume = constVolume - (lastVolume - currentVolume);
                         *  lastVolume = currentVolume;
                         *
                         *  Application app = Application.CreateInstance();
                         *  if (app != null)
                         *  {
                         *      app.SaveStages();
                         *  }
                         * }
                         *
                         * Consumption = _tech.Consumption.Value * _tech.Stages.CorrectionFactor;
                         *
                         * float deltaVolume = (currentVolume - ConstVolume);
                         * if (deltaVolume >= 0)
                         * {
                         *  Volume = deltaVolume * _tech.Stages.CorrectionFactor + _tech.Stages.s;
                         *  lastVolume = currentVolume;
                         * }*/

                        foreach (Rgr rgr in rgrs)
                        {
                            if (rgr.Calculate(StateRGR))
                            {
                                Application app = Application.CreateInstance();
                                if (app != null)
                                {
                                    app.SaveStages();
                                }
                            }

                            if (rgr.IsMain)
                            {
                                Volume      = rgr.CurrentVolume;
                                Consumption = rgr.CurrentConsumption;
                            }
                        }

                        break;

                    case StateRGR.Unpressed:

                        foreach (Rgr rgr in rgrs)
                        {
                            rgr.Calculate(StateRGR);
                        }

                        Consumption = 0.0f;
                        Volume      = 0.0f;

                        break;

                    default:
                        break;
                    }

                    Density          = _tech.Density.Value;
                    FormattedDensity = _tech.Density.FormattedValue;

                    Pressure          = _tech.Pressure.Value;
                    FormattedPressure = _tech.Pressure.FormattedValue;

                    Temperature          = _tech.Temperature.Value;
                    FormattedTemperature = _tech.Temperature.FormattedValue;

                    _tech.Stages.ProccessVolume = _tech.Stages.TotalVolume + Volume;
                }
            }
            catch { }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
        }