public static string Describe <TMeasurement>(this IMultilevelSensorState <TMeasurement> state, TimeZoneInfo timeZone = null) where TMeasurement : IMeasurement { var result = new StringBuilder(); if (state == null) { return(result.ToString()); } var value = state.Value; if (value != null) { result.Append(value); } var timestamp = state.TimeStamp; if (timestamp != null) { result.Append(" (at "); result.AppendDateTime(state.TimeStamp, timeZone); result.Append(")"); } return(result.ToString()); }
public static ReadOnlyMultilevelSensorState <TMeasurement> CopyFrom(IMultilevelSensorState <TMeasurement> source) { var result = new ReadOnlyMultilevelSensorState <TMeasurement> { Value = source.Value, TimeStamp = source.TimeStamp }; return(result); }
public static void AssertMultilevelSensorEqual <TMeasurement>(IMultilevelSensorState <TMeasurement> one, IMultilevelSensorState <TMeasurement> two) where TMeasurement : IMeasurement { if (one == null && two == null) { return; } AssertHelperHelper(one, two); Assert.That(one.Value.Format(), Is.EqualTo(two.Value.Format())); Assert.That(one.TimeStamp, Is.EqualTo(two.TimeStamp)); }
public static XElement ToXElement <TMeasurement>(this IMultilevelSensorState <TMeasurement> state, string nodeName = "MultilevelSensor") where TMeasurement : IMeasurement { var result = new XElement(nodeName); if (state.Value != null) { result.Add(new XAttribute("Value", state.Value.Format())); } if (state.TimeStamp != null) { result.Add(new XAttribute("TimeStamp", state.TimeStamp)); } return(result); }
public ReadOnlyDeviceState(string name, string address, ILocation location, INetwork network, bool?isConnected, DeviceType type, string currentAction, IBinarySwitchState toggleSwitchState, IMultilevelSwitchState dimmerSwitchState, IColorSwitchState colorSwitchState, IBinarySensorState binarySensorState, IMultilevelSensorState <IPower> powerSensorState, IMultilevelSensorState <ITemperature> temperatureSensorState, IMultilevelSensorState <IHumidity> humiditySensorState, IMultilevelSensorState <IIlluminance> illuminanceSensorState, IThermostatState thermostatState, IKeypadState keypadState) { Name = name; Address = address; Location = location; NetworkState = network; IsConnected = isConnected; Type = type; CurrentAction = currentAction; BinarySwitchState = toggleSwitchState; MultilevelSwitchState = dimmerSwitchState; ColorSwitchState = colorSwitchState; BinarySensorState = binarySensorState; PowerSensorState = powerSensorState; TemperatureSensorState = temperatureSensorState; HumiditySensorState = humiditySensorState; IlluminanceSensorState = illuminanceSensorState; ThermostatState = thermostatState; KeypadState = keypadState; }
public ReadOnlyDeviceState(string name, string address, ILocation location, INetwork network, bool? isConnected, DeviceType type, string currentAction, IBinarySwitchState toggleSwitchState, IMultilevelSwitchState dimmerSwitchState, IColorSwitchState colorSwitchState, IBinarySensorState binarySensorState, IMultilevelSensorState<IPower> powerSensorState, IMultilevelSensorState<ITemperature> temperatureSensorState, IMultilevelSensorState<IHumidity> humiditySensorState, IMultilevelSensorState<IIlluminance> illuminanceSensorState, IThermostatState thermostatState, IKeypadState keypadState) { Name = name; Address = address; Location = location; NetworkState = network; IsConnected = isConnected; Type = type; CurrentAction = currentAction; BinarySwitchState = toggleSwitchState; MultilevelSwitchState = dimmerSwitchState; ColorSwitchState = colorSwitchState; BinarySensorState = binarySensorState; PowerSensorState = powerSensorState; TemperatureSensorState = temperatureSensorState; HumiditySensorState = humiditySensorState; IlluminanceSensorState = illuminanceSensorState; ThermostatState = thermostatState; KeypadState = keypadState; }
public void Update(IMultilevelSensorState <TMeasurement> state) { Value = state.Value; TimeStamp = state.TimeStamp; }
public static ReadOnlyMultilevelSensorState <TMeasurement> Copy <TMeasurement>( this IMultilevelSensorState <TMeasurement> state) where TMeasurement : IMeasurement { return(ReadOnlyMultilevelSensorState <TMeasurement> .CopyFrom(state)); }