Ejemplo n.º 1
0
 internal Generator(GpioCore _core, EventConfig _config, ILogger _logger)
 {
     Logger = _logger;
     Core   = _core;
     Config = _config;
     Driver = PinController.GetDriver() ?? throw new DriverNotInitializedException();
     Init();
 }
Ejemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            var pins = new AvailablePins(new int[10], new int[10], new int[10], new int[10], new int[10], new int[10]);

            GpioCore = new GpioCore(pins, false);
            WebHost  = CreateHostBuilder().Build();
            await WebHost.StartAsync().ConfigureAwait(false);

            WebHost.WaitForShutdown();
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 internal SoundController(GpioCore gpioCore)
 {
     Controller       = gpioCore;
     aMixerInterfacer = new aMixerCommandInterfacer(false, false, false);
 }
Ejemplo n.º 5
0
 internal BluetoothController(GpioCore _controller) => Controller = _controller;
Ejemplo n.º 6
0
 internal PinController(GpioCore _controller) => Controller = _controller;
Ejemplo n.º 7
0
 internal SoundController(GpioCore _controller) => Controller = _controller;
Ejemplo n.º 8
0
 internal EventManager(GpioCore _core) => Core = _core;
Ejemplo n.º 9
0
 internal PinController(GpioCore core) => Controller = core;
Ejemplo n.º 10
0
 public GpioController(GpioCore _gpioCore)
 {
     GpioCore = _gpioCore;
     Debug.WriteLine($"{nameof(_gpioCore)} assigned!");
 }