Пример #1
0
        /// <summary>
        /// Image Processing Tool Window Constructor
        /// </summary>
        /// <param name="imagePack">Image processing pack to work with</param>
        public ImageProcessingTool(ImageProcessPack imagePack)
        {
            InitializeComponent();
            _imagePack = imagePack;

            Loaded  += OnWindowLoaded;
            Closing += OnWindowClosing;
        }
Пример #2
0
        /// <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();
            }
        }