Exemple #1
0
        private void _background_thread_DoWork(object sender, DoWorkEventArgs e)
        {
            _timer.Reset();

            //Connect to the Arduino board
            BehaviorBoard board = new BehaviorBoard();

            board.ConnectToArduino(_com_port);

            //Grab the booth number
            var booth_num = board.GetBoothNumber();

            BoothLabel = booth_num.ToString();

            //Set the default IR threshold for the nosepoke
            _ir_threshold = JawBoothConfiguration.GetInstance().IR_Threshold;

            //Check to see if their is a booth-specific IR threshold
            var booth_names = JawBoothConfiguration.GetInstance().Booth_Specific_IR_Thresholds.Keys.ToList();

            if (booth_names.Contains(BoothLabel))
            {
                _ir_threshold = JawBoothConfiguration.GetInstance().Booth_Specific_IR_Thresholds[BoothLabel];
            }

            //SLeep for 50 milliseconds to allow the previous operation to complete
            Thread.Sleep(50);

            //Enable streaming from the board
            board.StreamEnable(true);

            while (!_background_thread.CancellationPending)
            {
                HandleState(board);

                //Update the GUI based on what is happening in the background thread
                _background_thread.ReportProgress(0);

                //Sleep the thread for a bit
                Thread.Sleep(33);
            }

            //Disconnect from the Arduino board
            board.DisconnectFromArduino();
        }
Exemple #2
0
        public static bool QueryIndividualArduinoDevice(string com_port)
        {
            BehaviorBoard b       = new BehaviorBoard();
            bool          success = b.ConnectToArduino(com_port);

            if (success)
            {
                //Get the booth number
                int booth_number = b.GetBoothNumber();

                //Disconnect from the Arduino
                b.DisconnectFromArduino();

                //Update the booth pairing
                JawBoothConfiguration.GetInstance().UpdateBoothPairing(com_port, booth_number.ToString());
                JawBoothConfiguration.GetInstance().SaveBoothPairings();

                return(true);
            }
            else
            {
                return(false);
            }
        }