示例#1
0
        public List <DataSensorModel> GetUserDevices(string deviceId = null)
        {
            var result  = new List <DataSensorModel>();
            var devices = !string.IsNullOrEmpty(deviceId) ? _devicessRepository.GetDevicesByEspId(deviceId) : _devicessRepository.GetAllActiveDevices();

            //var devices = _devicessRepository.GetAllActiveDevices();
            foreach (var s in devices)
            {
                var data = _measurementsRepository.CurrentMeasurementsForDevice(s.DeviceId);
                result.Add(new DataSensorModel()
                {
                    SensorId              = s.DeviceId,
                    SensorDescription     = s.Description,
                    SensorDescritionExtra = s.ExtraDescription,
                    SensorName            = s.DeviceName,
                    Measurements          = data == null ? new SensorMeasurementModel() : new SensorMeasurementModel()
                    {
                        CellVoltage       = data.CellVoltage,
                        HeaterHumidity    = data.HeaterHumidity,
                        HeaterTemperature = data.HeaterTemperature,
                        Humidity          = data.Humidity,
                        Pm10        = data.Pm10,
                        Pm25        = data.Pm25,
                        Pressure    = data.Pressure,
                        Temperature = data.Temperature,
                        WifiRssi    = data.WifiRssi,
                        InsertDate  = data.InsertDateTime
                    }
                });
            }
            return(result);
        }
示例#2
0
        public SensorMeasurementModel CurrentMeasurementsForDevice(Guid deviceId)
        {
            var data = _measurementsRepository.CurrentMeasurementsForDevice(deviceId);

            if (data == null)
            {
                return(null);
            }
            return(new SensorMeasurementModel()
            {
                CellVoltage = data.CellVoltage,
                HeaterHumidity = data.HeaterHumidity,
                HeaterTemperature = data.HeaterTemperature,
                Humidity = data.Humidity,
                Pm10 = data.Pm10,
                Pm25 = data.Pm25,
                Pressure = data.Pressure,
                Temperature = data.Temperature,
                WifiRssi = data.WifiRssi,
                InsertDate = data.InsertDateTime
            });
        }