Пример #1
0
        public String GenerateHumidityData(int deviceNumber, int roomNumber)
        {
            float modifier = 1.0F;

            if (DeviceSendingDetails.FailureConditions.Any(
                    device => device.FailedDeviceId == deviceNumber && device.SensorType == SensorTypes.Humidity))
            {
                var deviceDetails =
                    DeviceSendingDetails.FailureConditions.First(device => device.FailedDeviceId == deviceNumber);
                modifier += deviceDetails.FailedDeviceGradient;
            }

            var humidity = _rand.Next((int)((DeviceSendingDetails.HumidityMin * modifier) * 100),
                                      (int)((DeviceSendingDetails.HumidityMax * modifier) * 100)) / 100;

            var humidityData = new HumidityData()
            {
                Deviceid   = "humidity" + deviceNumber,
                Humidity   = (humidity),
                Timestamp  = DateTime.UtcNow,
                RoomNumber = roomNumber
            };

            return(JsonConvert.SerializeObject(humidityData));
        }
Пример #2
0
        public String GenerateHumidityData(int deviceNumber, int roomNumber)
        {
            float modifier = 1.0F;
            if (DeviceSendingDetails.FailureConditions.Any(
                    device => device.FailedDeviceId == deviceNumber && device.SensorType == SensorTypes.Humidity))
            {
                var deviceDetails =
                    DeviceSendingDetails.FailureConditions.First(device => device.FailedDeviceId == deviceNumber);
                modifier += deviceDetails.FailedDeviceGradient;
            }

            var humidity = _rand.Next((int)((DeviceSendingDetails.HumidityMin * modifier) * 100),
                    (int)((DeviceSendingDetails.HumidityMax * modifier) * 100)) / 100;

            var humidityData = new HumidityData()
            {
                Deviceid = "humidity" + deviceNumber,
                Humidity = (humidity),
                Timestamp = DateTime.UtcNow,
                RoomNumber = roomNumber
            };

            return JsonConvert.SerializeObject(humidityData);
        }