コード例 #1
0
        public List<Fusion> GetTrendPoints(string fileName)
        {
            List<Fusion> result = new List<Fusion>();
            List<TrendPoint> points = new List<TrendPoint>();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(fileName);
            System.IO.FileInfo file = new System.IO.FileInfo(fileName);
            m_NewType = file.Extension == ".pldx";

            int countFusion = 0;
            string startDate = "";
            Fusion fusion = null;
            while (!streamReader.EndOfStream)
            {
                string temp = streamReader.ReadLine();
                if (temp.StartsWith("V7") || temp.StartsWith("New"))
                {
                    continue;
                }
                if (temp.StartsWith(">"))
                {

                    countFusion++;
                    if (countFusion > 1)
                    {

                        if (!m_NewType)
                        {
                            string startDate1 = ParseDateFromFileName(fileName);
                            startDate1 = string.Format("{0} {1}:00", startDate1, temp.Substring(1, 5));
                            if (Convert.ToDateTime(startDate) != Convert.ToDateTime(startDate1))
                            {
                                fusion = new Fusion(countFusion, Convert.ToDateTime(startDate), points);
                                fusion.ConverterNumber = int.Parse(fileName.Substring(fileName.Length - 16, 1));
                            }
                            else
                            {
                                countFusion--;
                            }
                        }
                        else
                        {

                            string[] split = temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            fusion = new Fusion(int.Parse(split[1]), DateTime.Parse(split[2] + " " + split[3]), points);
                            fusion.ConverterNumber = int.Parse(fileName.Substring(fileName.Length - 17, 1));
                            fusion.Id = int.Parse(split[0].Substring(2));
                            fusion.StartDateDB = DateTime.Parse(split[4] + " " + split[5]);
                            fusion.TeamNumber = int.Parse(split[6]);
                            int offset = 0;
                            if (split.Length < 12) continue;
                            if (split.Length > 12)
                            {
                                offset = split.Length - 12;
                                for (int i = 7; i <= 7 + offset; i++)
                                {
                                    fusion.Grade += split[i];
                                }
                            }
                            else
                            {
                                fusion.Grade = split[7];
                            }

                            fusion.PlannedTempereture = int.Parse(split[8 + offset]);
                            fusion.FactTemperature = int.Parse(split[9 + offset]);
                            fusion.PlannedC = double.Parse(split[10 + offset]);
                            fusion.FactC = double.Parse(split[11 + offset]);

                        }
                        if (fusion != null)
                        {
                            result.Add(fusion);
                            points = new List<TrendPoint>();
                        }
                    }
                    if (!m_NewType)
                    {
                        startDate = ParseDateFromFileName(fileName);
                        startDate = string.Format("{0} {1}:00", startDate, temp.Substring(1, 5));
                    }
                    else
                    {
                        startDate = temp;
                    }
                    continue;
                }
                if (m_NewType)
                {
                    points.Add(ParseLineNew(temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)));
                }
                else
                {
                    points.Add(ParseLine(temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), startDate));
                }
            }

            return result;
        }
コード例 #2
0
        public void ShowFusion(Fusion fusion)
        {
            lbH2Value.Text = "";
            lbO2Value.Text = "";
            lbCOValue.Text = "";
            lbCO2Value.Text = "";
            lbN2Value.Text = "";
            lbArValue.Text = "";
            zgMain.GraphPane.CurveList.Clear();
            PointPairList pointsH2 = new PointPairList();
            PointPairList pointsO2 = new PointPairList();
            PointPairList pointsCO = new PointPairList();
            PointPairList pointsCO2 = new PointPairList();
            PointPairList pointsN2 = new PointPairList();
            PointPairList pointsAr = new PointPairList();
            foreach (TrendPoint tp in fusion.Points)
            {
                pointsH2.Add(tp.Time.TotalSeconds, tp.H2);
                pointsO2.Add(tp.Time.TotalSeconds, tp.O2);
                pointsCO.Add(tp.Time.TotalSeconds, tp.CO);
                pointsCO2.Add(tp.Time.TotalSeconds, tp.CO2);
                pointsN2.Add(tp.Time.TotalSeconds, tp.N2);
                pointsAr.Add(tp.Time.TotalSeconds, tp.Ar);
            }
            if (cbH2.Checked)
            {
                zgMain.GraphPane.AddCurve("H2", pointsH2, Color.Green, SymbolType.None);
            }
            if (cbO2.Checked)
            {
                zgMain.GraphPane.AddCurve("O2", pointsO2, Color.Blue, SymbolType.None);
            }
            if (cbCO.Checked)
            {
                zgMain.GraphPane.AddCurve("CO", pointsCO, Color.Red, SymbolType.None);
            }
            if (cbCO2.Checked)
            {
                zgMain.GraphPane.AddCurve("CO2", pointsCO2, Color.Orange, SymbolType.None);
            }
            if (cbN2.Checked)
            {
                zgMain.GraphPane.AddCurve("N2", pointsN2, Color.Black, SymbolType.None);
            }
            if (cbAr.Checked)
            {
                zgMain.GraphPane.AddCurve("Ar", pointsAr, Color.Turquoise, SymbolType.None);
            }
            zgMain.GraphPane.Title.FontSpec.Size = 6;
            zgMain.GraphPane.Title.Text = string.Format("Плавка: {0}  Марка: {1}  Начало: {2}({3})  Бригада: {4}  Конвертер:{5}  Т зад={6}  Т факт={7}  С зад={8}  С факт={9}",
                                                         fusion.Number, fusion.Grade, fusion.StartDate, fusion.StartDateDB,
                                                         fusion.TeamNumber, fusion.ConverterNumber, fusion.PlannedTempereture,
                                                         fusion.FactTemperature, fusion.PlannedC, fusion.FactC);

            // Отображаем график для введенных формул
            if (gbVars.Controls.Count > 0)
            {
                MathParser mathParser = new MathParser();
                int varsCount = gbVars.Controls.Count / 3;
                for (int i = 0; i < varsCount; i++)
                {
                    PointPairList points = new PointPairList();
                    foreach (TrendPoint tp in fusion.Points)
                    {
                        mathParser.CreateVar("H2", tp.H2, null);
                        mathParser.CreateVar("O2", tp.O2, null);
                        mathParser.CreateVar("CO", tp.CO, null);
                        mathParser.CreateVar("CO2", tp.CO2, null);
                        mathParser.CreateVar("N2", tp.N2, null);
                        mathParser.CreateVar("Ar", tp.Ar, null);
                        mathParser.Expression = (gbVars.Controls.Find(string.Format("tb{0}", i), true)[0] as System.Windows.Forms.TextBox).Text;
                        try
                        {
                            points.Add(tp.Time.TotalSeconds, mathParser.ValueAsDouble);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(string.Format("Переменная {0} задана неверно, ошибка в формуле", (gbVars.Controls.Find(string.Format("lb{0}", i), true)[0] as System.Windows.Forms.Label).Text));
                            return;
                        }
                    }
                    mathParser.CreateVar((gbVars.Controls.Find(string.Format("lb{0}", i), true)[0] as System.Windows.Forms.Label).Text,
                                          mathParser.ValueAsString,
                                          null);
                    if ((gbVars.Controls.Find(string.Format("cb{0}", i), true)[0] as System.Windows.Forms.CheckBox).Checked)
                    {
                        zgMain.GraphPane.AddCurve((gbVars.Controls.Find(string.Format("lb{0}", i), true)[0] as System.Windows.Forms.Label).Text, points, Color.DeepPink, SymbolType.None);
                    }
                }
            }
            zgMain.GraphPane.Legend.IsVisible = false;
            zgMain.AxisChange();
            zgMain.Invalidate();
            zgMain.Visible = true;
            pAddVar.Visible = true;
            pVars.Visible = true;
            gbValues.Visible = true;
        }