using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using NucuCar.Sensors.Abstractions; using NucuCar.Sensors.Modules.BME680; using NucuCar.Sensors.Modules.CpuTemperature; using NucuCar.Sensors.Modules.Heartbeat; using NucuCar.Sensors.Modules.PMS5003; using NucuCar.Telemetry; using NucuCar.Telemetry.Abstractions; using NucuCar.Telemetry.Publishers; namespace NucuCar.Sensors { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { services.Configure(hostContext.Configuration.GetSection("Telemetry")); services.Configure(hostContext.Configuration.GetSection("Bme680Sensor")); services.Configure(hostContext.Configuration.GetSection("CpuTemperatureSensor")); services.Configure(hostContext.Configuration.GetSection("HeartbeatSensor")); services.Configure(hostContext.Configuration.GetSection("Pms5003Sensor")); // Singletons services.AddSingleton(); services.AddSingleton, Bme680Sensor>(); services.AddSingleton, CpuTempSensor>(); services.AddSingleton, HeartbeatSensor>(); services.AddSingleton, Pms5003Sensor>(); // Workers // Telemetry services.AddHostedService(); // Sensors services.AddHostedService(); services.AddHostedService(); services.AddHostedService(); services.AddHostedService(); }); } }