private IComponent ParseMotionDetector(XElement element) { IBinaryInput input = Parser.ParseBinaryInput(element.GetMandatorySingleChildElementOrFromContainer("Input")); return(new MotionDetector( new ComponentId(element.GetMandatoryStringFromAttribute("id")), new PortBasedMotionDetectorEndpoint(input), Controller.ServiceLocator.GetService <ISchedulerService>())); }
public RollerShutterButtons(string id, IBinaryInput upInput, IBinaryInput downInput, IHttpRequestController httpRequestController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpRequestController, notificationHandler) { if (upInput == null) throw new ArgumentNullException(nameof(upInput)); if (downInput == null) throw new ArgumentNullException(nameof(downInput)); Up = new Button(id + "-up", upInput, httpRequestController, notificationHandler, timer); Down = new Button(id + "-down", downInput, httpRequestController, notificationHandler, timer); }
public BinaryInputStateCondition(IBinaryInput input, BinaryState state) { if (input == null) { throw new ArgumentNullException(nameof(input)); } WithExpression(() => input.Read() == state); }
public Button(string id, IBinaryInput input, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpApiController, notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (input == null) throw new ArgumentNullException(nameof(input)); timer.Tick += CheckForTimeout; input.StateChanged += HandleInputStateChanged; }
public PortBasedMotionDetectorAdapter(IBinaryInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += DispatchEvents; }
public PortBasedButtonAdapter(IBinaryInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += ForwardState; }
public InterruptMonitor(IBinaryInput pin) { if (pin == null) { throw new ArgumentNullException(nameof(pin)); } _pin = pin; }
public PortBasedButtonEndpoint(IBinaryInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += DispatchState; }
private IComponent ParseButton(XElement element) { IBinaryInput input = Parser.ParseBinaryInput(element.GetMandatorySingleChildElementOrFromContainer("Input")); return(new Button( new ComponentId(element.GetMandatoryStringFromAttribute("id")), new PortBasedButtonEndpoint(input), Controller.Timer)); }
public static IBinaryInput WithInvertedState(this IBinaryInput binaryInput) { if (binaryInput == null) { throw new ArgumentNullException(nameof(binaryInput)); } return(new InvertedBinaryInput(binaryInput)); }
public BinaryInputButtonAdapter(IBinaryInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += DispatchState; }
public InterruptMonitor(IBinaryInput binaryInput, ILogService logService) { _binaryInput = binaryInput ?? throw new ArgumentNullException(nameof(binaryInput)); _log = logService?.CreatePublisher(nameof(InterruptMonitor)) ?? throw new ArgumentNullException(nameof(logService)); // The server-based Timer is designed for use with worker threads in a multithreaded environment. // Server timers can move among threads to handle the raised Elapsed event, resulting in more accuracy // than Windows timers in raising the event on time. _timer = new Timer(Poll, null, Timeout.Infinite, Timeout.Infinite); }
private IActuator ParseButton(XElement element) { IBinaryInput input = Parser.ParseBinaryInput(element.GetMandatorySingleChildElementOrFromContainer("Input")); return(new Button( new ActuatorId(element.GetMandatoryStringFromAttribute("id")), input, Controller.HttpApiController, Controller.Logger, Controller.Timer)); }
public InterruptMonitor(IBinaryInput pin) { if (pin == null) throw new ArgumentNullException(nameof(pin)); _pin = pin; // The server-based Timer is designed for use with worker threads in a multithreaded environment. // Server timers can move among threads to handle the raised Elapsed event, resulting in more accuracy // than Windows timers in raising the event on time. _timer = new Timer(Poll, null, Timeout.Infinite, Timeout.Infinite); }
public InterruptMonitor(string id, IBinaryInput input, ILogService logService) { if (input == null) { throw new ArgumentNullException(nameof(input)); } _id = id ?? throw new ArgumentNullException(nameof(id)); _log = logService?.CreatePublisher(nameof(InterruptMonitor)) ?? throw new ArgumentNullException(nameof(logService)); input.StateChanged += HandleInterrupt; }
public MotionDetector(string id, IBinaryInput input, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { if (input == null) throw new ArgumentNullException(nameof(input)); input.StateChanged += (s, e) => HandleInputStateChanged(e); IsEnabledChanged += (s, e) => { HandleIsEnabledStateChanged(timer, notificationHandler); }; }
public PortBasedWindowAdapter(IBinaryInput fullOpenReedSwitch, IBinaryInput tildOpenReedSwitch = null) { _fullOpenReedSwitch = fullOpenReedSwitch ?? throw new ArgumentNullException(nameof(fullOpenReedSwitch)); _tildOpenReedSwitch = tildOpenReedSwitch; if (_tildOpenReedSwitch != null) { _tildOpenReedSwitch.StateChanged += (s, e) => Refresh(); } _fullOpenReedSwitch.StateChanged += (s, e) => Refresh(); }
private IActuator ParseRollerShutterButtons(XElement element) { IBinaryInput upInput = Parser.ParseBinaryInput(element.GetMandatorySingleChildFromContainer("Up")); IBinaryInput downInput = Parser.ParseBinaryInput(element.GetMandatorySingleChildFromContainer("Down")); return(new RollerShutterButtons( new ActuatorId(element.GetMandatoryStringFromAttribute("id")), upInput, downInput, Controller.HttpApiController, Controller.Logger, Controller.Timer)); }
public static IArea WithButton(this IArea room, Enum id, IBinaryInput input) { if (room == null) { throw new ArgumentNullException(nameof(room)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } room.AddActuator(new Button(ActuatorIdFactory.Create(room, id), input, room.Controller.HttpApiController, room.Controller.Logger, room.Controller.Timer)); return(room); }
public InterruptMonitor(IBinaryInput pin) { if (pin == null) { throw new ArgumentNullException(nameof(pin)); } _pin = pin; // The server-based Timer is designed for use with worker threads in a multithreaded environment. // Server timers can move among threads to handle the raised Elapsed event, resulting in more accuracy // than Windows timers in raising the event on time. _timer = new Timer(Poll, null, Timeout.Infinite, Timeout.Infinite); }
public InterruptMonitor(IBinaryInput pin, ILogger logger) { if (pin == null) { throw new ArgumentNullException(nameof(pin)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _pin = pin; _logger = logger; }
public IMotionDetector RegisterMotionDetector(IArea area, Enum id, IBinaryInput input) { if (area == null) throw new ArgumentNullException(nameof(area)); if (input == null) throw new ArgumentNullException(nameof(input)); var motionDetector = new MotionDetector( ComponentIdGenerator.Generate(area.Id, id), new PortBasedMotionDetectorEndpoint(input), _schedulerService, _settingsService); area.AddComponent(motionDetector); return motionDetector; }
public Button(ActuatorId id, IBinaryInput input, IHttpRequestController api, ILogger logger, IHomeAutomationTimer timer) : base(id, api, logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } timer.Tick += CheckForTimeout; input.StateChanged += HandleInputStateChanged; }
private Casement ParseCasement(XElement element, string defaultId) { IBinaryInput fullOpenInput = Parser.ParseBinaryInput(element.GetMandatorySingleChildFromContainer("FullOpen")); IBinaryInput tiltInput = null; if (element.HasChildElement("Tilt")) { tiltInput = Parser.ParseBinaryInput(element.GetMandatorySingleChildFromContainer("Tilt")); } var casement = new Casement(element.GetStringFromAttribute("id", defaultId), fullOpenInput, tiltInput); return(casement); }
public IButton RegisterButton(IArea area, Enum id, IBinaryInput input, Action<IButton> initializer = null) { if (area == null) throw new ArgumentNullException(nameof(area)); if (input == null) throw new ArgumentNullException(nameof(input)); var button = new Button( ComponentIdGenerator.Generate(area.Id, id), new PortBasedButtonEndpoint(input), _timerService, _settingsService); initializer?.Invoke(button); area.AddComponent(button); return button; }
public MotionDetector(ActuatorId id, IBinaryInput input, IHomeAutomationTimer timer, IHttpRequestController api, ILogger logger) : base(id, api, logger) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += (s, e) => HandleInputStateChanged(e); base.Settings = new ActuatorSettings(id, logger); Settings.IsEnabled.ValueChanged += (s, e) => { HandleIsEnabledStateChanged(timer, logger); }; }
public RollerShutterButtons(ActuatorId id, IBinaryInput upInput, IBinaryInput downInput, IHttpRequestController httpApiController, ILogger logger, IHomeAutomationTimer timer) : base(id, httpApiController, logger) { if (upInput == null) { throw new ArgumentNullException(nameof(upInput)); } if (downInput == null) { throw new ArgumentNullException(nameof(downInput)); } Up = new Button(new ActuatorId(id + "-up"), upInput, httpApiController, logger, timer); Down = new Button(new ActuatorId(id + "-down"), downInput, httpApiController, logger, timer); Settings = new ActuatorSettings(id, logger); }
public IButton RegisterButton(IArea area, Enum id, IBinaryInput input) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var adapter = new PortBasedButtonAdapter(input); var button = new Button($"{area.Id}.{id}", adapter, _timerService, _settingsService, _messageBroker, _logService); area.RegisterComponent(button); return(button); }
public IWindow RegisterWindow(IArea area, Enum id, IBinaryInput fullOpenReedSwitch, IBinaryInput tildOpenReedSwitch = null) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (fullOpenReedSwitch == null) { throw new ArgumentNullException(nameof(fullOpenReedSwitch)); } var adapter = new PortBasedWindowAdapter(fullOpenReedSwitch, tildOpenReedSwitch); var window = new Window($"{area.Id}.{id}", adapter, _settingsService); area.RegisterComponent(window); return(window); }
public Casement(string id, IBinaryInput fullOpenReedSwitch, IBinaryInput tiltReedSwitch = null) { if (id == null) throw new ArgumentNullException(nameof(id)); if (fullOpenReedSwitch == null) throw new ArgumentNullException(nameof(fullOpenReedSwitch)); Id = id; _fullOpenReedSwitch = fullOpenReedSwitch; _tiltReedSwitch = tiltReedSwitch; if (_tiltReedSwitch != null) { _tiltReedSwitch.StateChanged += (s, e) => Update(); } _fullOpenReedSwitch.StateChanged += (s, e) => Update(); Update(); }
public static IArea WithMotionDetector(this IArea area, Enum id, IBinaryInput input) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var motionDetector = new MotionDetector( ComponentIdFactory.Create(area.Id, id), new PortBasedMotionDetectorEndpoint(input), area.Controller.ServiceLocator.GetService <ISchedulerService>()); area.AddComponent(motionDetector); return(area); }
private void RegisterInterrupt(string id, IBinaryInput input) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var interruptMonitor = new InterruptMonitor(id, input, _logService); lock (_interruptMonitors) { _interruptMonitors.Add(id, interruptMonitor); } _log.Verbose($"Registered interrupt '{id}'."); }
public static IArea WithRollerShutterButtons(this IArea room, Enum id, IBinaryInput upInput, IBinaryInput downInput) { if (room == null) { throw new ArgumentNullException(nameof(room)); } if (upInput == null) { throw new ArgumentNullException(nameof(upInput)); } if (downInput == null) { throw new ArgumentNullException(nameof(downInput)); } var rollerShutterButtons = new RollerShutterButtons(ActuatorIdFactory.Create(room, id), upInput, downInput, room.Controller.HttpApiController, room.Controller.Logger, room.Controller.Timer); room.AddActuator(rollerShutterButtons); return(room); }
public IMotionDetector RegisterMotionDetector(IArea area, Enum id, IBinaryInput input) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var motionDetector = new MotionDetector( $"{area.Id}.{id}", new PortBasedMotionDetectorAdapter(input), _schedulerService, _settingsService); area.RegisterComponent(motionDetector); return(motionDetector); }
public static IArea WithButton(this IArea area, Enum id, IBinaryInput input, Action <IButton> initializer = null) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var button = new Button( ComponentIdFactory.Create(area.Id, id), new PortBasedButtonEndpoint(input), area.Controller.Timer); initializer?.Invoke(button); area.AddComponent(button); return(area); }
public IMotionDetector RegisterMotionDetector(IArea area, Enum id, IBinaryInput input) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var motionDetector = new MotionDetector( ComponentIdGenerator.Generate(area.Id, id), new PortBasedMotionDetectorEndpoint(input), _schedulerService, _settingsService); area.AddComponent(motionDetector); return(motionDetector); }
public IButton RegisterButton(IArea area, Enum id, IBinaryInput input, Action <IButton> initializer = null) { if (area == null) { throw new ArgumentNullException(nameof(area)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } var button = new Button( ComponentIdGenerator.Generate(area.Id, id), new PortBasedButtonEndpoint(input), _timerService, _settingsService); initializer?.Invoke(button); area.AddComponent(button); return(button); }
public Window WithRightCasement(IBinaryInput fullOpenReedSwitch, IBinaryInput tiltReedSwitch = null) { return WithCasement(new Casement(Casement.RightCasementId, fullOpenReedSwitch, tiltReedSwitch)); }
public Window WithCasement(string id, IBinaryInput fullOpenReedSwitch, IBinaryInput tiltReedSwitch = null) { return WithCasement(new Casement(id, fullOpenReedSwitch, tiltReedSwitch)); }
public InterruptMonitor(IBinaryInput pin) { if (pin == null) throw new ArgumentNullException(nameof(pin)); _pin = pin; }
public void RegisterRollerShutterButtons( IArea area, Enum upId, IBinaryInput upInput, Enum downId, IBinaryInput downInput) { if (area == null) throw new ArgumentNullException(nameof(area)); if (upInput == null) throw new ArgumentNullException(nameof(upInput)); if (downInput == null) throw new ArgumentNullException(nameof(downInput)); var upButton = new Button( ComponentIdGenerator.Generate(area.Id, upId), new PortBasedButtonEndpoint(upInput), _timerService, _settingsService); area.AddComponent(upButton); var downButton = new Button( ComponentIdGenerator.Generate(area.Id, downId), new PortBasedButtonEndpoint(downInput), _timerService, _settingsService); area.AddComponent(downButton); }
public PortBasedMotionDetectorEndpoint(IBinaryInput input) { if (input == null) throw new ArgumentNullException(nameof(input)); input.StateChanged += DispatchEvents; }
public PortBasedButtonEndpoint(IBinaryInput input) { if (input == null) throw new ArgumentNullException(nameof(input)); input.StateChanged += DispatchState; }