void AddMonGroup(Chart chart, MonGroup monGroup)
        {
            ComboBoxItem selectedItem = DataCount.SelectedItem as ComboBoxItem;
            int          dataCount    = int.Parse(selectedItem.Content.ToString());
            int          markStyle    = 1;

            MonPoint firstPnt = monGroup.monPntDict.Values.First();

            foreach (string key in firstPnt.readingsDict.Keys)
            {
                List <MonReading> firstPnt_readings = firstPnt.readingsDict[key];
                int numReadings = firstPnt_readings.Count;
                if (numReadings < dataCount)
                {
                    dataCount = numReadings;
                }

                for (int i = 0; i < dataCount; ++i)
                {
                    int        index            = numReadings - i * numReadings / dataCount - 1;
                    MonReading firstPnt_reading = firstPnt_readings[index];
                    DateTime   time             = firstPnt_reading.time;

                    Series series1 = new Series();
                    series1.ChartType = SeriesChartType.Line;
                    series1.ChartArea = "ChartArea1";
                    series1.Name      = string.Format("{0}: {1} ({2:d})",
                                                      monGroup.name, key, time);
                    series1.BorderWidth = 2;
                    series1.MarkerStyle = (MarkerStyle)(markStyle++ % 9);
                    series1.MarkerSize  = 8;

                    foreach (MonPoint monPoint in monGroup.monPntDict.Values)
                    {
                        if (monPoint.readingsDict.ContainsKey(key) == false)
                        {
                            continue;
                        }
                        List <MonReading> readings = monPoint.readingsDict[key];
                        int readIndex = index;
                        if (readIndex > readings.Count - 1)
                        {
                            readIndex = readings.Count - 1;
                        }
                        MonReading reading   = readings[readIndex];
                        double     x         = reading.value * _sign;
                        double     y         = monPoint.distanceZ.Value;
                        DataPoint  dataPoint = new DataPoint(x, y);
                        if (_showName)
                        {
                            dataPoint.Label = monPoint.name;
                        }
                        dataPoint.ToolTip = "#VALX";
                        series1.Points.Add(dataPoint);
                    }

                    chart.Series.Add(series1);
                }
            }
        }
예제 #2
0
 public static string getMonPointUnit(MonPoint monPoint)
 {
     if (monPoint == null || monPoint.readingsDict == null ||
         monPoint.readingsDict.Count == 0)
         return null;
     List<MonReading> readings = monPoint.readingsDict.Values.First();
     if (readings == null || readings.Count == 0)
         return null;
     string unit = readings.First().unit;
     return unit;
 }
예제 #3
0
        public static string getMonGroupUnit(MonGroup group)
        {
            if (group == null || group.monPntDict == null ||
                group.monPntDict.Count == 0)
            {
                return(null);
            }
            MonPoint monPoint = group.monPntDict.Values.First();
            string   unit     = getMonPointUnit(monPoint);

            return(unit);
        }
예제 #4
0
 // Returns the MonPoint's parent (DGObjects) rawDataSet
 // because MonGroup doesn't stores readings.
 DataSet getMonGroupDataSet(IEnumerable <DGObject> objs)
 {
     if (objs.Count() > 0)
     {
         MonGroup group = objs.First() as MonGroup;
         if (group.monPntDict.Count > 0)
         {
             MonPoint point = group.monPntDict.Values.First();
             return(point.parent.rawDataSet);
         }
     }
     return(null);
 }
예제 #5
0
        public static FrameworkElement getMonGroupChart(
            IEnumerable <DGObject> objs, double width, double height)
        {
            if (objs == null || objs.Count() == 0)
            {
                return(null);
            }
            MonGroup firstMonGroup = objs.First() as MonGroup;

            if (firstMonGroup == null ||
                firstMonGroup.monPntDict == null ||
                firstMonGroup.monPntDict.Count == 0)
            {
                return(null);
            }
            MonPoint lastMonPoint = firstMonGroup.monPntDict.Values.Last();

            if (lastMonPoint == null)
            {
                return(null);
            }

            string shape = firstMonGroup.groupShape.ToLower();

            if (shape == "line" || shape == "linear")
            {
                if (lastMonPoint.distanceZ != null &&
                    lastMonPoint.distanceZ.Value != 0)
                {
                    MonGroupChartLinearZ chart = new MonGroupChartLinearZ(width, height);
                    chart.setObjs(objs);
                    return(chart);
                }
                else
                {
                    MonGroupChartLinearX chart = new MonGroupChartLinearX(width, height);
                    chart.setObjs(objs);
                    return(chart);
                }
            }
            else if (shape == "circle" || shape == "circular")
            {
                return(getMonGroupChart_Circular(objs, width, height));
            }
            return(null);
        }
예제 #6
0
        public static string getMonPointUnit(MonPoint monPoint)
        {
            if (monPoint == null || monPoint.readingsDict == null ||
                monPoint.readingsDict.Count == 0)
            {
                return(null);
            }
            List <MonReading> readings = monPoint.readingsDict.Values.First();

            if (readings == null || readings.Count == 0)
            {
                return(null);
            }
            string unit = readings.First().unit;

            return(unit);
        }
예제 #7
0
        // Summary:
        //     Resume the relationship betwwen MonGroup and MonPoint.
        void resumeGroup2PointRelationship(MonGroup group, Domain domainMon)
        {
            if (group.monPntNames == null)
            {
                return;
            }

            foreach (string monPntName in group.monPntNames)
            {
                MonPoint monPnt = findMonPoint(monPntName, domainMon);
                if (monPnt == null)
                {
                    continue;
                }
                group.monPntDict[monPnt.name] = monPnt;
            }
        }
예제 #8
0
        // Clear readings of DGObjects if each object is MonPoint
        public void ClearReadings(DGObjects objs)
        {
            // clear objs rawData.Table[1] which is Readings
            if (objs.rawDataSet.Tables.Count >= 1)
            {
                objs.rawDataSet.Tables[1].Clear();
            }

            // clear readings for every DGObject
            foreach (DGObject obj in objs.values)
            {
                MonPoint monPoint = obj as MonPoint;
                if (monPoint == null)
                {
                    continue;
                }
                monPoint.readingsDict.Clear();
            }
        }
        public void setObjs(IEnumerable <DGObject> objs)
        {
            _objs = objs;

            if (objs == null || objs.Count() == 0)
            {
                return;
            }
            MonPoint firstMonPoint = objs.First() as MonPoint;

            if (firstMonPoint == null)
            {
                return;
            }
            string unit = ChartHelper.getMonPointUnit(firstMonPoint);

            if (CBComponents.Items.Count == 1)
            {
                // initialize the display list when the control first show
                // add componenet name
                foreach (string key in firstMonPoint.readingsDict.Keys)
                {
                    ComboBoxItem item = new ComboBoxItem();
                    item.Content = key;
                    CBComponents.Items.Add(item);
                }
            }

            Chart chart1 = new Chart();

            chart1.Name = "Chart1";
            chart1.Text = "Chart1";

            ChartArea chartArea1 = new ChartArea("ChartArea1");

            ChartHelper.setChartAreaStyle(chartArea1);
            chartArea1.AxisX.LabelAutoFitStyle =
                LabelAutoFitStyles.IncreaseFont |
                LabelAutoFitStyles.DecreaseFont |
                LabelAutoFitStyles.WordWrap;
            chartArea1.AxisX.Title = "Date";
            chartArea1.AxisX.ScrollBar.LineColor = Color.Black;
            chartArea1.AxisX.ScrollBar.Size      = 10;
            chartArea1.AxisY.Title = "Value (" + unit + ")";
            chartArea1.AxisY.ScrollBar.LineColor      = Color.Black;
            chartArea1.AxisY.ScrollBar.Size           = 10;
            chartArea1.CursorX.IsUserEnabled          = true;
            chartArea1.CursorX.IsUserSelectionEnabled = true;
            chartArea1.CursorY.IsUserEnabled          = true;
            chartArea1.CursorY.IsUserSelectionEnabled = true;
            chart1.ChartAreas.Add(chartArea1);

            Legend legend1 = new Legend("Legend1");

            legend1.DockedToChartArea = "ChartArea1";
            chart1.Legends.Add(legend1);

            foreach (DGObject obj in objs)
            {
                MonPoint monPnt = obj as MonPoint;
                if (monPnt == null)
                {
                    continue;
                }
                foreach (string key in monPnt.readingsDict.Keys)
                {
                    if (_component != "ALL" && _component != key)
                    {
                        continue;
                    }

                    List <MonReading> readings = monPnt.readingsDict[key];
                    if (readings.Count == 0)
                    {
                        continue;
                    }

                    Series series1 = new Series();
                    series1.Name      = monPnt.name + ":" + key;
                    series1.ChartType = SeriesChartType.FastLine;
                    series1.ChartArea = "ChartArea1";
                    series1.Points.DataBind(readings, "time", "value", null);
                    series1.BorderWidth = 2;

                    chart1.Series.Add(series1);
                }
            }

            chartHost.Child = chart1;
        }