public void OnStartup() { _communicationManager = CommunicationFactory.Create(GameType.Chaarr); try { Json = _communicationManager.Restart(); } catch (Exception exception) { MessageBox.Show(exception.Message); return; } GameState = JsonConverter.Parse(Json); LogManager.AddTurnReport(GameState); }
/// <summary> /// On window loaded - Start Foosbot Application and Threads /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnWindowLoaded(object sender, RoutedEventArgs e) { try { InitializeStatistics(); //get operation mode from configuration file _isArduinoConnected = Configuration.Attributes.GetValue <bool>(Configuration.Names.KEY_IS_ARDUINOS_CONNECTED); //Start Diagnostics - Processor and Memory Usage StartDiagnostics(); _imageProcessingPack = ImageProcessPack.Create(Dispatcher, _guiImage); _imageProcessingPack.Start(); VectorCalculationUnit vectorCalcullationUnit = new VectorCalculationUnit(_imageProcessingPack.ImageProcessUnit.BallLocationUpdater, _imageProcessingPack.ImageProcessUnit.ImagingData); vectorCalcullationUnit.Start(); MainDecisionUnit decisionUnit = new MainDecisionUnit(vectorCalcullationUnit.LastBallLocationPublisher); decisionUnit.Start(); if (_isArduinoConnected) { Dictionary <eRod, CommunicationUnit> communication = CommunicationFactory.Create(decisionUnit.RodActionPublishers); foreach (eRod key in communication.Keys) { if (communication[key] != null) { communication[key].Start(); } } } } catch (Exception ex) { MessageBox.Show("Application can not start. Reason: " + ex.Message); Close(); } }