예제 #1
0
파일: MCCDaq.cs 프로젝트: rdherric/Drivers
        /// <summary>
        /// CreateMccBoard does the detection and creation
        /// of the MccBoard object and stores it in the
        /// static variable.
        /// </summary>
        private void CreateMccBoard()
        {
            //If the board has already been created, just return
            //with no further processing
            if (MCCDaq._board != null)
            {
                return;
            }

            //Figure out the number of boards that
            //have been installed
            //Get the max number of boards
            Int32 maxBoards = GlobalConfig.NumBoards;

            //If the number isn't at least one, throw an Exception
            if (maxBoards < 1)
            {
                throw new System.ApplicationException("Could not find MCC DAQ Boards installed.");
            }

            //Iterate through the boards and take the first
            //one that works
            for (Int32 i = 0; i < maxBoards; i++)
            {
                //Attempt to make the MccBoard
                MccBoard board = new MccBoard(i);

                //If the Board doesn't appear to exist, continue
                ErrorInfo ei = board.FlashLED();
                if (ei.Value == ErrorInfo.ErrorCode.BadBoard)
                {
                    continue;
                }

                //Save the board as the member variable and break
                MCCDaq._board = board;
                break;
            }
        }