public EditSensorViewModel(SensorDBItem sensor, ProbeDBItem probe)
        {
            if (sensor == null)
                throw new ArgumentNullException("sensor", "sensor is null.");
            if (probe == null)
                throw new ArgumentNullException("probe", "probe is null.");

            _probe = probe;
            _sensor = sensor;
            _availableIndexes = CalculateIndexes();
            SensorID = _sensor.SensorId == -1 ? _availableIndexes.FirstOrDefault() : _sensor.SensorId;
            SensorIndex = _sensor.SensorIndex;
            Name = sensor.Name;
            ActualPosition = sensor.ActualPosition;
            _view = new EditSensor();
            _view.DataContext = this;
            Ok = new Command((x) => OkAction(), (x) => true);
            Cancel = new Command((x) => CancelAction(), (x) => true);
        }
示例#2
0
 private void AddProbeAction()
 {
     var p = new ProbeDBItem();
     p.ИмяЗонда = "Новый зонд";
     EditNodeViewModel vm = new EditNodeViewModel(p);
     vm.Show();
     if (vm.Result == EditNodeResult.Ok)
     {
         CurrentRoad.Probes.Add(p);
         CurrentProbe = p;
     }
 }
示例#3
0
        private void FillTestDB()
        {
            var r1 = new RoadDBItem { Наименование = "Ростов-Краснодар" };

            var p1 = new ProbeDBItem { ИмяЗонда = "Зонд 1" };
            p1.Sensors.Add(new SensorDBItem { SensorId = 331, SensorIndex = 1, Name = "т.б.", ActualPosition = -120 });

            var s2 = new SensorDBItem { SensorId = 332, SensorIndex = 2, Name = "гр.", ActualPosition = -32 };
            s2.History.Add(new SensorDBHistory { Sensor1Value = 9578, Sensor2Value = 7562, Temperature = 23, Position = 897.32d, TimeStamp = DateTime.Now.AddMonths(-1) });
            s2.History.Add(new SensorDBHistory { Sensor1Value = 10780, Sensor2Value = 9578, Temperature = 12, Position = 898.32d, TimeStamp = DateTime.Now.AddMonths(-2) });
            s2.History.Add(new SensorDBHistory { Sensor1Value = 13890, Sensor2Value = 11234, Temperature = 17, Position = 899.32d, TimeStamp = DateTime.Now.AddMonths(-3) });
            p1.Sensors.Add(s2);

            r1.Probes.Add(p1);
            r1.Probes.Add(new ProbeDBItem { ИмяЗонда = "Зонд 2" });

            var r2 = new RoadDBItem { Наименование = "Ростов-Таганрог" };
            r2.Probes.Add(new ProbeDBItem { ИмяЗонда = "Зонд 1" });
            r2.Probes.Add(new ProbeDBItem { ИмяЗонда = "Зонд 2" });
            r2.Probes.Add(new ProbeDBItem { ИмяЗонда = "Зонд 3" });
            r2.Probes.Add(new ProbeDBItem { ИмяЗонда = "Зонд 4" });

            _DataBaseManager.DataBase.Roads.Add(r1);
            _DataBaseManager.DataBase.Roads.Add(r2);           
        }
示例#4
0
 public ProbeViewModel(ProbeDBItem model)
 {
     _Model = model;
 }
示例#5
0
        private void AddRoadAction()
        {
            //var r = new StationDBItem();
            //r.Наименование = "Новый пункт передачи данных";
            //EditNodeViewModel vm = new EditNodeViewModel(r);
            //vm.Show();
            //if (vm.Result == EditNodeResult.Ok)
            //{
            //    _DataBaseManager.DataBase.Roads.Add(r);
            //    CurrentRoad = r;
            //}

            var v = new RoadPeakerViewModel();
            v.Show();
            if (v.AddNewRoad)
            {
                RoadDBItem road = DataBaseManager.DataBase.Roads.SingleOrDefault(r => r.Идентификатор == v.SelectedStation.stationId);
                if (road == null)
                {
                    road = new RoadDBItem() { Идентификатор = v.SelectedStation.stationId };
                    DataBaseManager.DataBase.Roads.Add(road);
                }
                road.Наименование = v.SelectedStation.stationName;

                foreach (var jProbe in v.SelectedStation.probeStatuses)
                {
                    ProbeDBItem probe = road.Probes.SingleOrDefault(p => p.Идентификатор == jProbe.probeId);
                    if (probe == null)
                    {
                        probe = new ProbeDBItem() { Идентификатор = jProbe.probeId };
                        road.Probes.Add(probe);
                    }
                    probe.ИмяЗонда = string.Format("Зонд: {0}", jProbe.probeId, jProbe.LastMeasureDate);
                }

                CurrentRoad = road;
            }
        }