コード例 #1
0
        public HumidityPage()
        {
            Model = new HumidityModel
            {
                IsSupported = HumiditySensor.IsSupported,
                SensorCount = HumiditySensor.Count
            };

            InitializeComponent();

            if (Model.IsSupported)
            {
                Humidity              = new HumiditySensor();
                Humidity.DataUpdated += Humidity_DataUpdated;

                canvas.Series = new List <Series>()
                {
                    new Series()
                    {
                        Color         = SKColors.Red,
                        Name          = "Humidity",
                        FormattedText = "Humidity={0}",
                    },
                };
            }
        }
コード例 #2
0
 public static HumidityViewModel MapFromModel(HumidityModel model)
 {
     return(new HumidityViewModel
     {
         Humidity = model.Humidity,
         Location = model.Location,
         Date = DateTime.Parse(model.Date, null, System.Globalization.DateTimeStyles.RoundtripKind)
     });
 }
コード例 #3
0
        public void StartTransfer()
        {
            TemperatureModel.ResetAllAxes();
            HumidityModel.ResetAllAxes();
            PressureModel.ResetAllAxes();

            if (_requestTimer == null)
            {
                _requestTimer          = new Timer(_dataService.GetConfigurationInstance().SampleTime);
                _requestTimer.Elapsed += new ElapsedEventHandler(RequestTimerElaped);
                _requestTimer.Enabled  = true;
            }
        }
コード例 #4
0
        public ParseInputLogFile()
        {
            ReferenceValuesModel referenceValuesModel = new ReferenceValuesModel
            {
                ThermometerReferenceValue = 70.0m,
                HumidityReferenceValue    = 45.0m,
                MonoxideReferenceValue    = 6
            };

            ThermometerModel thermometerModel = new ThermometerModel
            {
                Name     = "temp-1",
                Readings = new List <DecimalReadingModel> {
                    new DecimalReadingModel {
                        Timestamp = DateTime.Parse("2007-04-05T22:00"), Value = 72.4m
                    }
                }
            };

            HumidityModel humidityModel = new HumidityModel
            {
                Name     = "hum-1",
                Readings = new List <DecimalReadingModel> {
                    new DecimalReadingModel {
                        Timestamp = DateTime.Parse("2007-04-05T22:04"), Value = 45.2m
                    }
                }
            };

            MonoxideModel monoxideModel = new MonoxideModel
            {
                Name     = "mon-1",
                Readings = new List <IntegerReadingModel> {
                    new IntegerReadingModel {
                        Timestamp = DateTime.Parse("2007-04-05T22:04"), Value = 5
                    }
                }
            };

            sensorLogModel.ReferenceValues = referenceValuesModel;
            sensorLogModel.ThermometerReadings.Add(thermometerModel);
            sensorLogModel.HumidityReadings.Add(humidityModel);
            sensorLogModel.MonoxideReadings.Add(monoxideModel);
        }
コード例 #5
0
        /// <summary>
        /// Generates a sensor log model from the sensor log input text file
        /// </summary>
        /// <param name="logContentsStr">The sensor log input text file</param>
        /// <exception cref="ArgumentException">logContentStr is null or whitespace</exception>
        /// <exception cref="NotImplementedException">Invalid record type is entered</exception>
        /// <returns>The sensor log model representing the sensors and reading log records</returns>
        private SensorLogModel ParseInputLogFile(string logContentsStr)
        {
            if (string.IsNullOrWhiteSpace(logContentsStr))
            {
                _logger.LogError($"{Messages.NullWhitespaceString} (Parameter '{nameof(logContentsStr)}')");
                throw new ArgumentException(Messages.NullWhitespaceString, nameof(logContentsStr));
            }

            SensorLogModel model = new SensorLogModel();

            string[] input          = logContentsStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Regex    timeValueRegex = new Regex("[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(2[0-3]|[01][0-9]):[0-5][0-9]");

            for (int i = 0; i < input.Length; i++)
            {
                string[] line = input[i].Split(' ');

                switch (line[0])
                {
                case "reference":
                    model.ReferenceValues = HandleReferenceValuesLogRecord(line[1], line[2], line[3]);
                    break;

                case "thermometer":
                    ThermometerModel thermometerModel = new ThermometerModel
                    {
                        Name = line[1]
                    };

                    while (true)
                    {
                        i++;
                        line = input[i].Split(' ');

                        if (timeValueRegex.IsMatch(line[0]))
                        {
                            DecimalReadingModel readingModel = HandleDecimalReading(line[0], line[1]);
                            thermometerModel.Readings.Add(readingModel);
                        }
                        else
                        {
                            i--;
                            break;
                        }

                        if (i + 1 >= input.Length)
                        {
                            break;
                        }
                    }

                    model.ThermometerReadings.Add(thermometerModel);
                    break;

                case "humidity":
                    HumidityModel humidityModel = new HumidityModel
                    {
                        Name = line[1]
                    };

                    while (true)
                    {
                        i++;
                        line = input[i].Split(' ');

                        if (timeValueRegex.IsMatch(line[0]))
                        {
                            DecimalReadingModel readingModel = HandleDecimalReading(line[0], line[1]);
                            humidityModel.Readings.Add(readingModel);
                        }
                        else
                        {
                            i--;
                            break;
                        }

                        if (i + 1 >= input.Length)
                        {
                            break;
                        }
                    }

                    model.HumidityReadings.Add(humidityModel);
                    break;

                case "monoxide":
                    MonoxideModel monoxideModel = new MonoxideModel
                    {
                        Name = line[1]
                    };

                    while (true)
                    {
                        i++;
                        line = input[i].Split(' ');

                        if (timeValueRegex.IsMatch(line[0]))
                        {
                            IntegerReadingModel readingModel = HandleIntegerReading(line[0], line[1]);
                            monoxideModel.Readings.Add(readingModel);
                        }
                        else
                        {
                            i--;
                            break;
                        }

                        if (i + 1 >= input.Length)
                        {
                            break;
                        }
                    }

                    model.MonoxideReadings.Add(monoxideModel);
                    break;

                default:
                    _logger.LogError($"Sensor type {line[0]} has not been implemented yet.");
                    throw new NotImplementedException($"Sensor type {line[0]} has not been implemented yet.");
                }
            }

            return(model);
        }
コード例 #6
0
        private void initCampaignDataSources()
        {
            #region Assign sensor model references
            accelerometerModel = new AccelerometerModel
            {
                IsSupported = Accelerometer.IsSupported,
                SensorCount = Accelerometer.Count
            };
            gravityModel = new GravityModel
            {
                IsSupported = GravitySensor.IsSupported,
                SensorCount = GravitySensor.Count
            };
            gyroscopeModel = new GyroscopeModel
            {
                IsSupported = Gyroscope.IsSupported,
                SensorCount = Gyroscope.Count
            };
            hRMModel = new HRMModel
            {
                IsSupported = HeartRateMonitor.IsSupported,
                SensorCount = HeartRateMonitor.Count
            };
            humidityModel = new HumidityModel
            {
                IsSupported = HumiditySensor.IsSupported,
                SensorCount = HumiditySensor.Count
            };
            lightModel = new LightModel
            {
                IsSupported = LightSensor.IsSupported,
                SensorCount = LightSensor.Count
            };
            linearAccelerationModel = new LinearAccelerationModel
            {
                IsSupported = LinearAccelerationSensor.IsSupported,
                SensorCount = LinearAccelerationSensor.Count
            };
            magnetometerModel = new MagnetometerModel
            {
                IsSupported = Magnetometer.IsSupported,
                SensorCount = Magnetometer.Count
            };
            orientationModel = new OrientationModel
            {
                IsSupported = OrientationSensor.IsSupported,
                SensorCount = OrientationSensor.Count
            };
            pressureModel = new PressureModel
            {
                IsSupported = PressureSensor.IsSupported,
                SensorCount = PressureSensor.Count
            };
            proximityModel = new ProximityModel
            {
                IsSupported = ProximitySensor.IsSupported,
                SensorCount = ProximitySensor.Count
            };
            temperatureModel = new TemperatureModel
            {
                IsSupported = TemperatureSensor.IsSupported,
                SensorCount = TemperatureSensor.Count
            };
            ultravioletModel = new UltravioletModel
            {
                IsSupported = UltravioletSensor.IsSupported,
                SensorCount = UltravioletSensor.Count
            };
            #endregion

            #region Assign sensor references and sensor measurement event handlers
            if (accelerometerModel.IsSupported)
            {
                accelerometer                  = new Accelerometer();
                accelerometer.PausePolicy      = SensorPausePolicy.None;
                accelerometer.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                accelerometer.DataUpdated     += storeAccelerometerDataCallback;
                sensorMap[Tools.ACCELEROMETER] = accelerometer;
            }
            if (gravityModel.IsSupported)
            {
                gravity                  = new GravitySensor();
                gravity.PausePolicy      = SensorPausePolicy.None;
                gravity.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                gravity.DataUpdated     += storeGravitySensorDataCallback;
                sensorMap[Tools.GRAVITY] = gravity;
            }
            if (gyroscopeModel.IsSupported)
            {
                gyroscope                  = new Gyroscope();
                gyroscope.PausePolicy      = SensorPausePolicy.None;
                gyroscope.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                gyroscope.DataUpdated     += storeGyroscopeDataCallback;
                sensorMap[Tools.GYROSCOPE] = gyroscope;
            }
            if (hRMModel.IsSupported)
            {
                hRM                  = new HeartRateMonitor();
                hRM.PausePolicy      = SensorPausePolicy.None;
                hRM.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                hRM.DataUpdated     += storeHeartRateMonitorDataCallback;
                sensorMap[Tools.HRM] = hRM;
            }
            if (humidityModel.IsSupported)
            {
                humidity                  = new HumiditySensor();
                humidity.PausePolicy      = SensorPausePolicy.None;
                humidity.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                humidity.DataUpdated     += storeHumiditySensorDataCallback;
                sensorMap[Tools.HUMIDITY] = humidity;
            }
            if (lightModel.IsSupported)
            {
                light                  = new LightSensor();
                light.PausePolicy      = SensorPausePolicy.None;
                light.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                light.DataUpdated     += storeLightSensorDataCallback;
                sensorMap[Tools.LIGHT] = light;
            }
            if (linearAccelerationModel.IsSupported)
            {
                linearAcceleration                  = new LinearAccelerationSensor();
                linearAcceleration.PausePolicy      = SensorPausePolicy.None;
                linearAcceleration.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                linearAcceleration.DataUpdated     += storeLinearAccelerationSensorDataCallback;
                sensorMap[Tools.LINEARACCELERATION] = linearAcceleration;
            }
            if (magnetometerModel.IsSupported)
            {
                magnetometer                  = new Magnetometer();
                magnetometer.PausePolicy      = SensorPausePolicy.None;
                magnetometer.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                magnetometer.DataUpdated     += storeMagnetometerDataCallback;
                sensorMap[Tools.MAGNETOMETER] = magnetometer;
            }
            if (orientationModel.IsSupported)
            {
                orientation                  = new OrientationSensor();
                orientation.PausePolicy      = SensorPausePolicy.None;
                orientation.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                orientation.DataUpdated     += storeOrientationSensorDataCallback;
                sensorMap[Tools.ORIENTATION] = orientation;
            }
            if (pressureModel.IsSupported)
            {
                pressure                  = new PressureSensor();
                pressure.PausePolicy      = SensorPausePolicy.None;
                pressure.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                pressure.DataUpdated     += storePressureSensorDataCallback;
                sensorMap[Tools.PRESSURE] = pressure;
            }
            if (proximityModel.IsSupported)
            {
                proximity                  = new ProximitySensor();
                proximity.PausePolicy      = SensorPausePolicy.None;
                proximity.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                proximity.DataUpdated     += storeProximitySensorDataCallback;
                sensorMap[Tools.PROXIMITY] = proximity;
            }
            if (temperatureModel.IsSupported)
            {
                temperature                  = new TemperatureSensor();
                temperature.PausePolicy      = SensorPausePolicy.None;
                temperature.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                temperature.DataUpdated     += storeTemperatureSensorDataCallback;
                sensorMap[Tools.TEMPERATURE] = temperature;
            }
            if (ultravioletModel.IsSupported)
            {
                ultraviolet                  = new UltravioletSensor();
                ultraviolet.PausePolicy      = SensorPausePolicy.None;
                ultraviolet.Interval         = Tools.DEFAULT_SENSOR_SAMPLING_INTERVAL;
                ultraviolet.DataUpdated     += storeUltravioletSensorDataCallback;
                sensorMap[Tools.ULTRAVIOLET] = ultraviolet;
            }
            #endregion

            loadCampaignSettings();
        }