public static ApplicationSensorReading ConvertToApplicationSensorReading(this IDeviceSensorReading sensorReading, ApplicationSensorReadingSource source) => new ApplicationSensorReading()
 {
     Temperature           = sensorReading.Temperature,
     IsCritical            = sensorReading.IsCritical,
     IsAboveUpperThreshold = sensorReading.IsAboveUpperThreshold,
     IsBelowLowerThreshold = sensorReading.IsBelowLowerThreshold,
     Source       = source,
     TimestampUtc = sensorReading.TimestampUtc
 };
Exemplo n.º 2
0
        public async Task <IApplicationSensorReading> GetSensorReading()
        {
            IApplicationSensorReading returnValue = null;

            try
            {
                if (this.Device != null && this.Device.IsInitialized)
                {
                    IDeviceSensorReading sensorReading = (await this.Device.ReadSensor());
                    returnValue = sensorReading.ConvertToApplicationSensorReading(ApplicationSensorReadingSource.Device);
                }
            }
            catch (Exception ex)
            {
                this.EventAggregator.GetEvent <Events.DebugEvent>().Publish(new DebugEventArgs(ex));
            }

            return(returnValue);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Converts the temperature in an instance of IDeviceSensorReading
 /// from Celsius to Fahrenheit.
 /// </summary>
 /// <param name="sensorReading">An instance of IDeviceSensorReading.</param>
 /// <returns>Returns the temperature in Fahrenheit.</returns>
 public static float ToFahrenheit(this IDeviceSensorReading sensorReading) => Temperature.ConvertToFahrenheit(sensorReading.Temperature);