/// <summary>
        /// Initial setup for RPIDriver
        /// Creates a copy of GPIO Pins
        /// </summary>
        public RPIDriver()
        {
            Log = new FileLogger();
            try
            {
                //Same as WiringPiSetup
                GPIO = new Gpio(Gpio.NumberingMode.Broadcom);
                Log.Add($"Sucess! WiringPi setup in {GPIO.PinNumberingMode} mode");
                Log.Add("PiBoard rev. = " + WiringPi.PiBoardRev().ToString());
                //Export all pins
                UpdatePinStates();
                //Initialize OUTInfos
                for (int i = 0; i < MAX_OUTPUTS; i++)
                {
                    OUT[i].Name         = $"OUT{i}";
                    OUT[i].SwitchStatus = 0;
                }
                //Initialize LEDInfos
                for (int i = 0; i < MAX_LEDS; i++)
                {
                    LED[i].Name      = $"LED{i}";
                    LED[i].LedStatus = 0;
                }
                //Initialize InputsInfos
                for (int i = 0; i < MAX_INPUTS; i++)
                {
                    IN[i].Name    = $"IN{i}";
                    IN[i].ADValue = new byte[] { 0, 0 };
                    IN[i].Range   = (int)RANGES.V3_0; //Default is Thermistor as seen in c++
                }

                //Initialize HSPInfos
                for (int i = 0; i < MAX_HSP_COUNTERS; i++)
                {
                    HSP[i].Name     = $"HSP{i}";
                    HSP[i].HSPValue = new byte[] { 0, 0, 0, 0 };
                }
            }
            catch (Exception ex)
            {
                Log.Add("Error: Failed to initialize WiringPi");
                Log.Add(ex.Message, false);
                throw ex;
            }
        }
Exemplo n.º 2
0
        public void Add__log_saves_to_file()
        {
            var fileLogger = new FileLogger();

            Log log = fileLogger.Add("test", typeof(LogTest));

            bool logExists = File.Exists(log.GetLogPath());

            Assert.AreEqual(logExists, true);
        }