public RollerShutter(
            string id, 
            IBinaryOutput powerOutput, 
            IBinaryOutput directionOutput, 
            TimeSpan autoOffTimeout,
            int maxPosition,
            IHttpRequestController httpApiController,
            INotificationHandler notificationHandler, 
            IHomeAutomationTimer timer)
            : base(id, httpApiController, notificationHandler)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));
            if (powerOutput == null) throw new ArgumentNullException(nameof(powerOutput));
            if (directionOutput == null) throw new ArgumentNullException(nameof(directionOutput));

            _powerGpioPin = powerOutput;
            _directionGpioPin = directionOutput;
            _autoOffTimeout = autoOffTimeout;
            _positionMax = maxPosition;
            _timer = timer;

            //TODO: StartMoveUp();

            timer.Tick += (s, e) => UpdatePosition(e);
        }
        /// <summary>
        /// Add the subscription to this topic 
        /// </summary>
        /// <param name="callback"></param>
        public void Subscribe(INotificationHandler callback)
        {
            if (Subscribers == null)
                Subscribers = new List<INotificationHandler>();

            Subscribers.Add(callback);
        }
 public HSREL5(string id, int address, II2cBusAccessor bus, INotificationHandler notificationHandler)
     : base(id, new PCF8574Driver(address, bus), notificationHandler)
 {
     // Ensure that all relays are off by default. The first 5 ports are hardware inverted! The other ports are not inverted but the
     // connected relays are inverted.
     SetState(new byte[] { 0xFF });
     CommitChanges(true);
 }
        public BinaryStateOutputActuator(string id, IBinaryOutput output, IHttpRequestController httpRequestController,
            INotificationHandler notificationHandler) : base(id, httpRequestController, notificationHandler)
        {
            if (output == null) throw new ArgumentNullException(nameof(output));

            _output = output;
            SetStateInternal(BinaryActuatorState.Off, new ForceUpdateStateParameter());
        }
        public HSPE16InputOnly(string id, int address, II2cBusAccessor i2cBus, INotificationHandler notificationHandler)
            : base(id, new MAX7311Driver(address, i2cBus), notificationHandler)
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
        public IOBoardManager(IHttpRequestController httpApiController, INotificationHandler notificationHandler)
        {
            if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController));
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            _httpApiController = httpApiController;
            _notificationHandler = notificationHandler;
        }
        public LogicalBinaryStateOutputActuator(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler,
            IHomeAutomationTimer timer) : base(
                id, httpApiController, notificationHandler)
        {
            if (timer == null) throw new ArgumentNullException(nameof(timer));

            _timer = timer;
        }
        public HumiditySensor(string id, ISingleValueSensor sensor,
            IHttpRequestController httpApiController, INotificationHandler notificationHandler)
            : base(id, httpApiController, notificationHandler)
        {
            if (sensor == null) throw new ArgumentNullException(nameof(sensor));

            sensor.ValueChanged += (s, e) => UpdateValue(e.NewValue);
        }
 /// <summary>
 /// Annotation controller constructor.
 /// </summary>
 /// <param name="repository">The repository interface.</param>
 /// <param name="telemetryClient">The telemetry client.</param>
 /// <param name="notificationHandler">The notification handler.</param>
 /// <param name="userRegistrationReferenceProvider">The user registration reference provider.</param>
 public AnnotationController(IRepository repository, TelemetryClient telemetryClient,
     INotificationHandler notificationHandler,
     IUserRegistrationReferenceProvider userRegistrationReferenceProvider) :
         base(userRegistrationReferenceProvider)
 {
     _repository = repository;
     _telemetryClient = telemetryClient;
     _notificationHandler = notificationHandler;
 }
 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 void Init()
       {
           _notificationHandler = new NotificationHandler();
           _repository = new DocumentDbRepository(new TestEnvironmentDefinition());
           _userRegistrationReferenceProviderMock = new UserRegistrationReferenceProviderMock();
 
           _reportController = new ReportController(_repository, new TelemetryClient(),
               _notificationHandler, _userRegistrationReferenceProviderMock);
       }
        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 AzureEventHubPublisher(string eventHubNamespace, string eventHubName, string sasToken, INotificationHandler notificationHandler) : base(notificationHandler)
        {
            if (eventHubNamespace == null) throw new ArgumentNullException(nameof(eventHubNamespace));
            if (eventHubName == null) throw new ArgumentNullException(nameof(eventHubName));
            if (sasToken == null) throw new ArgumentNullException(nameof(sasToken));

            _sasToken = sasToken;
            _uri = new Uri(string.Format("https://{0}.servicebus.windows.net/{1}/messages?timeout=60&api-version=2014-01", eventHubNamespace, eventHubName));
        }
 public NotificationManager(INotificationHandler[] handlers)
 {
     _handlers = handlers.Select(h => new
         {
             Handler = h,
             Type = (HandleNotificationTypeAttribute)h.GetType().GetCustomAttributes(typeof(HandleNotificationTypeAttribute), false).FirstOrDefault(),
         })
         .Where(h => h.Type != null)
         .ToLookup(h => h.Type.Type, h => h.Handler, StringComparer.OrdinalIgnoreCase);
 }
        public CCToolsBoardController(II2cBusAccessor i2CBus, IOBoardManager ioBoardManager, INotificationHandler notificationHandler)
        {
            if (i2CBus == null) throw new ArgumentNullException(nameof(i2CBus));
            if (ioBoardManager == null) throw new ArgumentNullException(nameof(ioBoardManager));

            _i2CBus = i2CBus;
            _notificationHandler = notificationHandler;

            _ioBoardManager = ioBoardManager;
        }
        protected ActuatorBase(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));
            if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController));
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            Id = id;
            NotificationHandler = notificationHandler;
            HttpApiController = httpApiController;

            ExposeToApi();
        }
        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);
            };
        }
        protected IOBoardController(string id, IPortExpanderDriver portExpanderDriver, INotificationHandler notificationHandler)
        {
            if (portExpanderDriver == null) throw new ArgumentNullException(nameof(portExpanderDriver));
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            Id = id;

            _portExpanderDriver = portExpanderDriver;
            _notificationHandler = notificationHandler;

            _state = new byte[portExpanderDriver.StateSize];
            _committedState = new byte[portExpanderDriver.StateSize];
        }
Beispiel #19
0
        /// <summary>
        /// Subscribes to a topic.
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="callback"></param>
        public void Subscribe(string topic, INotificationHandler callback)
        {
            // 1st time access ?
            if (_subscriptions == null)
                _subscriptions = new Dictionary<string,NotificationTopic>();

            // Topic exists ?
            if (!_subscriptions.ContainsKey(topic))
                _subscriptions[topic] = new NotificationTopic(topic);

            // Get topic
            NotificationTopic topicSubs = _subscriptions[topic];
            topicSubs.Subscribe(callback);
        }
Beispiel #20
0
        public Home(IHomeAutomationTimer timer, HealthMonitor healthMonitor, IWeatherStation weatherStation, IHttpRequestController httpApiController, INotificationHandler notificationHandler)
        {
            if (timer == null) throw new ArgumentNullException(nameof(timer));
            if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController));
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            Timer = timer;
            _healthMonitor = healthMonitor;
            WeatherStation = weatherStation;
            HttpApiController = httpApiController;
            NotificationHandler = notificationHandler;

            httpApiController.Handle(HttpMethod.Get, "configuration").Using(c => c.Response.Body = new JsonBody(GetConfigurationAsJSON()));
            httpApiController.Handle(HttpMethod.Get, "status").Using(HandleStatusRequest);
            httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(_healthMonitor.ApiGet()));
        }
        public I2cBusAccessor(INotificationHandler notificationHandler)
        {
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            _notificationHandler = notificationHandler;

            string deviceSelector = I2cDevice.GetDeviceSelector();
            
            DeviceInformationCollection deviceInformation = DeviceInformation.FindAllAsync(deviceSelector).AsTask().Result;
            if (deviceInformation.Count == 0)
            {
                throw new InvalidOperationException("I2C bus not found.");
            }

            _i2CBusId = deviceInformation.First().Id;
        }
        public OWMWeatherStation(double lat, double lon, string appId, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler)
        {
            if (timer == null) throw new ArgumentNullException(nameof(timer));
            if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController));
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            Temperature = _temperature;
            Humidity = _humidity;

            _notificationHandler = notificationHandler;
            _weatherDataSourceUrl = new Uri(string.Format("http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&APPID={2}&units=metric", lat, lon, appId));

            httpApiController.Handle(HttpMethod.Get, "weatherStation").Using(c => c.Response.Body = new JsonBody(ApiGet()));
            httpApiController.Handle(HttpMethod.Post, "weatherStation").WithRequiredJsonBody().Using(c => ApiPost(c.Request));

            LoadPersistedValues();
            timer.Every(TimeSpan.FromMinutes(2.5)).Do(Update);
        }
 public Window(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler)
 {
 }
Beispiel #24
0
 public WeatherController(IOpenWeatherService openWeatherService,
                          INotificationHandler <Notification> notifications,
                          IMediatorHandler mediatorHandler) : base(notifications, mediatorHandler)
 {
     _openWeatherService = openWeatherService;
 }
 public PedidosController(IPedidoAppService pedidoAppService,
                          INotificationHandler <DomainNotification> notifications) : base(notifications)
 {
     _pedidoAppService = pedidoAppService;
 }
 private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer, INotificationHandler notificationHandler)
 {
     if (!IsEnabled)
     {
         notificationHandler.PublishFrom(this, NotificationType.Info, "'{0}' disabled for 1 hour.", Id);
         _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(() => IsEnabled = true);
     }
     else
     {
         _autoEnableAction?.Cancel();
     }
 }
Beispiel #27
0
 public UnitOfWork(ThotContext context, IServiceProvider provider, INotificationHandler notificationHandler)
 {
     _context             = context;
     _provider            = provider;
     _notificationHandler = notificationHandler;
 }
 public ErrorNotificationManager(INotificationHandler <ErrorNotification> errorNotificationHandler)
 {
     _errorNotificationHandler = (IErrorNotificationHandler)errorNotificationHandler;
 }
Beispiel #29
0
 protected BaseController(INotificationHandler <Notifications> notification)
 {
     _messageHandler = (NotifiyHandler)notification;
 }
Beispiel #30
0
 public static Builder Create(INotificationHandler handler)
 => new Builder(handler);
Beispiel #31
0
 public PedidoController(IPedidoQueries pedidoQueries,
                         INotificationHandler <DomainNotification> notifications,
                         IMediatorHandler mediatorHandler) : base(notifications, mediatorHandler)
 {
     _pedidoQueries = pedidoQueries;
 }
 public SummaryViewComponent(INotificationHandler <DomainNotification> notifications)
 {
     _notifications = (DomainNotificationHandler)notifications;
 }
Beispiel #33
0
 public CargoController(ICargoAppService cargoAppService,
                        INotificationHandler <DomainNotification> notifications,
                        IMediatorHandler mediator) : base(notifications, mediator)
 {
     _cargoAppService = cargoAppService;
 }
Beispiel #34
0
 public CommandHandler(IUnitOfWork uow, IMediatorHandler bus, INotificationHandler <DomainNotification> notifications)
 {
     _uow           = uow;
     _notifications = (DomainNotificationHandler)notifications;
     Bus            = bus;
 }
 protected ControllerBase(INotificationHandler <DomainNotification> notifications,
                          IMediatorHandler mediatorHandler)
 {
     _notifications   = (DomainNotificationHandler)notifications;
     _mediatorHandler = mediatorHandler;
 }
 protected CommandHandler(IUnitOfWork uow, IMediatorHandler mediator, INotificationHandler <DomainNotification> notifications)
 {
     _uow           = uow;
     _mediator      = mediator;
     _notifications = (DomainNotificationHandler)notifications;
 }
 public BuyerController(INotificationHandler <ExceptionNotification> notifications, IMediator bus) : base(notifications)
 {
     _bus = bus;
 }
 public SmsCampaignNotificationHandler(INotificationHandler notificationHandler, IUnitOfWork unitOfWork
                                       , IMapper mapper) : base(notificationHandler, unitOfWork, mapper)
 {
 }
Beispiel #39
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="notificationHandlers">Array of notification handlers</param>
 public MessageManager(INotificationHandler[] notificationHandlers)
 {
     _notificationHandlers = notificationHandlers
         .SelectMany(h => h.NotificationTypes.Select(nt => new { Handler = h, Type = nt }))
         .ToLookup(h => h.Type, h => h.Handler, StringComparer.OrdinalIgnoreCase);
 }
Beispiel #40
0
 public BlogController(IBlogAppService blogAppService,
                       INotificationHandler <DomainNotification> notifications) : base(notifications)
 {
     _blogAppService = blogAppService;
 }
 public ProductDomainService(IProductRepository repository, INotificationHandler notificationHandler)
     : base(notificationHandler)
 {
     _repository = repository;
 }
Beispiel #42
0
 protected ApiBaseController(INotificationHandler <DomainNotification> notifications,
                             IDomainNotificationMediatorService mediator)
 {
     _notifications = (DomainNotificationHandler)notifications;
     _mediator      = mediator;
 }
Beispiel #43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="notifications"></param>
 /// <param name="authenticationService"></param>
 public AuthenticationController(INotificationHandler <DomainNotification> notifications, JwtAutenticationService authenticationService) : base(notifications)
 {
     _authenticationService = authenticationService;
 }
Beispiel #44
0
 public CustomerController(ICustomerAppService customerAppService,
                           INotificationHandler <DomainNotification> notifications) : base(notifications)
 {
     _customerAppService = customerAppService;
 }
        protected ActuatorMonitor(INotificationHandler notificationHandler)
        {
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            NotificationHandler = notificationHandler;
        }
 protected SingleValueSensorBase(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler)
     : base(id, httpApiController, notificationHandler)
 {
 }
        public HomeAutomationTimer(INotificationHandler notificationHandler)
        {
            if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler));

            _notificationHandler = notificationHandler;
        }
Beispiel #48
0
 public TagController(ITagService tagService,
                      INotificationHandler <Notification> notifications) : base(notifications) =>
Beispiel #49
0
 public CommandHandler(IUnityOfWork uow, IMediatorHandler bus, INotificationHandler <DomainNotification> notificacao)
 {
     _uow         = uow;
     _notificacao = (DomainNotificationsHandler)notificacao;
     _bus         = bus;
 }
 public CondominiumController(IMediatorBus mediator, INotificationHandler <DomainNotification> notifications, ILoggerFactory loggerFactory, IUser user) : base(mediator, notifications, loggerFactory, user)
 {
     _user     = user;
     _mediator = mediator;
     _logger   = loggerFactory.CreateLogger("CondominiumController");
 }
 public NotificationSenderJob(INotificationHandler notificationHandler)
 {
     _notificationHandler = notificationHandler;
 }
Beispiel #52
0
 public Bus(IServiceProvider serviceProvider, INotificationHandler notificationHandler)
 {
     _serviceProvider     = serviceProvider;
     _notificationHandler = notificationHandler;
 }
Beispiel #53
0
 public ClienteController(IClienteAppService clienteAppService,
                          INotificationHandler <DomainNotification> notifications) : base(notifications)
 {
     _clienteAppService = clienteAppService;
 }
 public VirtualButton(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler)
     : base(id, httpApiController, notificationHandler)
 {
 }
 public HSPE16OutputOnly(string id, int address, II2cBusAccessor i2cBus, INotificationHandler notificationHandler)
     : base(id, new MAX7311Driver(address, i2cBus), notificationHandler)
 {
     CommitChanges(true);
 }
Beispiel #56
0
 public ProductsController(IProductsService productsService, INotificationHandler <DomainEvent> events)
     : base(events)
 {
     this.productsService = productsService;
 }
Beispiel #57
0
 public BaseController(INotificationHandler <DomainNotification> notifications)
 {
     _notifications = (DomainNotificationHandler)notifications;
 }
Beispiel #58
0
 public PreservationAppService(IPreservationService PreservationService, IMediatorHandler bus, IBus rabbitMQBus, INotificationHandler <DomainNotification> notifications)
 {
     _service       = PreservationService;
     Bus            = bus;
     _notifications = (DomainNotificationHandler)notifications;
     RabbitMQBus    = rabbitMQBus;
 }
Beispiel #59
0
 public static Builder Create(INotificationHandler handler, Product instance)
 => new Builder(handler, instance);
 /// <summary>
 /// Default constructor
 /// </summary>
 public PurchaseController(IPurchaseAppService appService,
                           INotificationHandler <DomainNotification> notifications,
                           IMediatorHandler mediator) : base(appService, notifications, mediator)
 {
 }