public bool HistoryContainsEvent(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { var matches = GetMatches(history, device, eventType, since); var result = matches.Any(); return(result); }
public WhenDeviceEventHappensTrigger(IDevice device, IEventType deviceType, IDeviceHistory history) { _device = device; _eventType = deviceType; _history = history; _lastCheck = UpdateLastCheck(); }
public bool HistoryContainsEvent(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { var matches = GetMatches(history, device, eventType, since); var result = matches.Any(); return result; }
public HomeAutomationNetworkContext(RoomieEngine engine, ThreadPool threadPool, IDeviceHistory deviceHistory, INetworkHistory networkHistory) { _engine = engine; ThreadPool = threadPool; //TODO: ninject? History = new MasterHistory(deviceHistory, networkHistory); Triggers = new TriggerCollection(); }
protected override IEnumerable <IDeviceEvent> GetMatches(IDeviceHistory history, IDevice device, IEventType eventType, System.DateTime since) { var matches = base.GetMatches(history, device, eventType, since); matches = matches.Where(x => IsAMatch(history, x)); return(matches); }
protected virtual IEnumerable<IDeviceEvent> GetMatches(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { //TODO: save the last inspected node instead of using a timestamp var matches = history.GetMatches( x => x.TimeStamp >= since, x => x.Device.Equals(device), x => x.Type.Matches(eventType) ); return matches; }
protected virtual IEnumerable <IDeviceEvent> GetMatches(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { //TODO: save the last inspected node instead of using a timestamp var matches = history.GetMatches( x => x.TimeStamp >= since, x => x.Device.Equals(device), x => x.Type.Matches(eventType) ); return(matches); }
private bool IsAMatch(IDeviceHistory history, IDeviceEvent candidate) { var previousEvent = GetEventBefore(history, candidate); var previousValue = GetMeasurement(previousEvent?.State); var currentValue = GetMeasurement(candidate?.State); if (previousValue == null || currentValue == null) { return(false); } return(IsAMatch(previousValue, currentValue)); }
protected static IDeviceEvent GetEventBefore(IDeviceHistory history, IDeviceEvent target) { IDeviceEvent lastMatch = null; foreach (var @event in history) { if (@event == target) { return(lastMatch); } if (@event.Device == target.Device && @event.Type.Matches(target.Type)) { lastMatch = @event; } } return(null); }
protected DeviceStateChangedTriggerBase(IDevice device, IDeviceHistory history) : base(device, new DeviceStateChanged(), history) { }
public WhenHumidityRisesAboveValueTrigger(IDevice device, IHumidity target, IDeviceHistory history) : base(device, history) { _target = target; }
public WhenDeviceEventHappenedWithinTimespanTrigger(IDevice device, IEventType deviceType, TimeSpan timeSpan, IDeviceHistory history) : base(device, deviceType, history) { _timeSpan = timeSpan; }
public MasterHistory(IDeviceHistory deviceHistory, INetworkHistory networkHistory) { DeviceEvents = deviceHistory; NetworkEvents = networkHistory; }
public WhenAKeypadButtonIsPressedTrigger(IDevice device, string buttonId, IDeviceHistory history) : base(device, history) { _buttonId = buttonId; }
public WhenTheCurrentActionChangesTrigger(IDevice device, string target, IDeviceHistory history) : base(device, history) { _target = target; }
public WhenHumidityFallsBelowValueTrigger(IDevice device, IHumidity target, IDeviceHistory history) : base(device, history) { _target = target; }