示例#1
0
        public Shutter(string openPin, string closePin, int delay, IHardwareAbstractionLayer hal)
        {
            if (string.IsNullOrEmpty(openPin))
                throw new ArgumentOutOfRangeException("openPin", "missing open pin");
            if (string.IsNullOrEmpty(closePin))
                throw new ArgumentOutOfRangeException("closePin", "missing close pin");
            if (delay == 0)
                throw new ArgumentOutOfRangeException("delay", "delay must be greater than 0");
            if (hal == null)
                throw new ArgumentNullException("hal");

            _openPin = openPin;
            _closePin = closePin;
            _delay = delay;
            _hal = hal;
            _scheduler = Scheduler.GetScheduler();

            //Stop motors on startup
            _hal.Write(_openPin, PinTypes.Output, 0);
            _hal.Write(_closePin, PinTypes.Output, 0);
            _status = StatusStop;

            Class = "Window";
            Hardware = _hal.Info.Name;
            Version = CLASS_VERSION;
        }
示例#2
0
        public RgbDevice(string redPin, string greenPin, string bluePin, IHardwareAbstractionLayer hal)
        {
            _red = redPin;
            _green = greenPin;
            _blue = bluePin;
            _hal = hal;
            _scheduler = Scheduler.GetScheduler();

            WhiteColor = Color.White;
            DefaultColor = Color.White;
            Color = Color.White;
            Class = "Light";
            Hardware = _hal.Info.Name;
            Version = CLASS_VERSION;
        }
示例#3
0
        public Node(INodeConfigurator configurator)
        {
            _configurator = configurator;

            //Bus controller
            _bus = _configurator.Bus;
            _bus.CommandReceived += OnCommandReceived;
            _bus.AckReceived += OnAckReceived;

            //Hardware Abstraction Layer
            _hal = _configurator.Hal;

            //Scheduler
            _scheduler = _configurator.Scheduler;

            //Private members
            _pinSubscribers = new Dictionary<string, Pin>();
            _deviceSubscribers = new Dictionary<string, Device>();
            _sensorSubscribers = new List<SensorSubscriber>();
            _nodeSubscribers = new Dictionary<Address, byte>();

            //Public configuration
            Status = new NodeStatusInfo
            {
                Mask = 0,
                NodeStatus = NodeStatusValues.Reset,
                BusStatus = _bus.Status,
                LastError = 0,
                TotalErrors = 0,
                Time = 0,
                LastActivatedInput = string.Empty,
                LastActivatedOutput = string.Empty
            };
            //TODO: Add autostart property
            //if (AutoStart) {
            //Configure node
            //if (LoadConfiguration(false))
            //{
            //    //Full reset node
            //    Reset(true);
            //}
            //}
            //else
            //_bus.Open();    //Only bus start

            Log.Debug("Node created");
        }
示例#4
0
 public DummySensor(IHardwareAbstractionLayer hal, Scheduler scheduler)
 {
     _hal = hal;
     _scheduler = scheduler;
 }
示例#5
0
        public Node()
        {
            _configurator = null;

            //Bus controller
            _bus = null;

            //Hardware Abstraction Layer
            _hal = null;

            //Scheduler
            _scheduler = null;

            //Private members
            _pinSubscribers = new Dictionary<string, Pin>();
            _deviceSubscribers = new Dictionary<string, Device>();
            _sensorSubscribers = new List<SensorSubscriber>();
            _nodeSubscribers = new Dictionary<Address, byte>();

            //Public configuration
            Status = new NodeStatusInfo
            {
                Mask = 0,
                NodeStatus = NodeStatusValues.Unknown,
                BusStatus = BusStatus.Reset,
                LastError = 0,
                TotalErrors = 0,
                Time = 0,
                LastActivatedInput = string.Empty,
                LastActivatedOutput = string.Empty
            };

            Log.Debug("Empty node created");
        }