internal static void DoDeviceOperation(this ZWaveDevice device, Action operation) { Func <int> wrappedOperation = () => { operation(); return(0); }; device.DoDeviceOperation(wrappedOperation); }
internal static TResult DoDeviceOperation <TResult>(this ZWaveDevice device, Func <TResult> operation) { var wasConnected = device.IsConnected; var network = (ZWaveNetwork)device.Network; var workQueue = network.WorkQueue; var retries = wasConnected == true ? InitiallyConnectedRetries : InitiallyDisconnectedRetries; var result = default(TResult); var work = new WorkQueueItem(() => { result = operation(); }, retries, typeof(ControlThink.ZWave.ZWaveException)); workQueue.Add(work); var workResult = work.Result; if (workResult.Success) { device.IsConnected = true; if (wasConnected != true) { var @event = DeviceEvent.Found(device, null); device.AddEvent(@event); } return(result); } device.IsConnected = false; if (wasConnected == true) { var @event = DeviceEvent.Lost(device, null); device.AddEvent(@event); } var exception = workResult.Exception; if (exception is ControlThink.ZWave.DeviceNotRespondingException) { throw new DeviceNotRespondingException(device, exception); } if (exception is ControlThink.ZWave.CommandTimeoutException) { throw new CommandTimedOutException(device, exception); } throw new HomeAutomationException("Unexpected Z-Wave error: " + exception.Message, exception); }
public override Device AddDevice() { var backingDevice = ZWaveController.AddDevice(); if (backingDevice == null) return null; //TODO: throw exception? var device = new ZWaveDevice(this, backingDevice); Devices.Add(device); return device; }
public override Device AddDevice() { var backingDevice = ZWaveController.AddDevice(); if (backingDevice == null) { return(null); //TODO: throw exception? } var device = new ZWaveDevice(this, backingDevice); Devices.Add(device); return(device); }
public ZWaveSetpointCollection(ZWaveDevice device) { _device = device; _thermostat = device.BackingObject as GeneralThermostatV2; _setpoints = new Dictionary <ThermostatSetpointType, ITemperature>(); if (_thermostat == null) { return; } SetCallbacks(); }
public ZWaveSetpointCollection(ZWaveDevice device) { _device = device; _thermostat = device.BackingObject as GeneralThermostatV2; _setpoints = new Dictionary<ThermostatSetpointType, ITemperature>(); if (_thermostat == null) { return; } SetCallbacks(); }
public ZWaveThermostatFan(ZWaveDevice device) { _device = device; _thermostat = device.BackingObject as GeneralThermostatV2; SupportedModes = new List<ThermostatFanMode>(); if (_thermostat == null) { return; } SetCallbacks(); }
public ZWaveThermostatFan(ZWaveDevice device) { _device = device; _thermostat = device.BackingObject as GeneralThermostatV2; SupportedModes = new List <ThermostatFanMode>(); if (_thermostat == null) { return; } SetCallbacks(); }
public ZWaveThermostat(ZWaveDevice device) { _device = device; _thermostat = device.BackingObject as GeneralThermostatV2; Core = new ZWaveThermostatCore(device); Fan = new ZWaveThermostatFan(device); _setpoints = new ZWaveSetpointCollection(device); if (_thermostat == null) { return; } SetCallbacks(); }
public override Device RemoveDevice() { var removedDevice = ZWaveController.RemoveDevice(); Device result; if (Devices.Contains(removedDevice)) { result = Devices[removedDevice]; Devices.Remove(result); } else { result = new ZWaveDevice(null, removedDevice); } return(result); }
public override Device RemoveDevice() { var removedDevice = ZWaveController.RemoveDevice(); Device result; if (Devices.Contains(removedDevice)) { result = Devices[removedDevice]; Devices.Remove(result); } else { result = new ZWaveDevice(null, removedDevice); } return result; }
public ZWaveToggleSwitch(ZWaveDevice device) { _device = device; }
public ZWaveBinarySensor(ZWaveDevice device) { _device = device; }
public ZWaveTemperatureSensor(ZWaveDevice device) { _device = device; }
public ZWaveDimmerSwitch(ZWaveDevice device) { _device = device; }