Ejemplo n.º 1
0
Archivo: Tech.cs Proyecto: slawer/skc
        /// <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 { }
        }
Ejemplo n.º 2
0
Archivo: Tech.cs Proyecto: slawer/skc
        private TechParameter tech_volume; // объем

        #endregion Fields

        #region Constructors

        /// <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());
            }
        }
Ejemplo n.º 3
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();
            }
        }