Пример #1
0
        public void ResetTrend(int trendIndex)
        {
            TrendObj trendObj = fChart[trendIndex];

            Panel1.Text = "< " + trendObj.Name + " >";
            if (trendObj.AutoScaleMin)
            {
                txtMin.Text = string.Format("{0:0.00}", trendObj.Series.ChartMin);
            }
            else
            {
                txtMin.Text = string.Format("{0:0.00}", trendObj.Min);
            }
            chkMin.Checked = trendObj.AutoScaleMin;
            if (trendObj.AutoScaleMax)
            {
                txtMax.Text = string.Format("{0:0.00}", trendObj.Series.ChartMax);
            }
            else
            {
                txtMax.Text = string.Format("{0:0.00}", trendObj.Max);
            }
            chkMax.Checked                           = trendObj.AutoScaleMax;
            chkVisible.Checked                       = trendObj.Visible;
            rgPrepareMode.SelectedIndex              = (int)trendObj.Series.PostAction;
            chkShowSource.Checked                    = trendObj.ShowSource;
            fFilterOptions                           = trendObj.Series.Filter;
            rgFilterMode.SelectedIndex               = (int)fFilterOptions.Mode;
            txtBandWidth.Text                        = fFilterOptions.BandWidth.ToString();
            chkOvershoot.Checked                     = fFilterOptions.Overshoot;
            cmbSuppressionDegree.SelectedIndex       = (int)((sbyte)fFilterOptions.SuppressionDegree);
            cmbSubstractionNoiseDegree.SelectedIndex = (int)((sbyte)fFilterOptions.SubstractionNoiseDegree);

            UpdateFilterControls();
        }
Пример #2
0
        public void ApplyTrend(int trendIndex)
        {
            TrendObj trendObj = fChart[trendIndex];

            trendObj.AutoScaleMin = chkMin.Checked;
            if (!trendObj.AutoScaleMin)
            {
                trendObj.Min = ConvertHelper.ParseFloat(txtMin.Text, 0);
            }
            trendObj.AutoScaleMax = chkMax.Checked;
            if (!trendObj.AutoScaleMax)
            {
                trendObj.Max = ConvertHelper.ParseFloat(txtMax.Text, 0);
            }
            trendObj.Visible                       = chkVisible.Checked;
            trendObj.Series.PostAction             = (PostAction)rgPrepareMode.SelectedIndex;
            trendObj.ShowSource                    = chkShowSource.Checked;
            fFilterOptions.BandWidth               = ConvertHelper.ParseFloat(txtBandWidth.Text, 0);
            fFilterOptions.Overshoot               = chkOvershoot.Checked;
            fFilterOptions.SuppressionDegree       = (FilterDegree)cmbSuppressionDegree.SelectedIndex;
            fFilterOptions.SubstractionNoiseDegree = (FilterDegree)cmbSubstractionNoiseDegree.SelectedIndex;
            trendObj.Series.Filter                 = fFilterOptions;
            trendObj.SaveSettings();

            fChart.DataUpdated();
        }
Пример #3
0
        public TrendObj AddTrend()
        {
            TrendObj trendObj = new TrendObj();

            fTrends.Add(trendObj);
            return(trendObj);
        }
Пример #4
0
        public void PrepareArray(string title, string xAxis, string yAxis, TrendObj trendObj)
        {
            List <TrendPoint> vals = trendObj.Series.List;

            GraphPane gPane = fGraph.GraphPane;

            try
            {
                gPane.Title.Text       = title;
                gPane.XAxis.Title.Text = xAxis;
                gPane.YAxis.Title.Text = yAxis;

                gPane.XAxis.Type = AxisType.Date;
                PointPairList ppList   = new PointPairList();
                bool          filtered = (trendObj.Series.PostAction != PostAction.paNone);

                int num = vals.Count;
                for (int i = 0; i < num; i++)
                {
                    TrendPoint item  = vals[i];
                    double     value = (!filtered) ? item.pValue : item.pFilteredValue;
                    ppList.Add(item.pTime, value);
                }
                ppList.Sort();

                gPane.AddCurve(trendObj.Name, ppList, trendObj.Color, SymbolType.None);
            }
            finally
            {
                fGraph.AxisChange();
                fGraph.Invalidate();
            }
        }
Пример #5
0
 private void SetTagByItem(TrendObj trendObj, ListViewItem listItem)
 {
     trendObj.Name = listItem.SubItems[0].Text;
     trendObj.Tag  = listItem.Text;
     trendObj.Init();
     trendObj.LoadSettings();
 }
Пример #6
0
 private void CheckModifyTagList()
 {
     if (!string.IsNullOrEmpty(fCurTagListFile) && fModified)
     {
         using (IniFile iniFile = new IniFile(fCurTagListFile)) {
             if (PIBUtils.ShowQuestionYN(string.Concat(new string[] {
                 "List of tags: \"",
                 Path.GetFileName(fCurTagListFile),
                 "\" is changed. Save changes?"
             })))
             {
                 for (int i = 1; i <= MAX_TRENDS; i++)
                 {
                     TrendObj trendObj = TrendChart1[i - 1];
                     iniFile.WriteString("Trends", "Trend" + Convert.ToString(i), trendObj.Tag);
                     iniFile.WriteInteger("Trends", "PostAction" + Convert.ToString(i), (int)trendObj.PostAction);
                     if (trendObj.PostAction != PostAction.paNone)
                     {
                         iniFile.WriteInteger("Trends", "Mode" + Convert.ToString(i), (int)trendObj.Filter.Mode);
                         iniFile.WriteFloat("Trends", "BandWidth" + Convert.ToString(i), trendObj.Filter.BandWidth);
                         iniFile.WriteBool("Trends", "Overshoot" + Convert.ToString(i), trendObj.Filter.Overshoot);
                         iniFile.WriteInteger("Trends", "FrequencyResolution" + Convert.ToString(i), trendObj.Filter.FrequencyResolution);
                         iniFile.WriteInteger("Trends", "SuppressionDegree" + Convert.ToString(i), (int)trendObj.Filter.SuppressionDegree);
                         iniFile.WriteInteger("Trends", "SubstractionNoiseDegree" + Convert.ToString(i), (int)trendObj.Filter.SubstractionNoiseDegree);
                     }
                 }
             }
         }
     }
 }
Пример #7
0
        public void tbAnalysisClick(object sender, EventArgs e)
        {
            StringList strList = new StringList();

            try {
                for (int i = 0; i < MAX_TRENDS; i++)
                {
                    TrendObj trendObj = TrendChart1[i];

                    if (!string.IsNullOrEmpty(trendObj.Tag))
                    {
                        strList.Add(string.Concat(new string[] {
                            trendObj.Tag,
                            ": ",
                            "MIN: ",
                            AnalitikMIN[i].ToString(),
                            "| ",
                            "MAX: ",
                            AnalitikMAX[i].ToString(),
                            "| ",
                            "AVG: ",
                            AnalitikAVG[i].ToString(),
                            "\n\r"
                        }));
                    }
                }

                if (strList.Text != "")
                {
                    PIBUtils.ShowMessage("Analysis results:\n\r" + strList.Text);
                }
            } catch (Exception ex) {
                strList.Dispose();
            }
        }
Пример #8
0
        public void tbTLSaveClick(object sender, EventArgs e)
        {
            sdTagList.Filter           = "Tags list file (*.lst)|*.lst|All files|*.*";
            sdTagList.InitialDirectory = PIBUtils.GetAppPath();

            if (sdTagList.ShowDialog() == DialogResult.OK)
            {
                using (IniFile iniFile = new IniFile(sdTagList.FileName)) {
                    for (int i = 1; i <= MAX_TRENDS; i++)
                    {
                        TrendObj trendObj = TrendChart1[i - 1];
                        iniFile.WriteString("Trends", "Trend" + Convert.ToString(i), trendObj.Tag);
                        iniFile.WriteInteger("Trends", "PostAction" + Convert.ToString(i), (int)trendObj.PostAction);
                        if (trendObj.PostAction != PostAction.paNone)
                        {
                            iniFile.WriteInteger("Trends", "Mode" + Convert.ToString(i), (int)trendObj.Filter.Mode);
                            iniFile.WriteFloat("Trends", "BandWidth" + Convert.ToString(i), trendObj.Filter.BandWidth);
                            iniFile.WriteBool("Trends", "Overshoot" + Convert.ToString(i), trendObj.Filter.Overshoot);
                            iniFile.WriteInteger("Trends", "FrequencyResolution" + Convert.ToString(i), trendObj.Filter.FrequencyResolution);
                            iniFile.WriteInteger("Trends", "SuppressionDegree" + Convert.ToString(i), (int)trendObj.Filter.SuppressionDegree);
                            iniFile.WriteInteger("Trends", "SubstractionNoiseDegree" + Convert.ToString(i), (int)trendObj.Filter.SubstractionNoiseDegree);
                        }
                    }
                }

                CaptionTagList = "Current list of tags: " + Path.GetFileName(sdTagList.FileName);
                fModified      = false;
            }
        }
Пример #9
0
 public TrendObj this[int index]
 {
     get {
         TrendObj result = null;
         if (index >= 0 && index < fTrends.Count)
         {
             result = fTrends[index];
         }
         return(result);
     }
 }
Пример #10
0
 private void InitTrends()
 {
     for (int i = 0; i < MAX_TRENDS; i++)
     {
         TrendObj trendObj = TrendChart1.AddTrend();
         trendObj.GridShow = true;
         trendObj.PosX     = 1;
         trendObj.PosY     = 1;
         trendObj.Tag      = "";
     }
 }
Пример #11
0
        public double FindValue(DateTime dtx)
        {
            double fdt = dtx.ToOADate();

            double result = 0.0;

            try {
                bool flag = fSeries.PostAction != PostAction.paNone && (fSeries.PostAction == PostAction.paNone || !fShowSource);

                int num  = 0;
                int num2 = fSeries.Count - 1;
                if (num <= num2)
                {
                    do
                    {
                        int num3 = (int)((uint)(num + num2) >> 1);
                        int num4 = TrendObj.FindValue_CompareValue(fSeries[num3].pTime, fdt);
                        if (num4 < 0)
                        {
                            num = num3 + 1;
                        }
                        else
                        {
                            num2 = num3 - 1;
                            if (num4 == 0)
                            {
                                num = num3;
                            }
                        }
                    } while (num <= num2);
                }

                int num5 = num;
                if (num5 >= 0 && num5 < fSeries.Count)
                {
                    if (flag)
                    {
                        result = fSeries[num5].pFilteredValue;
                    }
                    else
                    {
                        result = fSeries[num5].pValue;
                    }
                }
                else
                {
                    result = 0.0;
                }
            } catch (Exception ex) {
                PIBUtils.ShowError("Error type #4: " + ex.Message);
            }
            return(result);
        }
Пример #12
0
        public void btnReset_Click(object sender, EventArgs e)
        {
            TreeNode selected = TreeView1.SelectedNode;

            if (selected != null)
            {
                int num = (int)selected.Tag;
                if (num >= 0 && num < fChart.TrendsCount)
                {
                    TrendObj trendObj = fChart[num];
                    trendObj.ClearSettings();
                    ResetTrend(num);
                    fChart.DataUpdated();
                }
            }
        }
Пример #13
0
        public void LoadListTrend(string trendListFile)
        {
            using (IniFile iniFile = new IniFile(trendListFile)) {
                for (int k = 1; k <= MAX_TRENDS; k++)
                {
                    TrendChart1[k - 1].Tag = iniFile.ReadString("Trends", "Trend" + Convert.ToString(k), "");
                }

                for (int i = 0; i < MAX_TRENDS; i++)
                {
                    TrendObj trendObj = TrendChart1[i];

                    if (!string.IsNullOrEmpty(trendObj.Tag))
                    {
                        ListViewItem listItem = PIBUtils.FindCaption(lvTags, trendObj.Tag);
                        if (listItem != null)
                        {
                            listItem.Checked = true;
                            SetTagByItem(trendObj, listItem);
                            trendObj.PostAction = (PostAction)iniFile.ReadInteger("Trends", "PostAction" + Convert.ToString(i), 1);
                            if (trendObj.PostAction != PostAction.paNone)
                            {
                                FilterOptions filter = trendObj.Filter;
                                filter.Mode                    = (FilterMode)iniFile.ReadInteger("Trends", "Mode" + Convert.ToString(i), 1);
                                filter.BandWidth               = iniFile.ReadFloat("Trends", "BandWidth" + Convert.ToString(i), 0.1);
                                filter.Overshoot               = iniFile.ReadBool("Trends", "Overshoot" + Convert.ToString(i), false);
                                filter.FrequencyResolution     = iniFile.ReadInteger("Trends", "FrequencyResolution" + Convert.ToString(i), 5);
                                filter.SuppressionDegree       = (FilterDegree)iniFile.ReadInteger("Trends", "SuppressionDegree" + Convert.ToString(i), 0);
                                filter.SubstractionNoiseDegree = (FilterDegree)iniFile.ReadInteger("Trends", "SubstractionNoiseDegree" + Convert.ToString(i), 0);
                            }
                        }
                        else
                        {
                            PIBUtils.ShowWarning("Tag " + trendObj.Tag + " not exists");
                            trendObj.Tag = "";
                            fModified    = true;
                        }
                    }
                }

                TrendChart1.FiltersApply();
                SelectTag(TrendChart1[0].Tag);
                LVTagsClick(lvTags, null);
            }

            CaptionTagList = "Current list of tags: " + Path.GetFileName(trendListFile);
        }
Пример #14
0
 public void DrawTrends()
 {
     Clear();
     for (int i = 0; i < fTrends.Count; i++)
     {
         TrendObj trendObj = fTrends[i];
         if (fTrends[i].Visible)
         {
             try {
                 if (!string.IsNullOrEmpty(trendObj.Tag))
                 {
                     PrepareArray("", "", "", trendObj);
                 }
             } catch (Exception ex) {
                 PIBUtils.ShowMessage("Error type #8: " + ex.Message);
             }
         }
     }
 }
Пример #15
0
        private void LoadTrendData(DataLoadKind loadKind, DateTime aBeg, DateTime aEnd)
        {
            RefreshNavigation();

            if (loadKind == DataLoadKind.dlkByStart)
            {
                for (int i = 0; i < MAX_TRENDS; i++)
                {
                    TrendChart1[i].Clear();
                }
            }

            DateTime begDateTime = DateTime.Now;
            DateTime endDateTime = DateTime.Now;

            GetTimeRange(ref begDateTime, ref endDateTime);

            TrendChart1.BegDateTime = begDateTime;
            TrendChart1.EndDateTime = endDateTime;
            TrendChart1.ForeColor   = Color.Black;
            TrendChart1.RulerColor  = Color.Black;
            TrendChart1.XAxisColor  = Color.Black;
            TrendChart1.CrossRuler  = true;
            TrendChart1.DateCode    = 0;
            TrendChart1.DayCode     = 0;
            TrendChart1.MonthCode   = 0;
            TrendChart1.YearCode    = 0;
            TrendChart1.AroundZoom  = true;
            TrendChart1.Legend      = true;

            TrendChart1.BeginUpdate();
            for (int k = 0; k < MAX_TRENDS; k++)
            {
                int num2 = k / 4;
                int num3 = k % 4;

                TrendObj trendObj = TrendChart1[k];
                //if (trendObj == null) continue;

                switch (k)
                {
                case 0:
                    trendObj.Color = Color.Red;
                    break;

                case 1:
                    trendObj.Color = Color.Green;
                    break;

                case 2:
                    trendObj.Color = Color.Black;
                    break;

                case 3:
                    trendObj.Color = Color.Blue;
                    break;

                case 4:
                    trendObj.Color = Color.Fuchsia;
                    break;

                case 5:
                    trendObj.Color = Color.Navy;
                    break;

                case 6:
                    trendObj.Color = Color.Olive;
                    break;

                case 7:
                    trendObj.Color = Color.Purple;
                    break;
                }

                trendObj.AxisSign   = "[" + Convert.ToString(k) + "]";
                trendObj.ScaleIndex = num3 + 1;
                trendObj.PosY       = num2 + 1;

                if (!string.IsNullOrEmpty(trendObj.Tag))
                {
                    float zero, span;
                    PIBUtils.piLoadTrend(trendObj.Series, trendObj.Tag, (LoadFlags)0, aBeg, aEnd, out zero, out span);

                    double sum = 0.0;
                    if (trendObj.Series.Count > 0)
                    {
                        AnalitikMAX[k] = trendObj.Series[0].pValue;
                        AnalitikMIN[k] = trendObj.Series[0].pValue;
                    }
                    else
                    {
                        AnalitikMAX[k] = 0.0;
                        AnalitikMIN[k] = 0.0;
                    }

                    for (int i = 0; i < trendObj.Series.Count; i++)
                    {
                        TrendPoint trendPt = trendObj.Series[i];
                        sum = (sum + trendPt.pValue);
                        if (trendPt.pValue >= AnalitikMAX[k])
                        {
                            AnalitikMAX[k] = trendPt.pValue;
                        }
                        if (trendPt.pValue <= AnalitikMIN[k])
                        {
                            AnalitikMIN[k] = trendPt.pValue;
                        }
                    }

                    if (trendObj.Series.Count != 0)
                    {
                        AnalitikAVG[k] = (sum / (double)trendObj.Series.Count);
                    }
                    else
                    {
                        AnalitikAVG[k] = 0.0;
                    }

                    if (trendObj.Series.Count > 0)
                    {
                        fLastUpdate = trendObj.Series[trendObj.Series.Count - 1].pTime;
                    }
                    else
                    {
                        fLastUpdate = 0;
                    }
                }
                else
                {
                    trendObj.Visible = false;
                    AnalitikMAX[k]   = 0.0;
                    AnalitikMIN[k]   = 0.0;
                }
            }

            TrendChart1.FiltersApply();
            TrendChart1.DrawTrends();
            TrendChart1.EndUpdate();
            TrendChart1.Invalidate();
        }