Exemplo n.º 1
0
        public MeassuresViewModel(int sensorID, int s1, int s2, SensorsDB db)
        {
            if (db == null)
            {
                MeassureVisibility = Visibility.Visible;
                return;
            }

            MeassureVisibility = Visibility.Visible;

            var sensor = db.Sensors.SingleOrDefault(s => s.SensorAddress == sensorID);
            if (sensor == null)
                return;

            MeassureVisibility = Visibility.Hidden;
            var pts = sensor.Points.OrderBy(p => p.Position).ToList();
            List<double> s1ps = new List<double>();
            List<double> s2ps = new List<double>();

            for (int i = 1; i < pts.Count; i++)
            {
                if (pts[i].Sensor1 < s1 & pts[i - 1].Sensor1 > s1 |
                    pts[i].Sensor1 > s1 & pts[i - 1].Sensor1 < s1)
                    s1ps.Add(CountPosition(
                        pts[i - 1].Sensor1,
                        pts[i].Sensor1,
                        pts[i - 1].Position,
                        pts[i].Position,
                        s1));

                if (pts[i].Sensor2 < s2 & pts[i - 1].Sensor2 > s2 |
                    pts[i].Sensor2 > s2 & pts[i - 1].Sensor2 < s2)
                    s2ps.Add(CountPosition(
                        pts[i - 1].Sensor2,
                        pts[i].Sensor2,
                        pts[i - 1].Position,
                        pts[i].Position,
                        s2));
            }
            S1Points = s1ps;
            S2Points = s2ps;
        }
Exemplo n.º 2
0
        private void OpenSensorDBAction()
        {
            Microsoft.Win32.OpenFileDialog opDlg = new Microsoft.Win32.OpenFileDialog();
            opDlg.DefaultExt = ".sndbml";
            opDlg.Filter = "Файл базы данных тарирования (.sndbml)|*.sndbml";
            if (opDlg.ShowDialog() == true)
            {
                XmlSerializer s = new XmlSerializer(typeof(SensorsDB));

                using (FileStream fs = new FileStream(opDlg.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    _SensorsDB = (SensorsDB)s.Deserialize(fs);
                }
            }
        }