//depending on the type of io we're using, create an io controller
        public static IoController CreateIoController(Config config)
        {
            IoController ioController = null;

            switch (config.IoControllerType)
            {
            case Config.IoControllerTypes.RawGpio:
                Log.LogMessage("Using Raw GPIO");
                ioController = new GpioController(IoControllerFactory.GetGpioInputPins(config), IoControllerFactory.GetGpioOutputPins(config));
                break;

            case Config.IoControllerTypes.PifaceDigital:
                Log.LogMessage("Using PifaceDigital");
                ioController = new PiFaceIoController(IoControllerFactory.GetPiFaceInputPins(config), IoControllerFactory.GetPiFaceOutputPins(config));
                break;

            default:
                throw new ArgumentException("Config does not contain a valid IoController");
            }

            return(ioController);
        }
示例#2
0
        //setup the alarm system
        public Alarm(Config configuration)
        {
            Alarmed = false;

            //get configuration
            Config = configuration;

            //get the io controller we're going to use
            IoBoard = IoControllerFactory.CreateIoController(Config);

            //make sure the triggers are started
            InitialiseTriggers();

            Log.LogMessage("Rpi Home Security Ready...");

            _loggerStatusTimer           = new System.Timers.Timer(StatusTimerInterval);
            _loggerStatusTimer.AutoReset = true;
            _loggerStatusTimer.Elapsed  += OnSystemStatusTimerEvent;
            _loggerStatusTimer.Start();


            //run the startup actions
            RunActionList(Config.StartupActionListName);
        }