Inheritance: Caliburn.Micro.PropertyChangedBase
Exemple #1
0
        public void OpenFunctionOperationMenu(DataSet ds, SurfaceButton b)
        {
            var menu = new MenuPopupViewModel();
            menu.RelativeElement = b;
            menu.RelativePosition = new Point(0, 0);
            menu.TimeOut = new TimeSpan(0, 0, 0, 5);
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
            menu.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            //menu.DisplayProperty = "ServiceName";
            menu.AutoClose = true;

            foreach (var a in Enum.GetValues(typeof(FunctionOperations)))
            {
                var mi = menu.AddMenuItem(a.ToString());
                mi.Click += (e, s) =>
                {
                    SelectedDataSet.FunctionOperation = (FunctionOperations)a;
                    UpdateDataSet(SelectedDataSet);
                    menu.Close();
                };
            }
            AppState.Popups.Add(menu);
        }
Exemple #2
0
 private void RemoveDataSet(DataSet dataSet)
 {
     var tbr = model.Series.Where(k => k.Tag is Guid && (Guid) k.Tag == dataSet.Id).ToList();
     foreach (var a in tbr)
     {
         model.Series.Remove(a);
     }
     model.Update();
     _view.Plot.InvalidatePlot(true);
 }
Exemple #3
0
        public void OpenGroupingOperationMenu(DataSet ds, SurfaceButton b)
        {

            var menu = GetMenu(b);
            foreach (var a in Enum.GetValues(typeof(GroupingOperations)))
            {
                var mi = menu.AddMenuItem(a.ToString());
                mi.Click += (e, s) =>
                {
                    SelectedDataSet.GroupingOperation = (GroupingOperations)a;
                    UpdateDataSet(SelectedDataSet);
                    menu.Close();
                };
            }
            AppState.Popups.Add(menu);
        }
Exemple #4
0
        private void UpdateDataSet(DataSet ds)
        {

            foreach (var rls in model.Series.OfType<LineSeries>().ToList())
            {
                //Todo rls.Tag is null sometimes and throwing null pointer exception fix it
                if (!DataSets.Any(k=>k.Id.ToString() == rls.Tag.ToString()))
                {
                    model.Series.Remove(rls);
                }
            }
            if (ds.SparkLine || SparkLine)
            {
                SparkLine = true;
                model.IsLegendVisible = false;
                model.TitlePadding = 0;
                model.TitleFontSize = 0;
                model.SubtitleFontSize = 0;
                model.Title = "";
                model.Subtitle = "";
                model.Padding = new OxyThickness(0);
                model.PlotMargins = new OxyThickness(0);
                model.PlotAreaBorderThickness = 0;
                model.Axes.Clear();
                model.Axes.Add(new InvisibleAxis() { Position = AxisPosition.Left, IsAxisVisible = false });
                if (ds.DData != null)
                    model.Axes.Add(new InvisibleAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false });
                else
                    model.Axes.Add(new InvisibleDateAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false });

                if (ds.SparkLineAmount > 2)
                {
                    if (ds.DData != null)
                        ds.ReducedData = mf.CalculateReduction(ds.DData, ds.SparkLineAmount);
                    else
                    {

                        var r = (from n in ds.Data select new KeyValuePair<double, double>(DateTimeAxis.ToDouble(n.Key), n.Value)).ToSortedDictionary(k => k.Key, k => k.Value);
                        ds.ReducedData = mf.CalculateReduction(r, ds.SparkLineAmount);
                    }
                    ds.FunctionOperation = FunctionOperations.auto;
                }
                else if (ds.SparkLinePercentage > 0)
                {
                    if (ds.DData != null)
                        ds.ReducedData = mf.CalculateReduction(ds.DData, ds.SparkLinePercentage);
                    else
                    {
                        var r = (from n in ds.Data select new KeyValuePair<double, double>(DateTimeAxis.ToDouble(n.Key), n.Value)).ToSortedDictionary(k => k.Key, k => k.Value);
                        ds.ReducedData = mf.CalculateReduction(r, ds.SparkLinePercentage);
                    }
                    ds.FunctionOperation = FunctionOperations.auto;
                }
                foreach (var ax in model.Axes)
                {
                    ax.IsPanEnabled = false;
                    ax.IsZoomEnabled = false;
                }
                //foreach (var ax in model.Axes)
                //    ax.IsAxisVisible = false;
            }
            else SparkLine = false;

            if (model.Series.Count(k => ((Guid)k.Tag) == ds.Id) > 1)
                foreach (var r in model.Series.Where(k => ((Guid)k.Tag) == ds.Id).ToList())
                {
                    model.Series.Remove(r);
                }
            
            var ls = model.Series.FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString()) as LineSeries;
            if (ls==null)
                ls = new LineSeries(){Tag = ds.Id};
            ls.Smooth = ds.Smooth;
            ls.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
            if (ls.YAxisKey == "Right")
            {
                var ra = model.Axes.FirstOrDefault(k => k.Key == "Right");
                if (ra == null)
                {
                    var linearAxis2 = new LinearAxis();
                    linearAxis2.Position = AxisPosition.Right;
                    linearAxis2.Key = "Right";
                    linearAxis2.Title = ds.Unit != null ? ds.Unit : "Value";
                    model.Axes.Add(linearAxis2);
                }

            }
            if (ls != null)
            {
                var res = GetDataSet(ds);
                

                if (res.Count == 1)
                {
                    ls.Points.Clear();
                    foreach (var a in res.First())
                    {
                        ls.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                    var ap = model.Series.OfType<AreaSeries>().FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString());
                    if (ap != null)
                    {
                        model.Series.Remove(ap);
                    }
                }
                else if (ds.FunctionOperation == FunctionOperations.auto)
                {
                    var ap = model.Series.OfType<AreaSeries>().FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString());
                    if (ap == null)
                    {
                        ap = new AreaSeries() { Tag = ds.Id };
                        model.Series.Add(ap);
                    }
                    ap.Fill = OxyColor.FromAColor((byte)96,OxyColors.LightBlue);
                    ap.Color = OxyColors.Black;
                    ap.Points.Clear();
                    ap.Points2.Clear();
                    foreach (var a in res.Last())
                    {
                        ap.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                    foreach (var a in res.First())
                    {
                        ap.Points2.Add(new DataPoint(a.Key, a.Value));
                    }
                    foreach (var a in res[1])
                    {
                        ls.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                }
                else
                {
                    foreach (var r in model.Series.Where(k => ((Guid)k.Tag) == ds.Id).ToList())
                    {
                        model.Series.Remove(r);
                    }
                    var l = new List<SortedDictionary<DateTime, double>>();
                    int colidx = 0;
                    foreach (var lineseries in res)
                    {
                        var lss = new LineSeries();
                        var ll = new SortedDictionary<DateTime, double>();

                        ds.Color = AvailableColors[colidx];
                        colidx++;

                        lss.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
                        lss.Smooth = ds.Smooth;
                        lss.Color = OxyColor.FromArgb(ds.Color.A, ds.Color.R, ds.Color.G, ds.Color.B);
                        lss.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6);
                        lss.Tag = ds.Id;
                        foreach (var a in lineseries)
                        {
                            lss.Points.Add(new DataPoint(a.Key, a.Value));
                            ll.Add(DateTimeAxis.ToDateTime(a.Key), a.Value);
                        }
                        model.Series.Add(lss);
                        l.Add(ll);
                    }
                }



                model.RefreshPlot(true);
            }
        }
Exemple #5
0
        private void AddDataSet(DataSet ds)
        {


            var ls = new LineSeries();
            
            ds.Color = Colors.Red;
            foreach (Color c in AvailableColors)
            {
                if (!DataSets.Any(k=>k.Color == c))
                {
                    ds.Color = c;
                    break;
                }
                
            }
            ls.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
            ls.Smooth = ds.Smooth;
            ls.Color = OxyColor.FromArgb(ds.Color.A, ds.Color.R,ds.Color.G,ds.Color.B);
            ls.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6);
            ls.Tag = ds.Id;
            ls.Title = ds.Sensor.Description;
            
            // week days


            if (ds.DData != null)
            {
                var da = model.Axes.OfType<DateTimeAxis>().ToList();
                foreach (var d in da)
                    model.Axes.Remove(d);
                if (model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Bottom) == null)
                {
                    firstAxis = new LinearAxis(AxisPosition.Bottom, "");
                    firstAxis.Key = "Bottom";
                    firstAxis.Minimum = ds.DData.Keys.First();
                    firstAxis.Minimum = ds.DData.Keys.Last();
                    firstAxis.MajorGridlineStyle = LineStyle.Solid;
                    firstAxis.MinorGridlineStyle = LineStyle.Dot;
                    firstAxis.MinimumPadding = 0.05;
                    firstAxis.MaximumPadding = 0.1;
                    model.Axes.Add(firstAxis);
                }
            
                foreach (var a in ds.DData)
                {
                    ls.Points.Add(new DataPoint(a.Key, a.Value));
                }
            }
            else
            {
                var res = GetDataSet(ds);
                if (res.Count == 1)
                {
                    foreach (var a in res.First())
                    {
                        ls.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                }
                else
                {
                    var l = new List<SortedDictionary<DateTime, double>>();
                    int colidx=0;
                    foreach (var lineseries in res)
                    {
                        var lss = new LineSeries();
                        var ll = new SortedDictionary<DateTime, double>();
                        ds.Color = AvailableColors[colidx];
                        colidx++;

                        lss.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
                        lss.Smooth = ds.Smooth;
                        lss.Color = OxyColor.FromArgb(ds.Color.A, ds.Color.R, ds.Color.G, ds.Color.B);
                        lss.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6);
                        lss.Tag = ds.Id;
                        foreach (var a in lineseries)
                        {
                            lss.Points.Add(new DataPoint(a.Key, a.Value));
                            ll.Add(DateTimeAxis.ToDateTime(a.Key),a.Value);
                        }
                        model.Series.Add(lss);
                        l.Add(ll);
                    }
                }
            }
            model.Series.Add(ls);
            UpdateDataSet(ds);
            //model.Title = ds.Sensor.Description != null ? ds.Sensor.Description : Title ;
            model.Update();
            ds.Updated -= ds_Updated;
            ds.Updated += ds_Updated;
        
            if (ds.Data!=null)
                ds.Data.CollectionChanged += (e,f) => UpdateDataSet(ds);
            _view.Plot.InvalidatePlot(true);
        }
Exemple #6
0
 public void FitDataSet(DataSet ds)
 {
     if (!ds.RightAxis)
     {
         if (ds.Data == null)
         {
             if (ds.DData != null)
             {
                 var minx = ds.DData.OrderBy(k => k.Key).FirstOrDefault().Key;
                 var maxx = ds.DData.OrderByDescending(k => k.Key).FirstOrDefault().Key;
                 var difx = maxx - minx;
                 var miny = ds.DData.OrderBy(k => k.Value).FirstOrDefault().Value;
                 var maxy = ds.DData.OrderByDescending(k => k.Value).FirstOrDefault().Value;
                 var dify = maxy - miny;
                 var baxis = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Bottom);
                 if (baxis != null)
                     baxis.Zoom(minx - (difx) / 10.0 ,maxx + (difx) / 10.0);
                 var laxis = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Left);
                 if (laxis != null)
                     laxis.Zoom(miny - dify/10.0,maxy + dify / 10.0);
             }
         }
         else
         {
             var minx = DateTimeAxis.ToDouble(ds.Data.OrderBy(k => k.Key).FirstOrDefault().Key);
             var maxx = DateTimeAxis.ToDouble(ds.Data.OrderByDescending(k => k.Key).FirstOrDefault().Key);
             var difx = maxx - minx;
             var miny = ds.Data.OrderBy(k => k.Value).FirstOrDefault().Value;
             var maxy = ds.Data.OrderByDescending(k => k.Value).FirstOrDefault().Value;
             var dify = maxy - miny;
             dateAxis.Zoom(minx - difx / 10.0,maxx + difx / 10.0);
             firstAxis.Zoom(miny - dify / 10.0,maxy + dify / 10.0);
         }
     }
     else
     {
         if (ds.Data == null)
         {
             if (ds.DData != null)
             {
                 var baxis = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Bottom);
                 if (baxis != null)
                     baxis.Zoom(ds.DData.OrderBy(k => k.Key).FirstOrDefault().Key,
                                ds.DData.OrderByDescending(k => k.Key).FirstOrDefault().Key);
                 var raxis = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Right);
                 if (raxis != null)
                     raxis.Zoom(ds.DData.OrderBy(k => k.Value).FirstOrDefault().Value,
                                ds.DData.OrderByDescending(k => k.Value).FirstOrDefault().Value);
             }
         }
         else
         {
             dateAxis.Zoom(DateTimeAxis.ToDouble(ds.Data.OrderBy(k => k.Key).FirstOrDefault().Key),
                           DateTimeAxis.ToDouble(
                               ds.Data.OrderByDescending(k => k.Key).FirstOrDefault().Key));
             var raxis = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Right);
             if (raxis != null)
                 raxis.Zoom(ds.Data.OrderBy(k => k.Value).FirstOrDefault().Value,
                            ds.Data.OrderByDescending(k => k.Value).FirstOrDefault().Value);
         }
     }
     model.Update();
     _view.Plot.InvalidatePlot(true);
 }
Exemple #7
0
        private List<SortedDictionary<double, double>> GetDataSet(DataSet ds)
        {

            var res = new SortedDictionary<double, List<double>>();

            if (ds.Data!=null && Enumerable.Any(ds.Data))
            foreach (var p in ds.Data)
            {
                double day = DateTimeAxis.ToDouble(p.Key);
                double groupDay = day;

                switch (ds.Grouping)
                {            
                    case GroupingOptions.none:
                        groupDay = DateTimeAxis.ToDouble(p.Key);
                        break;
                    case GroupingOptions.minutes:
                        groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour).AddMinutes(p.Key.Minute));
                        break;
                    case GroupingOptions.quarterly:
                        var min = 0;
                        if (p.Key.Minute < 30) min = 15;
                        if (p.Key.Minute < 45) min = 30;
                        if (p.Key.Minute < 60) min = 45;
                        groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour).AddMinutes(min));
                        break;
                    case GroupingOptions.hourly:
                        groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour));
                        break;
                    case GroupingOptions.daily:
                        groupDay = DateTimeAxis.ToDouble(p.Key.Date);
                        break;
                    case GroupingOptions.weekly:
                        groupDay = DateTimeAxis.ToDouble(p.Key.GetDateTimeForDayOfWeek(DayOfWeek.Monday));
                        break;
                    case GroupingOptions.monthly:                        
                        groupDay = DateTimeAxis.ToDouble(p.Key.GetFirstDayOfTheMonth());
                        break;
                    case GroupingOptions.yearly:
                        groupDay = DateTimeAxis.ToDouble(p.Key.GetFirstDayOfTheYear());
                        break;
                }
                
                if (!res.ContainsKey(groupDay)) res[groupDay] = new List<double>();
                res[groupDay].Add(p.Value);
            }
            else if (ds.DData != null)
            {
                return new List<SortedDictionary<double, double>>() { ds.DData };
            }
            SortedDictionary<double, double> r = new SortedDictionary<double, double>();
            switch (ds.GroupingOperation)
            {
                case GroupingOperations.count:
                    r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Count)).ToSortedDictionary(k => k.Key, k => k.Value);                    
                    break;
                case GroupingOperations.maximum:
                    r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Max())).ToSortedDictionary(k => k.Key, k => k.Value);
                    break;
                case GroupingOperations.minimum:
                    r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Min())).ToSortedDictionary(k => k.Key, k => k.Value);
                    break;
                case GroupingOperations.average:
                    r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Average())).ToSortedDictionary(k => k.Key, k => k.Value);
                    break;
                case GroupingOperations.total:
                    r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Sum())).ToSortedDictionary(k => k.Key, k => k.Value);
                    break;                
            }
            SortedDictionary<double, double> f = new SortedDictionary<double, double>();
            switch (ds.FunctionOperation)
            {
                case FunctionOperations.none:
                    f = r;
                    break;
                case FunctionOperations.reduction:
                    {
                        var m = new MathFunctions();
                        var temp = (from n in r select new Point(n.Key, n.Value)).ToList();
                        var euclistx = new List<double>();
                        var euclisty = new List<double>();
                        for (int i = 0; i < temp.Count - 1; i++)
                        {
                            euclistx.Add(Math.Sqrt((temp[i].X - temp[i + 1].X)*(temp[i].X - temp[i + 1].X)));
                            euclisty.Add(Math.Sqrt((temp[i].Y - temp[i + 1].Y)*(temp[i].Y - temp[i + 1].Y)));
                        }
                        var thresholdx = Convert.ToDouble(euclistx.Average());
                        var thresholdy = Convert.ToDouble(euclisty.Average());
                        var dp = m.DouglasPeuckerReduction(temp, 10*thresholdx);
                        f = (from n in dp select new KeyValuePair<double, double>(n.X, n.Y)).ToSortedDictionary(k => k.Key,
                                                                                                          k => k.Value);
                    }
                    break;
                case FunctionOperations.auto:
                    {
                        if (ds.ReducedData == null)
                            ds.ReducedData = mf.CalculateReduction(r, 0.95); ;

                        f = ds.ReducedData;


                        if (ds.AggregatedData == null)
                        {
                            ds.AggregatedData = CalculateAggregate(f);
                        }
                        var actualsize = Math.Max(_view.Plot.ActualWidth - 60, 20);
                        var v = model.Axes.FirstOrDefault(k => k.Position == AxisPosition.Bottom);
                        var points = f.Where(k => k.Key > v.Minimum && k.Key < v.Maximum).Count();

                        if (points > actualsize / 2)
                        {
                            return ds.AggregatedData;
                        }
                    }
                    break;
                case FunctionOperations.periodic:
                    {
                        var first = r.First();
                        var test = DateTimeAxis.ToDouble(new DateTime());
                        var period = DateTimeAxis.ToDouble(new DateTime() + ds.Periodic)-test;
                        var idx = 1.0;
                        var resultlist = new List<SortedDictionary<double, double>>();
                        foreach (var val in r)
                        {
                           
                            if (val.Key - first.Key > period*idx)
                            {
                                resultlist.Add(f.ToSortedDictionary(k=>k.Key,k=>k.Value));
                                while (val.Key - first.Key > period*idx)
                                    idx++;
                                f.Clear();
                            }
                            f.Add(first.Key + ((val.Key - first.Key) - period*(idx-1)),val.Value);
                        }
                        resultlist.Add(f.ToSortedDictionary(k => k.Key, k => k.Value));
                        return resultlist;
                    }
                // FIXME TODO: Unreachable code
                    // break;
            }
            return new List<SortedDictionary<double, double>>() { f };

        }
        private DataSet CreateDataSet()
        {
            var dataSet = new DataSet
            {
                Data = new ConcurrentObservableSortedDictionary<DateTime, double>(), GroupingOperation = GroupingOperations.count
            };
            //var d = new Dictionary<double,int>();
            //foreach (var fs in Poi.InFlow())
            //{
            //    var date = fs.Eta;

            //    if (data.Data.ContainsKey(date))
            //    {
            //        data.Data[date] += 1;
            //    }
            //    else
            //    {
            //        data.Data[date] = 1;
            //    }
            //}

            return dataSet;
        }
Exemple #9
0
        public void OpenDataSetMenu(DataSet ds, SurfaceButton b)
        {
            var menu = new MenuPopupViewModel();
            menu.RelativeElement = b;
            menu.RelativePosition = new Point(0, 0);
            menu.TimeOut = new TimeSpan(0, 0, 0, 5);
            //menu.Point = _view.CreateLayer.TranslatePoint(new Point(0,0),Application.Current.MainWindow);
            menu.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            //menu.DisplayProperty = "ServiceName";
            menu.AutoClose = true;
            var miRemove = menu.AddMenuItem("Remove");
            miRemove.Click += (e, s) =>
                {
                    DataSets.Remove(ds);
                    menu.Close();
                };

            var miFit = menu.AddMenuItem("Fit");
            miFit.Click += (e, s) =>
            {
                FitDataSet(ds);
                menu.Close();
            };

            var miDuplicate = menu.AddMenuItem("Duplicate");
            miDuplicate.Click += (e, s) =>
                {
                    DataSet d = ds.Clone() as DataSet;
                    DataSets.Add(d);
                    menu.Close();
                };

            var miEdit = menu.AddMenuItem("Edit");
            miEdit.Click += (e, s) =>
                {
                    SelectedDataSet = ds;
                    menu.Close();
                    EditDataSet = true;
                };


            var miDraw = menu.AddMenuItem("Draw");
            miDraw.Click += (e, s) =>
            {
                SelectedDataSet = ds;
                menu.Close();
                if (DrawDataSet == false)
                {
                    DrawDataSet = true;
                    // Subscribe to the mouse down event on the line series
                    _view.PreviewMouseLeftButtonDown += _view_PreviewMouseLeftButtonDown;
                    _view.PreviewMouseMove += _view_PreviewMouseMove;
                    _view.PreviewMouseLeftButtonUp += _view_PreviewMouseLeftButtonUp;
                    

                }
                else
                {
                    DrawDataSet = false;
                }
            };
            AppState.Popups.Add(menu);
        }
Exemple #10
0
        private DataSet CreateDataSet()
        {
            var data = new DataSet() { Data = new ConcurrentObservableSortedDictionary<DateTime, double>() };
            //var d = new Dictionary<double,int>();
            foreach (var fs in Poi.InFlow())
            {
                var date = fs.Eta;

                if (data.Data.ContainsKey(date))
                {
                    data.Data[date] += 1;
                }
                else
                {
                    data.Data[date] = 1;
                }
            }

            data.GroupingOperation = GroupingOperations.count;
            return data;
        }
Exemple #11
0
 public async Task PinDataSet(DataSet sc) // REVIEW TODO fix: async added
 {
     if (AppState.Dashboards.ActiveDashboard != null)
     {
         var di = new DashboardItem()
         {
             Title = "Test 2x1",
             GridX = 17,
             GridY = 17,
             GridHeight = 8,
             GridWidth = 8,
             Data = sc,                    
             Dashboard = AppState.Dashboards.ActiveDashboard,
             Config = "Focus Value",
             DataSetId = sc.DataSetId
         };
         di.ViewModel = new DashboardItemViewModel {Data = sc, Item = di};
         AppState.Dashboards.ActiveDashboard.DashboardItems.Add(di);
     }
     await AppState.Dashboards.Save("dashboards.config");
 }
Exemple #12
0
 public void AddSensorData(string sensor, DateTime date, double value, string description = "", bool trigger = true)
 {
     if (!Sensors.ContainsKey(sensor))
     {
         Sensors[sensor] = new DataSet
         {
             Data = new ConcurrentObservableSortedDictionary<DateTime, double>(),
             Sensor = new csEvents.Sensors.Sensor { Description = description, Id = sensor }
         };
         //Sensors.Add(sensor, new DataSet
         //{
         //    Data = new ConcurrentObservableSortedDictionary<DateTime, double>(),
         //    Sensor = new csEvents.Sensors.Sensor { Description = description, Id = sensor }
         //});
     }
     Sensors[sensor].Data[date] = value;
     if (trigger) Sensors[sensor].TriggerUpdated();
 }
Exemple #13
0
 /// <summary>
 ///     Sets the sensor value.
 /// </summary>
 /// <param name="dateTime"></param>
 /// <param name="sensorName"></param>
 /// <param name="sensorValue"></param>
 public void SetSensorValue(DateTime dateTime, string sensorName, double sensorValue)
 {
     if (Sensors == null) Sensors = new SensorSet();
     if (!Sensors.ContainsKey(sensorName)) Sensors[sensorName] = new DataSet { Data = new ConcurrentObservableSortedDictionary<DateTime, double>() };
     Sensors[sensorName].Data[dateTime] = sensorValue;
 }
Exemple #14
0
 /// <summary>
 ///     Shallow clone.
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     var ds = new DataSet
     {
         Sensor = Sensor,
         Smooth = Smooth,
         Grouping = Grouping,
         GroupingOperation = GroupingOperation,
         Data = Data,
         //BooleanData = BooleanData,
         //FloatData = FloatData,
         //StringData = StringData,
         DData = DData,
         RightAxis = RightAxis,
         Color = Color
     };
     return ds;
 }