Example #1
0
        /// <summary>
        /// Loads the pin configuration.
        /// </summary>
        /// <returns>The <see cref="Task"/></returns>
        public async Task LoadConfiguration()
        {
            if (!Directory.Exists(Constants.ConfigDirectory))
            {
                Directory.CreateDirectory(Constants.ConfigDirectory);
            }

            if (!File.Exists(Constants.GpioConfigDirectory))
            {
                return;
            }

            Logger.Trace("Loading Gpio config...");
            await Sync.WaitAsync().ConfigureAwait(false);

            try {
                PinConfig = JsonConvert.DeserializeObject <PinConfig>(File.ReadAllText(Constants.GpioConfigDirectory));

                if (PinConfig != null && PinConfig.PinConfigs.Count > 0)
                {
                    Logger.Trace("Pin configuration loaded!");
                }
                else
                {
                    Logger.Warning("Failed to load pin configuration.");
                }
            }
            catch (Exception e) {
                Logger.Log(e);
            }
            finally {
                Sync.Release();
            }
        }
Example #2
0
 public PinConfigManager Init(PinConfig config)
 {
     PinConfig = config;
     return(this);
 }