public bool ConnectRFIDandScale(string serialRFID, string portCom) { this.serialRFID = serialRFID; isScaleConnected = false; isRfidConnected = false; // release previous object if not connected if (device != null) { device.ReleaseDevice(); } //Create a new object device = new RFID_Device(); //subscribe the event device.NotifyRFIDEvent += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent); //Create a d device eventEndConnection.Reset(); device.Create_NoFP_Device(serialRFID, portCom); eventEndConnection.WaitOne(); if (isRfidConnected && isScaleConnected) { return(true); } else { return(false); } }
/// <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"); } }
public PrinterForm(RFID_Device device, string lotID, PrinterData printInfo) { this.device = device; this.lotID = lotID; this.printInfo = printInfo; InitializeComponent(); }
/// <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(); } }); }
public BadCriteriaForm(DataView dv, Hashtable columnInfo, RFID_Device currentDevice) { InitializeComponent(); this.dv = dv; ColumnInfo = columnInfo; dataListView.DataSource = dv; this.currentDevice = currentDevice; if (currentDevice == null) { toolStripButtonFindByLed.Enabled = false; } for (int i = 0; i < dataListView.Columns.Count; i++) { OLVColumn ol = dataListView.GetColumn(i); ol.HeaderFont = new Font("Arial", 12F, FontStyle.Bold, GraphicsUnit.Point, 0); ol.HeaderForeColor = Color.AliceBlue; ol.IsTileViewColumn = true; ol.UseInitialLetterForGroup = false; ol.MinimumWidth = 20 + ol.Text.Length * 10; } if (dataListView.UseTranslucentHotItem) { dataListView.HotItemStyle.Overlay = new BusinessCardOverlay(columnInfo.Count); dataListView.HotItemStyle = dataListView.HotItemStyle; } dataListView.ItemRenderer = new BusinessCardRenderer(); dataListView.Invalidate(); }
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); } } }
//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; }); } }
/// <summary> /// Default constructor for (USB) local readers /// </summary> /// <param name="previousUid">Given tag previous ID</param> /// <param name="currentDevice">Current local reader (the one that scanned the given tag)</param> public TagUidWritingForm(string previousUid, RFID_Device currentDevice) { InitializeComponent(); textBoxPreviousUID.Text = previousUid; _previousUid = previousUid; _currentDevice = currentDevice; comboBoxSelWrite.SelectedIndex = 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; } }
public static void StopScan(RFID_Device localDevice) { if (localDevice == null) { return; } if ((localDevice.ConnectionStatus == ConnectionStatus.CS_Connected) && (localDevice.DeviceStatus == DeviceStatus.DS_InScan)) { localDevice.StopScan(); } }
public static bool StartScan(RFID_Device localDevice, bool bUnlockAll) { if (localDevice == null) { return(false); } if ((localDevice.ConnectionStatus == ConnectionStatus.CS_Connected) && (localDevice.DeviceStatus == DeviceStatus.DS_Ready)) { localDevice.ScanDevice(true, bUnlockAll); return(true); } return(false); }
public static WriteCode WriteNewUID(RFID_Device localDevice, string oldUID, string newUID, int writeMode) { if (writeMode == 0) { return(localDevice.WriteNewUID(oldUID, newUID)); } if (writeMode == 1) { return(localDevice.WriteNewUidWithFamily(oldUID, newUID)); } if (writeMode == 2) { return(localDevice.WriteNewUidDecimal(oldUID, newUID)); } return(WriteCode.WC_Error); }
/// <summary> /// <c>buttonDispose_Click</c> is called when user clicks on Dispose button. /// This function calls <c>ReleaseDevice</c> (from RFID_DEVICE) if a device is currently connected. /// </summary> private void buttonDispose_Click(object sender, EventArgs e) { listBoxTag.Items.Clear(); if (_currentUSBDevice == null) { return; } if (_currentUSBDevice.ConnectionStatus == ConnectionStatus.CS_Connected) { _currentUSBDevice.ReleaseDevice(); } buttonCreateDevice.Enabled = true; _currentUSBDevice = null; }
// 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; } }); }
public static void ConfirmAll(RFID_Device localDevice, List <string> tagsList) { int nbTagToConfirm = tagsList.Count; // initial number of tags localDevice.ConfirmList(tagsList, TagType.TT_R8); string message = String.Format("{0} tags to Confirm: {1} have been found.", nbTagToConfirm, nbTagToConfirm - tagsList.Count); if (tagsList.Count > 0) // some tag UIDs are still in the list : they've not been found { message += "\nMissing tags ID :" + tagsList.Count + "\r\n"; foreach (string missingTag in tagsList) { message = String.Format("{0}\n{1}", message, missingTag); } } MessageBox.Show(message); // while user doesn't close the dialog, the led-lighting thread is still running }
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; } }); }
private void comboBoxReader_SelectedIndexChanged(object sender, EventArgs e) { if (_arrayOfPluggedDevice == null) { return; } // 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 = ResStrings.str_In_Connection_; //subscribe the event _device.NotifyRFIDEvent += new NotifyHandlerRFIDDelegate(rfidDev_NotifyRFIDEvent); //Create a smartboard 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 switch (_arrayOfPluggedDevice[selectedDevice].deviceType) { case DeviceType.DT_SBR: case DeviceType.DT_STR: // Use create with portcom parameter for speed connection (doesn't search again the reader at is is previouly done; _device.Create_NoFP_Device(_arrayOfPluggedDevice[selectedDevice].SerialRFID, _arrayOfPluggedDevice[selectedDevice].portCom); //device.Create_NoFP_Device(arrayOfPluggedDevice[selectedDevice].SerialRFID); break; default: MessageBox.Show(ResStrings.str_OnlySBR_STR, ResStrings.BoxModeCreateUpdate_button1_Click_Box_Mode_Info, MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } }
//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"; }); } }
public static void LedOnAll(RFID_Device localDevice, List <string> tagsList) { int nbTagToLight = tagsList.Count; // initial number of tags localDevice.TestLighting(tagsList); string message = String.Format("{0} tags to find : {1} have been found.", nbTagToLight, nbTagToLight - tagsList.Count); if (tagsList.Count > 0) // some tag UIDs are still in the list : they've not been found { message += "\nMissing tags ID :"; foreach (string missingTag in tagsList) { message = String.Format("{0}\n{1}", message, missingTag); } } MessageBox.Show(message); // while user doesn't close the dialog, the led-lighting thread is still running localDevice.StopLightingLeds(); // stops lighting once user closed MessageBox }
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!"); } }