/// <summary> /// Initializes the gpio driver. /// </summary> /// <param name="pins">The available pins on the device.</param> /// <param name="scheme">The numbering scheme to use.</param> /// <returns>The driver.</returns> internal GpioControllerDriver(InternalLogger logger, PinsWrapper pins, GpioDriver driverName, PinConfig pinConfig, NumberingScheme scheme) { Logger = logger ?? throw new ArgumentNullException(nameof(logger)); Pins = pins; NumberingScheme = scheme; DriverName = driverName; PinConfig = pinConfig; IsDriverInitialized = true; }
internal Core(string[] args) { Console.Title = $"Initializing..."; Logger = InternalLogger.GetOrCreateLogger <Core>(this, nameof(Core)); OS.Init(true); RuntimeSpanCounter.Restart(); File.WriteAllText("version.txt", Constants.Version?.ToString()); ParseStartupArguments(); if (File.Exists(Constants.TraceLogFile)) { File.Delete(Constants.TraceLogFile); } Config = new CoreConfig(this); Config.LoadAsync().Wait(); IsUpdatesAllowed = !NoUpdates && Config.AutoUpdates; Config.LocalIP = Helpers.GetLocalIpAddress()?.ToString() ?? "-Invalid-"; Config.PublicIP = Helpers.GetPublicIP()?.ToString() ?? "-Invalid-"; if (!IsNetworkAvailable) { Logger.Warn("No Internet connection."); Logger.Info($"Starting offline mode..."); } Pins = new PinsWrapper( Config.GpioConfiguration.OutputModePins, Config.GpioConfiguration.InputModePins, Constants.BcmGpioPins, Config.GpioConfiguration.RelayPins, Config.GpioConfiguration.InfraredSensorPins, Config.GpioConfiguration.SoundSensorPins ); Controller = new GpioCore(Pins, this, Config.GpioConfiguration.GpioSafeMode); ModuleLoader = new ModuleLoader(); RestServer = new RestCore(Config.RestServerPort, Config.Debug); JobManager.AddJob(() => SetConsoleTitle(), (s) => s.WithName("ConsoleUpdater").ToRunEvery(1).Seconds()); Logger.CustomLog(FiggleFonts.Ogre.Render("LUNA"), ConsoleColor.Green); Logger.CustomLog($"---------------- Starting Luna v{Constants.Version} ----------------", ConsoleColor.Blue); IsBaseInitiationCompleted = true; PostInitiation().Wait(); InternalConfigWatcher = new ConfigWatcher(this); InternalModuleWatcher = new ModuleWatcher(this); InitiationCompleted = true; }
public SystemDeviceDriver(InternalLogger logger, PinsWrapper pins, PinConfig pinConfig, NumberingScheme scheme) : base(logger, pins, Enums.GpioDriver.SystemDevicesDriver, pinConfig, scheme) { }
internal WiringPiDriver(InternalLogger logger, PinsWrapper pins, PinConfig pinConfig, NumberingScheme scheme) : base(logger, pins, GpioDriver.WiringPiDriver, pinConfig, scheme) { CommandLine = new OSCommandLineInterfacer(OSPlatform.Linux, false, false, false); }
internal RaspberryIODriver(InternalLogger logger, PinsWrapper pins, PinConfig pinConfig, NumberingScheme scheme) : base(logger, pins, GpioDriver.RaspberryIODriver, pinConfig, scheme) { }