public static IArea WithRollerShutter(this 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(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedRollerShutterEndpoint(powerOutput, directionOutput),
                area.Controller.Timer,
                area.Controller.ServiceLocator.GetService <ISchedulerService>());

            area.AddComponent(rollerShutter);
            return(area);
        }
        public static IActuator GetActuator(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <IActuator>(ComponentIdFactory.Create(area.Id, id)));
        }
        public static IRollerShutter GetRollerShutter(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <RollerShutter>(ComponentIdFactory.Create(area.Id, id)));
        }
Exemple #4
0
        public static IStateMachine GetStateMachine(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            return(area.GetComponent <IStateMachine>(ComponentIdFactory.Create(area.Id, id)));
        }
Exemple #5
0
        public static LogicalBinaryStateActuator CombineActuators(this IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var actuator = new LogicalBinaryStateActuator(ComponentIdFactory.Create(area.Id, id), area.Controller.Timer);

            area.AddComponent(actuator);
            return(actuator);
        }
        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(ComponentIdFactory.Create(areaId, componentId), synonyms);
        }
Exemple #7
0
        public static IArea WithVirtualButton(this IArea area, Enum id, Action <IButton> initializer = null)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var virtualButton = new Button(ComponentIdFactory.Create(area.Id, id), new EmptyButtonEndpoint(), area.Controller.Timer);

            initializer?.Invoke(virtualButton);

            area.AddComponent(virtualButton);
            return(area);
        }
Exemple #8
0
        public static IArea WithTemperatureSensor(this IArea area, Enum id, INumericValueSensorEndpoint endpoint)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            area.AddComponent(new TemperatureSensor(ComponentIdFactory.Create(area.Id, id), endpoint));
            return(area);
        }
Exemple #9
0
        public static IArea WithLamp(this 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(ComponentIdFactory.Create(area.Id, id), new PortBasedBinaryStateEndpoint(output));

            area.AddComponent(lamp);

            return(area);
        }
        public static IArea WithWindow(this 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(ComponentIdFactory.Create(area.Id, id));

            initializer(window);

            area.AddComponent(window);
            return(area);
        }
Exemple #11
0
        public static IArea WithMotionDetector(this 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(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedMotionDetectorEndpoint(input),
                area.Controller.ServiceLocator.GetService <ISchedulerService>());

            area.AddComponent(motionDetector);
            return(area);
        }
Exemple #12
0
        public static IArea WithStateMachine(this 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(
                ComponentIdFactory.Create(area.Id, id));

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

            area.AddComponent(stateMachine);
            return(area);
        }
Exemple #13
0
        public static IArea WithButton(this 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(
                ComponentIdFactory.Create(area.Id, id),
                new PortBasedButtonEndpoint(input),
                area.Controller.Timer);

            initializer?.Invoke(button);

            area.AddComponent(button);
            return(area);
        }
Exemple #14
0
        public static IArea WithRollerShutterButtons(
            this 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(
                ComponentIdFactory.Create(area.Id, upId),
                new PortBasedButtonEndpoint(upInput),
                area.Controller.Timer);

            area.AddComponent(upButton);

            var downButton = new Button(
                ComponentIdFactory.Create(area.Id, downId),
                new PortBasedButtonEndpoint(downInput),
                area.Controller.Timer);

            area.AddComponent(downButton);

            return(area);
        }