示例#1
0
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(TurnOnSlow);
            _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout);

            return(this);
        }
示例#2
0
        public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(ExecuteAutoTrigger);
            _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout);

            _settingsService.CreateSettingsMonitor <MotionDetectorSettings>(motionDetector, CancelTimeoutIfMotionDetectorDeactivated);

            return(this);
        }
示例#3
0
        public static ITrigger CreatePressedLongTrigger(this IButton button, IMessageBrokerService messageBroker)
        {
            if (button == null)
            {
                throw new ArgumentNullException(nameof(button));
            }
            if (messageBroker == null)
            {
                throw new ArgumentNullException(nameof(messageBroker));
            }

            return(messageBroker.CreateTrigger <ButtonPressedLongEvent>(button.Id));
        }