示例#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;
        }