mirror of
https://github.com/ckaczor/WeatherService.git
synced 2026-01-23 17:26:15 -05:00
More cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Runtime.Serialization;
|
||||
using OneWireAPI;
|
||||
using System.Runtime.Serialization;
|
||||
using WeatherService.Values;
|
||||
|
||||
namespace WeatherService.Devices
|
||||
@@ -7,26 +7,17 @@ namespace WeatherService.Devices
|
||||
[DataContract]
|
||||
public class TemperatureDevice : DeviceBase
|
||||
{
|
||||
#region Member variables
|
||||
|
||||
private readonly Value _temperatureValue; // Cached temperature
|
||||
private readonly Value _temperatureValue;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public TemperatureDevice(Session session, owDevice device) : base(session, device, DeviceType.Temperature)
|
||||
public TemperatureDevice(Session session, Device device)
|
||||
: base(session, device, DeviceType.Temperature)
|
||||
{
|
||||
// Create the new value object
|
||||
_temperatureValue = new Value(WeatherValueType.Temperature, this);
|
||||
|
||||
_valueList.Add(WeatherValueType.Temperature, _temperatureValue);
|
||||
Values.Add(WeatherValueType.Temperature, _temperatureValue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal methods
|
||||
|
||||
internal override void RefreshCache()
|
||||
{
|
||||
// Read the current temperature
|
||||
@@ -38,12 +29,10 @@ namespace WeatherService.Devices
|
||||
internal double ReadTemperature()
|
||||
{
|
||||
// Cast the device to its specific type
|
||||
owDeviceFamily10 temperatureDevice = (owDeviceFamily10) _device;
|
||||
var temperatureDevice = (DeviceFamily10) OneWireDevice;
|
||||
|
||||
// Return the temperature from the device
|
||||
return temperatureDevice.GetTemperature();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user