static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool useAuthentication = false; try { IConfigurationProvider provider = new XmlConfigurationProvider(); Analyzer analyzer = new Analyzer(provider); ConveyorService conveyor = new ConveyorService(54); AnalyzerDemoController demoController = new AnalyzerDemoController(provider, conveyor); demoController.LoadConfiguration("DemoControllerConfiguration"); StartWindow startWindow = new StartWindow(); MainWindow mainWindow = new MainWindow(); mainWindow.Init(analyzer, conveyor, demoController); startWindow.StartPosition = FormStartPosition.CenterScreen; mainWindow.StartPosition = FormStartPosition.CenterScreen; if (useAuthentication) { Application.Run(startWindow); if (startWindow.IsAuthenticated) { Application.Run(mainWindow); } } else { Application.Run(mainWindow); } analyzer.SaveUnitsConfiguration(); demoController.SaveConfiguration("DemoControllerConfiguration"); } catch (System.IO.FileLoadException) { MessageBox.Show("Ошибка при открытии файла конфигурации!"); return; } catch (System.IO.IOException) { MessageBox.Show("Ошибка при открытии файла конфигурации!"); return; } }
private void tryCreateController() { try { analyzer = new Analyzer(provider); conveyor = new ConveyorService(54); demoController = new AnalyzerDemoController(provider, conveyor); demoController.LoadConfiguration(controllerFileName); Analyzer.Serial.ConnectionChanged += UpdateConnectionState; } catch { Logger.Debug("Возникла ошибка при запуске!"); } }
static void tryRunAnalyzer() { try { analyzer = new Analyzer(provider); conveyor = new ConveyorService(54); demoController = new AnalyzerDemoController(provider, conveyor); demoController.LoadConfiguration(controllerFileName); Console.WriteLine("Анализатор запущен"); } catch { Console.WriteLine($"Возникла ошибка при открытии файла конфигурации!"); return; } }
public void Init(Analyzer analyzer, ConveyorService conveyor, AnalyzerDemoController controller) { this.analyzer = analyzer; devicesControlView.Init(analyzer); sensorsView.Init(analyzer); steppersGridView.Init(analyzer); Analyzer.Serial.ConnectionChanged += Serial_ConnectionChanged; this.conveyorService = conveyor; this.demoController = controller; demoExecutorView.Controller = this.demoController; }
public void SetController(AnalyzerDemoController controller) { _controller = controller; }