// Summary:
        //     Project loaded call back function
        // Remarks:
        //     When project data is loaded, the relationship between MonGroup
        //     and MonPoint need to be established.
        void mainframe_projectLoaded(object sender, EventArgs e)
        {
            if (Globals.project == null)
            {
                return;
            }
            Domain domainMon = Globals.project.getDomain(DomainType.Monitoring);

            if (domainMon == null)
            {
                return;
            }

            foreach (var def in domainMon.objsDefinitions.Values)
            {
                if (def.Type == "MonGroup")
                {
                    DGObjects objs = domainMon.objsContainer[def.Name];
                    foreach (var obj in objs.values)
                    {
                        MonGroup group = obj as MonGroup;
                        if (group == null)
                        {
                            continue;
                        }
                        resumeGroup2PointRelationship(group, domainMon);
                    }
                }
            }
        }
Пример #2
0
        public override List <FrameworkElement> chartViews(
            IEnumerable <DGObject> objs, double width, double height)
        {
            List <FrameworkElement> charts = new List <FrameworkElement>();

            // point curve
            List <MonPoint> allPoints = new List <MonPoint>();

            foreach (var obj in objs)
            {
                MonGroup group = obj as MonGroup;
                if (group == null)
                {
                    continue;
                }
                allPoints.AddRange(group.monPntDict.Values);
            }
            FrameworkElement chart =
                FormsCharting.getMonPointChart(allPoints, width, height);

            if (chart != null)
            {
                charts.Add(chart);
            }

            // group curve
            chart = FormsCharting.getMonGroupChart(objs, width, height);
            if (chart != null)
            {
                charts.Add(chart);
            }

            return(charts);
        }
Пример #3
0
        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);
                }
            }
        }
Пример #4
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);
        }
Пример #5
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);
 }
        // 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;
            }
        }
        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);
        }
        public override void setObjs(IEnumerable <DGObject> objs)
        {
            base.setObjs(objs);

            if (objs == null || objs.Count() == 0)
            {
                return;
            }
            MonGroup firstMonGroup = objs.First() as MonGroup;
            string   unit          = ChartHelper.getMonGroupUnit(firstMonGroup);

            Chart chart1 = new Chart();

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

            ChartArea chartArea1 = new ChartArea("ChartArea1");

            ChartHelper.setChartAreaStyle(chartArea1);
            chartArea1.AxisX.Title = "Distance (m)";
            chartArea1.AxisY.Title = "Value (" + unit + ")";
            chart1.ChartAreas.Add(chartArea1);

            Legend legend1 = new Legend("Legend1");

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

            foreach (DGObject obj in objs)
            {
                MonGroup monGroup = obj as MonGroup;
                if (monGroup == null)
                {
                    continue;
                }
                if (monGroup.monPntDict.Count == 0)
                {
                    continue;
                }

                AddMonGroup(chart1, monGroup);

                chartHost.Child = chart1;
            }
        }
Пример #9
0
        string nameFilter(IEnumerable <DGObject> objs)
        {
            string sql = "monPointName in (";

            foreach (var obj in objs)
            {
                MonGroup group = obj as MonGroup;
                if (group == null)
                {
                    continue;
                }
                foreach (string name in group.monPntNames)
                {
                    sql += '\'' + name + '\'';
                    sql += ",";
                }
            }
            sql += ")";
            return(sql);
        }