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)); }
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); }