Esempio n. 1
0
 public ChildrensRoomRoomConfiguration(
     IAreaRegistryService areaService,
     IDeviceRegistryService deviceService,
     CCToolsDeviceService ccToolsBoardService,
     AutomationFactory automationFactory,
     ActuatorFactory actuatorFactory,
     SensorFactory sensorFactory,
     IMessageBrokerService messageBroker,
     IDeviceMessageBrokerService deviceMessageBrokerService,
     ILogService logService)
 {
     _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker));
     _deviceMessageBrokerService = deviceMessageBrokerService;
     _logService          = logService;
     _areaService         = areaService ?? throw new ArgumentNullException(nameof(areaService));
     _deviceService       = deviceService ?? throw new ArgumentNullException(nameof(deviceService));
     _ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService));
     _automationFactory   = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory));
     _actuatorFactory     = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory));
     _sensorFactory       = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory));
 }
Esempio n. 2
0
        public LivingRoomConfiguration(
            IDeviceService deviceService,
            IAreaService areaService,
            CCToolsBoardService ccToolsBoardService,
            SynonymService synonymService,
            ActuatorFactory actuatorFactory,
            SensorFactory sensorFactory)
        {
            if (deviceService == null)
            {
                throw new ArgumentNullException(nameof(deviceService));
            }
            if (areaService == null)
            {
                throw new ArgumentNullException(nameof(areaService));
            }
            if (ccToolsBoardService == null)
            {
                throw new ArgumentNullException(nameof(ccToolsBoardService));
            }
            if (synonymService == null)
            {
                throw new ArgumentNullException(nameof(synonymService));
            }
            if (actuatorFactory == null)
            {
                throw new ArgumentNullException(nameof(actuatorFactory));
            }
            if (sensorFactory == null)
            {
                throw new ArgumentNullException(nameof(sensorFactory));
            }

            _deviceService       = deviceService;
            _areaService         = areaService;
            _ccToolsBoardService = ccToolsBoardService;
            _synonymService      = synonymService;
            _actuatorFactory     = actuatorFactory;
            _sensorFactory       = sensorFactory;
        }
        public WorkerABN03(string deviceId, ILogger <WorkerABN03> logger, IOptions <WorkersConfiguration> workersConfiguration, IOptions <MqttConfiguration> mqttConfiguration, IMqttClientForMultipleSubscribers mqttClient)
            : base(deviceId, logger, workersConfiguration, mqttConfiguration, mqttClient)
        {
            var sensorFactory = new SensorFactory();
            var device        = new Device
            {
                Name         = "ABN03",
                Model        = "ABSensor N03",
                Manufacturer = "April Brother",
                ViaDevice    = WorkersConfiguration.ServiceName,
                Identifiers  = new() { DeviceId },
                Connections  = new() { new() { "mac", DeviceId } }
            };

            ComponentList.AddRange(new List <Sensor>
            {
                sensorFactory.CreateSensor(DeviceClassDescription.Temperature, device: device),
                sensorFactory.CreateSensor(DeviceClassDescription.Humidity, device: device),
                sensorFactory.CreateSensor(DeviceClassDescription.IlluminanceLux, device: device),
                sensorFactory.CreateSensor(DeviceClassDescription.Battery, device: device)
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Collector initialize
        /// </summary>
        public void Initialize()
        {
            macAddress = NetworkInterface
                         .GetAllNetworkInterfaces()
                         .Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                         .Select(nic => nic.GetPhysicalAddress().ToString())
                         .FirstOrDefault();

            name             = Dns.GetHostName();
            location         = _configuration["Location"];
            description      = _configuration["Description"];
            readingFrequency = int.Parse(_configuration["ReadingFrequency"]);

            // Read sensors definition from config file
            var configSensors = _configuration.GetSection("Sensors");
            var sensorFactory = new SensorFactory(_logger);

            foreach (IConfigurationSection section in configSensors.GetChildren())
            {
                sensors.Add(sensorFactory.Get(section));
            }
        }
 public UpperBathroomConfiguration(
     CCToolsDeviceService ccToolsBoardService,
     IDeviceRegistryService deviceService,
     ISchedulerService schedulerService,
     IAreaRegistryService areaService,
     ISettingsService settingsService,
     AutomationFactory automationFactory,
     ActuatorFactory actuatorFactory,
     SensorFactory sensorFactory,
     IMessageBrokerService messageBroker)
 {
     _messageBroker       = messageBroker;
     _ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService));
     _deviceService       = deviceService ?? throw new ArgumentNullException(nameof(deviceService));
     _schedulerService    = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService));
     _areaService         = areaService ?? throw new ArgumentNullException(nameof(areaService));
     _settingsService     = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
     _automationFactory   = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory));
     _actuatorFactory     = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory));
     _sensorFactory       = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory));
     _messageBroker       = messageBroker ?? throw new ArgumentNullException(nameof(sensorFactory));
 }
 public LowerBathroomConfiguration(
     IDeviceRegistryService deviceService,
     ISchedulerService schedulerService,
     IAreaRegistryService areaService,
     ISettingsService settingsService,
     AutomationFactory automationFactory,
     ActuatorFactory actuatorFactory,
     SensorFactory sensorFactory,
     IMessageBrokerService messageBroker,
     IDeviceMessageBrokerService deviceMessageBrokerService,
     ILogService logService)
 {
     _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker));
     _deviceMessageBrokerService = deviceMessageBrokerService;
     _logService        = logService;
     _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
     _deviceService     = deviceService ?? throw new ArgumentNullException(nameof(deviceService));
     _schedulerService  = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService));
     _areaService       = areaService ?? throw new ArgumentNullException(nameof(areaService));
     _automationFactory = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory));
     _actuatorFactory   = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory));
     _sensorFactory     = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory));
 }