/// <summary>
 /// Method to disconnect device from the seriap port
 /// </summary>
 /// <returns>return true id succeed false otherwise</returns>
 public bool DisconnectBoard()
 {
     if (deviceChannel.CloseSerialPort())
     {
         bConnected    = false;
         deviceChannel = null;
     }
     return(bConnected);
 }
 /// <summary>
 /// Constructo of the class
 /// </summary>
 /// <param name="deviceChannel">involved deviceChannel for the event thread</param>
 /// <param name="eventDelegate">Delegate of the methof send when message received</param>
 public EventThread(IDeviceChannel deviceChannel,
                    ConsumeEventDelegate eventDelegate)
 {
     this.deviceChannel       = deviceChannel;
     this.eventDelegate       = eventDelegate;
     eventThread              = new Thread(eventThreadProc);
     eventThread.Name         = "Serial Async Events";
     eventThread.IsBackground = true;
     eventThread.Start();
 }
        /// <summary>
        /// Method to connect device to the serial port string pass in the constructor
        /// If the connection succeed recover all the parameter of the board.
        /// </summary>
        /// <returns>true is succed to connect, false otherwise</returns>
        public bool ConnectBoard()
        {
            deviceChannel = null;
            deviceChannel = new RS232DeviceChannel(0x23200232);
            deviceChannel.PinChangedEvent += deviceChannel_PinChangedEvent;
            bConnected = deviceChannel.OpenSerialPort(strSerialPortCom, out deviceId);
            if (bConnected)
            {
                deviceChannel.TheDeviceId = deviceId;
                PbRspGetHelloWorld Helloworld = getHelloWorld();
                this.deviceId        = Helloworld.DeviceInfo.deviceId;
                hardwareVersionMajor = Helloworld.DeviceInfo.description.hardwareVersionMajor;
                hardwareVersionMinor = Helloworld.DeviceInfo.description.hardwareVersionMinor;
                softwareVersionMajor = Helloworld.DeviceInfo.description.softwareVersionMajor;
                softwareVersionMinor = Helloworld.DeviceInfo.description.softwareVersionMinor;
                firmwareVersion      = softwareVersionMajor.ToString() + "." + softwareVersionMinor.ToString("00");
                hardwareVersion      = hardwareVersionMajor.ToString() + "." + hardwareVersionMinor.ToString("00");

                switch (hardwareVersionMajor)
                {
                case 1: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_DIAMOND_SMART_BOX; break;

                case 2: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_JEWELLERY_CABINET; break;

                case 3: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_MEDICAL_CABINET; break;

                case 4: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_DIAMOND_SMART_BOX_V2; break;

                case 5: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_MONO_AXE_READER; break;

                case 6: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_FLAT_3D_SHELVES; break;

                case 7: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_DIAMOND_SAS; break;

                case 8: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_FRIDGE_1D; break;

                case 9: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_MINI_SAS; break;

                case 10: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_RFID_BLOOD_FRIDGE; break;

                default: deviceTypeMajorType = DeviceTypeMajorType.DEVICE_UNKNOWN; break;
                }
            }
            return(bConnected);
        }