Beispiel #1
0
        public IRollerShutter RegisterRollerShutter(IArea area, Enum id, IBinaryOutput powerOutput, IBinaryOutput directionOutput)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (powerOutput == null)
            {
                throw new ArgumentNullException(nameof(powerOutput));
            }
            if (directionOutput == null)
            {
                throw new ArgumentNullException(nameof(directionOutput));
            }

            var rollerShutter = new RollerShutter(
                ComponentIdGenerator.Generate(area.Id, id),
                new PortBasedRollerShutterEndpoint(powerOutput, directionOutput),
                _timerService,
                _schedulerService,
                _settingsService);

            area.AddComponent(rollerShutter);

            return(rollerShutter);
        }
Beispiel #2
0
        public static ILamp GetLamp(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <ILamp>(ComponentIdGenerator.Generate(area.Id, id)));
        }
Beispiel #3
0
        public static ITemperatureSensor GetTemperatureSensor(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <ITemperatureSensor>(ComponentIdGenerator.Generate(area.Id, id)));
        }
Beispiel #4
0
        public static IRollerShutter GetRollerShutter(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <RollerShutter>(ComponentIdGenerator.Generate(area.Id, id)));
        }
Beispiel #5
0
        public static BinaryStateActuator GetBinaryStateActuator(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <BinaryStateActuator>(ComponentIdGenerator.Generate(area.Id, id)));
        }
Beispiel #6
0
        public LogicalBinaryStateActuator RegisterLogicalActuator(IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var actuator = new LogicalBinaryStateActuator(ComponentIdGenerator.Generate(area.Id, id), _timerService);

            area.AddComponent(actuator);

            return(actuator);
        }
Beispiel #7
0
        public void AddSynonymsForComponent(AreaId areaId, Enum componentId, params string[] synonyms)
        {
            if (componentId == null)
            {
                throw new ArgumentNullException(nameof(componentId));
            }
            if (synonyms == null)
            {
                throw new ArgumentNullException(nameof(synonyms));
            }

            AddSynonymsForComponent(ComponentIdGenerator.Generate(areaId, componentId), synonyms);
        }
Beispiel #8
0
        public IButton RegisterVirtualButton(IArea area, Enum id, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var virtualButton = new Button(ComponentIdGenerator.Generate(area.Id, id), new EmptyButtonEndpoint(), _timerService, _settingsService);

            initializer?.Invoke(virtualButton);

            area.AddComponent(virtualButton);
            return(virtualButton);
        }
Beispiel #9
0
        public ISocket RegisterSocket(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var socket = new Socket(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(socket);

            return(socket);
        }
Beispiel #10
0
        public ILamp RegisterLamp(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var lamp = new Lamp(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(lamp);

            return(lamp);
        }
Beispiel #11
0
        public IHumiditySensor RegisterHumiditySensor(IArea area, Enum id, INumericValueSensorEndpoint endpoint)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            var humditySensor = new HumiditySensor(ComponentIdGenerator.Generate(area.Id, id), _settingsService, endpoint);

            area.AddComponent(humditySensor);

            return(humditySensor);
        }
Beispiel #12
0
        public IWindow RegisterWindow(IArea area, Enum id, Action <Window> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var window = new Window(ComponentIdGenerator.Generate(area.Id, id), _settingsService);

            initializer(window);

            area.AddComponent(window);
            return(window);
        }
Beispiel #13
0
        public IStateMachine RegisterStateMachine(IArea area, Enum id, Action <StateMachine, IArea> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var stateMachine = new StateMachine(ComponentIdGenerator.Generate(area.Id, id));

            initializer(stateMachine, area);
            stateMachine.SetInitialState(BinaryStateId.Off);

            area.AddComponent(stateMachine);
            return(stateMachine);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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);
        }