// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); SmartPlugConnection smartPlugConnection = new SmartPlugConnection(); smartPlugConnection.Open(); EmeterEntityRepository emeterEntityRepository = new EmeterEntityRepository(smartPlugConnection); HtSensorEntityRepository htSensorEntityRepository = new HtSensorEntityRepository(smartPlugConnection); DoorWindowSensorEntityRepository doorWindowSensorEntityRepository = new DoorWindowSensorEntityRepository(smartPlugConnection); WeatherEntityRepository weatherEntityRepository = new WeatherEntityRepository(smartPlugConnection); services.AddSingleton(emeterEntityRepository); services.AddSingleton(htSensorEntityRepository); services.AddSingleton(doorWindowSensorEntityRepository); services.AddSingleton(weatherEntityRepository); }
static void Main(string[] args) { plugAddress = "192.168.0.206"; //plugAddress = args[0]; using (SmartPlugConnection connection = new SmartPlugConnection()) { connection.Open(); emeterEntityRepository = new EmeterEntityRepository(connection); weatherEntityRepository = new WeatherEntityRepository(connection); weatherApiClient = new WeatherApiClient(); SetTimers(); ev.Wait(); aTimer.Stop(); aTimer.Dispose(); bTimer.Stop(); bTimer.Dispose(); } }