private static void Start(CounterCommandLine commandLine, ILogger logger, IServiceScope scope) { ISensorDataProcessor sensorDataProcessor = scope.ServiceProvider.GetRequiredService <ISensorDataProcessor>(); sensorDataProcessor.Start(); ISensorDataReceiver sensorDataReceiver = scope.ServiceProvider.GetRequiredService <ISensorDataReceiver>(); sensorDataReceiver.Start(commandLine.Interface, commandLine.Port); IControlReceiver controlReceiver = scope.ServiceProvider.GetRequiredService <IControlReceiver>(); controlReceiver.Start(commandLine.Interface, commandLine.Port); logger.LogInformation("Choose an action - [e]xit | [s]tart | s[t]op (casing matters!)"); while (true) { string input = Console.ReadLine(); if (string.IsNullOrWhiteSpace(input) || input.StartsWith('e')) { break; } if (input.StartsWith('s')) { sensorDataReceiver.Start(commandLine.Interface, commandLine.Port); } if (input.StartsWith('t')) { sensorDataReceiver.Stop(); } } }
private void SetStatus(bool status) { if (status) { _sensorDataReceiver.Start(_interface, _port); } else { _sensorDataReceiver.Stop(); } }