コード例 #1
0
        /// <summary>
        /// <c>buttonCreateDevice_Click</c> is called when user clicks on Create button.
        /// This function initializes <c>_currentUSBDevice</c> by creating a new RFID_Device.
        /// </summary>
        private void buttonCreateDevice_Click(object sender, EventArgs e)
        {
            if (_currentUSBDevice != null)
            {
                if (_currentUSBDevice.ConnectionStatus != ConnectionStatus.CS_Connected)
                {
                    _currentUSBDevice.ReleaseDevice(); // Release previous object if not connected
                }
            }

            _currentUSBDevice = new RFID_Device(); // Create a new object
            UpdateStatusBar("Info : In connection ");
            buttonCreateDevice.Enabled         = false;
            _currentUSBDevice.NotifyRFIDEvent += (rfidDev_NotifyRFIDEvent);

            // Let's create appropriate smartboard device
            // The task is under a threadpool because scanning all ports (if you decide to do so) makes the UI freeze.
            ThreadPool.QueueUserWorkItem(
                delegate
            {
                //  Give the COM port as second parameter to avoid looking for all com ports again => faster connection.
                _currentUSBDevice.Create_NoFP_Device(_arrayOfPluggedDevice[_selectedDevice].SerialRFID, _arrayOfPluggedDevice[_selectedDevice].portCom);
                // Remove the second parameter if you want to force the program to look for all COM ports again
                if (_currentUSBDevice.get_RFID_Device.FirmwareVersion.StartsWith("1"))
                {
                    MessageBox.Show("Invalid firmware version");
                    _currentUSBDevice.ReleaseDevice();
                }
            });
        }
        //Function to discover device
        private void FindDevice()
        {
            _arrayOfPluggedDevice = null;
            RFID_Device tmp = new RFID_Device();

            _arrayOfPluggedDevice = tmp.getRFIDpluggedDevice(true);
            tmp.ReleaseDevice();
            comboBoxReader.Items.Clear();
            if (_arrayOfPluggedDevice != null)
            {
                foreach (rfidPluggedInfo dev in _arrayOfPluggedDevice)
                {
                    if ((dev.deviceType == DeviceType.DT_SBR) || (dev.deviceType == DeviceType.DT_STR))
                    {
                        DeviceInfo di = db.RecoverDevice(dev.SerialRFID);
                        if (di != null)
                        {
                            comboBoxReader.Items.Add(di.DeviceName + " (" + dev.SerialRFID + ")");
                        }
                        else
                        {
                            comboBoxReader.Items.Add(dev.SerialRFID);
                        }
                    }
                }
                if (comboBoxReader.Items.Count > 0)
                {
                    comboBoxReader.SelectedIndex = 0;
                }
            }
            else
            {
                Invoke((MethodInvoker) delegate { toolStripStatusLabelInfo.Text = ResStrings.str_Quit_Live_Data; });
            }
        }
コード例 #3
0
        private void FindDevice()
        {
            _arrayOfPluggedDevice = null;
            RFID_Device tmp = new RFID_Device();

            _arrayOfPluggedDevice = tmp.getRFIDpluggedDevice(true);
            comboBoxSerialRFID.Items.Clear();
            if (_arrayOfPluggedDevice != null)
            {
                foreach (rfidPluggedInfo dev in _arrayOfPluggedDevice)
                {
                    comboBoxSerialRFID.Items.Add(dev.SerialRFID);
                }
            }
            else
            {
                MessageBox.Show("No device found");
            }

            _fpDevArray = tmp.getFingerprintPluggedGUID();
            tmp.ReleaseDevice();
            comboBoxSerialFPMaster.Items.Clear();
            comboBoxSerialFPSlave.Items.Clear();
            if (_fpDevArray != null)
            {
                foreach (string fpDev in _fpDevArray)
                {
                    comboBoxSerialFPMaster.Items.Add(fpDev);
                    comboBoxSerialFPSlave.Items.Add(fpDev);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// <c>FindDevice</c> function, discorvers device(s).
        /// </summary>
        private void FindDevice()
        {
            _arrayOfPluggedDevice = null;
            RFID_Device tmp = new RFID_Device();

            _arrayOfPluggedDevice      = tmp.getRFIDpluggedDevice(true);
            buttonCreateDevice.Enabled = false;

            tmp.ReleaseDevice();
            comboBoxDevice.Items.Clear();


            if (_arrayOfPluggedDevice != null)
            {
                if (_arrayOfPluggedDevice.Length == 0)
                {
                    return;
                }

                foreach (rfidPluggedInfo dev in _arrayOfPluggedDevice)
                {
                    comboBoxDevice.Items.Add(dev.SerialRFID);
                }

                comboBoxDevice.SelectedIndex = 0;
                buttonCreateDevice.Enabled   = true;
            }

            else
            {
                UpdateStatusBar("Info : No device detected");
            }
        }
        private void BoxModeCreateUpdate_FormClosing(object sender, FormClosingEventArgs e)
        {
            db.CloseDB();

            if (_device == null)
            {
                return;
            }
            if (_device.DeviceStatus == DeviceStatus.DS_NotReady)
            {
                _device.StopScan();
            }
            if (_device.ConnectionStatus == ConnectionStatus.CS_Connected)
            {
                _device.ReleaseDevice();
            }
        }
コード例 #6
0
        // Button create device
        private void button1_Click(object sender, EventArgs e)
        {
            // release previous object if not connected
            if (device != null)
            {
                if (device.ConnectionStatus != ConnectionStatus.CS_Connected)
                {
                    device.ReleaseDevice();
                }
            }
            //Create a new object
            device = new RFID_Device();
            toolStripStatusLabelInfo.Text = "Info RFID : In Connection ";
            buttonCreate.Enabled          = false;
            //subscribe the event
            device.NotifyRFIDEvent += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent);
            device.NotifyFPEvent   += new NotifyHandlerFPDelegate(rfidDev_NotifyFPEvent);
            //Create a DSB device
            //As the function search on all the serial port of the PC, this connection can
            //take some time and is under a thread pool to avoid freeze of the GUI
            ThreadPool.QueueUserWorkItem(
                delegate
            {
                switch (arrayOfPluggedDevice[selectedDevice].deviceType)
                {
                case DeviceType.DT_DSB:
                case DeviceType.DT_SBX:
                case DeviceType.DT_JSC:

                    //  Use create with portcom parameter for speed connection (doesn't search again the reader at is is previouly done;
                    //  recover guid FP in devFParray
                    //  bLoadTemplateFromDB mandatory to false
                    device.Create_1FP_Device(arrayOfPluggedDevice[selectedDevice].SerialRFID, arrayOfPluggedDevice[selectedDevice].portCom, fpDevArray[selectedFP], false);

                    break;

                default:
                    MessageBox.Show("Device not created - Only device with fingerprint allowed \r\n\t\tDevice Detected : " + arrayOfPluggedDevice[selectedDevice].deviceType.ToString());
                    break;
                }
            });
        }
コード例 #7
0
        //Function to discover device
        private void FindDevice()
        {
            comboBoxDevice.Items.Clear();
            _ethernetDevices.Clear();
            RFID_Device tmp = new RFID_Device();

            rfidPluggedInfo[] tmpDev = tmp.getRFIDpluggedDevice(true);
            tmp.ReleaseDevice();
            if (tmpDev != null)
            {
                int nIndex = 0;
                _arrayOfPluggedDevice = new rfidPluggedInfo[tmpDev.Length];
                foreach (rfidPluggedInfo dev in tmpDev)
                {
                    if (dev.deviceType != DeviceType.DT_SBR && dev.deviceType != DeviceType.DT_STR)
                    {
                        continue;
                    }

                    DeviceInfo di       = _db.RecoverDevice(dev.SerialRFID);
                    string     itemText = (di != null) ? di.DeviceName + " (" + dev.SerialRFID + ")" : dev.SerialRFID;
                    comboBoxDevice.Items.Add(itemText);
                    _arrayOfPluggedDevice[nIndex++] = dev;
                }
            }

            DeviceInfo[] ethernetDevices = _db.RecoverDevice(false); // bLocal = false => only looks for ethernet devices

            if (ethernetDevices != null)
            {
                foreach (DeviceInfo ethernetDevice in ethernetDevices)
                {
                    if (ethernetDevice.deviceType != DeviceType.DT_SBR && ethernetDevice.deviceType != DeviceType.DT_STR)
                    {
                        continue;
                    }
                    comboBoxDevice.Items.Add(ethernetDevice.DeviceName);
                    _ethernetDevices.Add(ethernetDevice.DeviceName, ethernetDevice);
                }
            }

            if (comboBoxDevice.Items.Count > 0)
            {
                comboBoxDevice.SelectedIndex = 0;
                buttonCreate.Enabled         = true;
            }

            else
            {
                MessageBox.Show(ResStrings.str_No_Device_found, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Invoke((MethodInvoker) delegate { toolStripStatusLabelInfo.Text = ResStrings.str_Quit_Live_Data; });
                buttonCreate.Enabled = false;
            }
        }
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             //dispose managed ressources
             if (device != null)
             {
                 device.ReleaseDevice();
             }
             if (scale != null)
             {
                 scale.closePort();
             }
         }
     }
     //dispose unmanaged ressources
     disposed = true;
 }
コード例 #9
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            if (_arrayOfPluggedDevice.Length - 1 < _selectedDeviceIndex) // Ethernet devices are added (in comboBox) after USB devices. Their index is greater than _arrayOfPluggedDevice length
            {
                MessageBox.Show(ResStrings.str_create_Ethernet_devices, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // release previous object if not connected
            if (_device != null)
            {
                if (_device.ConnectionStatus != ConnectionStatus.CS_Connected)
                {
                    _device.ReleaseDevice();
                }
            }

            _device = new RFID_Device();
            toolStripStatusLabelInfo.Text = ResStrings.str_In_Connection_;
            buttonCreate.Enabled          = false;
            _device.NotifyRFIDEvent      += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent);

            ThreadPool.QueueUserWorkItem(
                delegate
            {
                switch (_arrayOfPluggedDevice[_selectedDeviceIndex].deviceType)
                {
                case DeviceType.DT_SBR:
                case DeviceType.DT_STR:
                    _device.Create_NoFP_Device(_arrayOfPluggedDevice[_selectedDeviceIndex].SerialRFID, _arrayOfPluggedDevice[_selectedDeviceIndex].portCom);
                    _currentEthernetDevice = null;
                    break;

                default:
                    MessageBox.Show(ResStrings.str_OnlySBR_STR, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
            });
        }
コード例 #10
0
        //Function to discover device
        //This function will search all the RFID device and fingerprint plugged on the PC
        //Take care to choose the good value depending of the serial numbers printed on the device.
        private void FindDevice()
        {
            arrayOfPluggedDevice = null;
            RFID_Device tmp = new RFID_Device();

            arrayOfPluggedDevice = tmp.getRFIDpluggedDevice(false);
            fpDevArray           = tmp.getFingerprintPluggedGUID();
            tmp.ReleaseDevice();
            comboBoxDevice.Items.Clear();
            if (arrayOfPluggedDevice != null)
            {
                foreach (rfidPluggedInfo dev in arrayOfPluggedDevice)
                {
                    comboBoxDevice.Items.Add(dev.SerialRFID);
                }
            }

            comboBoxFP.Items.Clear();
            if (fpDevArray != null)
            {
                foreach (string fpDev in fpDevArray)
                {
                    comboBoxFP.Items.Add(fpDev);
                }
            }

            if ((comboBoxDevice.Items.Count > 0) && (comboBoxFP.Items.Count > 0))
            {
                comboBoxDevice.SelectedIndex = 0;
                comboBoxFP.SelectedIndex     = 0;
                buttonCreate.Enabled         = true;
            }
            else
            {
                buttonCreate.Enabled = false;
                Invoke((MethodInvoker) delegate { toolStripStatusLabelInfo.Text = "Info : No RFID and/or Fingerprint detected - try Refresh"; });
            }
        }
コード例 #11
0
        private void FindDeviceAndConnect(string serial)
        {
            arrayOfPluggedDevice = null;
            RFID_Device tmp = new RFID_Device();

            arrayOfPluggedDevice = tmp.getRFIDpluggedDevice(false);
            tmp.ReleaseDevice();

            if (arrayOfPluggedDevice != null)
            {
                foreach (rfidPluggedInfo dev in arrayOfPluggedDevice)
                {
                    if (dev.SerialRFID.Equals(serial))
                    {
                        if (device != null)
                        {
                            if (device.ConnectionStatus != ConnectionStatus.CS_Connected)
                            {
                                device.ReleaseDevice();
                            }
                        }
                        //Create a new object
                        device = new RFID_Device();
                        updatelabel("Info : In Connection");
                        //subscribe the event
                        device.NotifyRFIDEvent += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent);
                        device.Create_NoFP_Device(dev.SerialRFID, dev.portCom);

                        break;
                    }
                }
            }
            else
            {
                updatelabel("Info : No Device Detected!");
            }
        }