private void btnWrite_Click(object sender, EventArgs e) { byte[] bWrite = new byte[96 / 8]; txtEPC.Text = txtEPC.Text.ToLower(); if ((txtEPC.Text.Length % 2) != 0) { txtEPC.Text = "0" + txtEPC.Text; } try { for (int i = 0, j = 0; i < txtEPC.Text.Length; i += 2, j++) { bWrite[j] = (byte)(16 * Utils.GetHex(txtEPC.Text[i])); bWrite[j] += (byte)Utils.GetHex(txtEPC.Text[i + 1]); } if (R1000Reader.RFIDTagWriteFile(MemoryBank.EPC, 4, bWrite, 96 / 8, 0) > 0) { lblStatus.Text = "Write OK"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cmbResponseMode_SelectedIndexChanged(object sender, EventArgs e) { #region codes ======================================== if (m_bOpen) { ResponseMode responseMode = ResponseMode.UNKNOWN; if (cmbResponseMode.SelectedIndex == 0) { responseMode = ResponseMode.COMPACT; } else { responseMode = ResponseMode.NORMAL; } Result nRet = R1000Reader.RFIDSetResponseMode(responseMode); if (nRet == Result.OK) { ErrorMessage(0, 0, "Set Response Mode OK"); } else { ErrorMessage(0, 0, "Set Response Mode Failure"); } } #endregion //end codes }
private void cmbOperationMode_SelectedIndexChanged(object sender, EventArgs e) { #region codes ======================================== Result nRet = Result.FAILURE; if (m_bOpen) { if (cmbOperationMode.SelectedIndex == 0) { nRet = R1000Reader.RFIDSetOperationMode(RadioOperationMode.CONTINUOUS); m_bContinue = true; } else { nRet = R1000Reader.RFIDSetOperationMode(RadioOperationMode.NONCONTINUOUS); m_bContinue = false; } if (nRet == Result.OK) { ErrorMessage(0, 0, "Set Operation Mode OK"); } else { ErrorMessage(0, 0, "Set Operation Mode Failure"); } } #endregion //end codes }
private void btnStart_Click(object sender, EventArgs e) { #region codes ======================================== if (m_bOpen) { if (!m_bStart) { m_bStart = true; ErrorMessage(0, 0, "Inventorying..."); btnStart.Text = "Parar"; lstView.Items.Clear(); RFID_INVENTORY stInventory = new RFID_INVENTORY(); ACCESS_STATUS stAccessStatus = new ACCESS_STATUS(); //operation in Non-blocking mode stInventory.hWnd = this.Handle; //stInventory.lpfnStartProc = new CallbackDelegate(InvStartProc); //stInventory.lpfnStopProc = new CallbackDelegate(InvStopProc); stInventory.lpfnStopProc = m_fnStopProc; R1000Reader.RFIDInventory(stInventory, ref stAccessStatus, false, 0); } else { R1000Reader.RFIDAbortOperation(); //StopInventory(); } }//end if (m_bOpen) #endregion //end codes }
private void EscrituraRFID() { byte[] bWrite = new byte[96 / 8]; txtEPC.Text = txtEPC.Text.ToLower(); if ((txtEPC.Text.Length % 2) != 0) { txtEPC.Text = "0" + txtEPC.Text; } // if ((txtEPC.Text.Length % 2) != 0) txtEPC.Text = txtEPC.Text + "00"; try { //for (int i = 0, j = 0; i < txtEPC.Text.Length; i += 2, j++) //{ // bWrite[j] = (byte)(16 * Utils.GetHex(txtEPC.Text[i])); // bWrite[j] += (byte)Utils.GetHex(txtEPC.Text[i + 1]); //} for (int i = 0, j = 0; i < txtEPC.Text.Length; i += 2, j++) { bWrite[j] = (byte)(16 * Utils.GetHex(txtEPC.Text[i])); bWrite[j] += (byte)Utils.GetHex(txtEPC.Text[i + 1]); } if (R1000Reader.RFIDTagWriteFile(MemoryBank.EPC, 4, bWrite, 96 / 8, 0) > 0) { lblStatus.Text = "Write OK"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmMain_Closed(object sender, EventArgs e) { #region codes ======================================== R1000Reader.RFIDClose(0); R1000Reader.RFIDDestroy(); scanTrigger.Dispose(); #endregion //end codes }
private void numTagStopCount_ValueChanged(object sender, EventArgs e) { #region codes ======================================== if (m_bOpen) { R1000Reader.RFIDSetStopCount(Convert.ToInt32(numTagStopCount.Value)); } #endregion //end codes }
private void btnCancel_Click(object sender, EventArgs e) { #region codes ======================================== if (m_bOpen) { R1000Reader.RFIDCancelOperation(); } #endregion //end codes }
private void btnOpen_Click(object sender, EventArgs e) { #region codes ======================================== Result nRet = Result.FAILURE; if (!m_bOpen) { nRet = R1000Reader.RFIDOpen(0); if (nRet != Result.OK) { ErrorMessage(nRet, 0, String.Empty); return; } //set anntena parameter for best Inventory AntennaPortConfig pConfig = new AntennaPortConfig(); R1000Reader.RFIDGetAntennaPortConfiguration(0, ref pConfig); //pConfig.powerLevel = 280; //pConfig.dwellTime = 300; //pConfig.numberInventoryCycles = 8192; //R1000Reader.RFIDSetAntennaPortConfiguration(0, ref pConfig); //For speed up block write below settings are necessary. //FIXEDQ_PARMS FixedParms = new FIXEDQ_PARMS(); //FixedParms.qValue = 0; //FixedParms.retryCount = 0; //FixedParms.toggleTarget = 0; //FixedParms.repeatUntilNoTags = 0; //SINGULATION_ALGORITHM_PARMS AlgParms = (SINGULATION_ALGORITHM_PARMS)FixedParms; //R1000Reader.RFIDSingulationAlgorithmParameters(SingulationAlgorithm.FIXEDQ, ref AlgParms, true); //SingulationAlgorithm nAlgorithm = SingulationAlgorithm.FIXEDQ; //R1000Reader.RFIDSingulationAlgorithm(ref nAlgorithm, true); btnOpen.Text = "Close"; m_bOpen = true; ErrorMessage(0, 0, "Ready"); }//end if (!m_bOpen) else { R1000Reader.RFIDClose(0); btnOpen.Text = "Open"; m_bOpen = false; ErrorMessage(0, 0, "Close"); } #endregion //end codes }
private void button2_Click_1(object sender, EventArgs e) { #region codes ======================================== string strWrite = "luyis"; string strRead = string.Empty; byte[] bytWrite = null; byte[] bytRead = new byte[32]; int nWrite = 0; int nRead = 0; bytWrite = Encoding.Default.GetBytes(strWrite); nWrite = R1000Reader.RFIDTagWriteFile(MemoryBank.USER, 0, bytWrite, bytWrite.Length, 0); //nRead = R1000Reader.RFIDTagReadFile(MemoryBank.USER, 0, bytRead, 11, 0); strRead = Encoding.Default.GetString(bytRead, 0, 11); #endregion //end codes }
private void btnRefresh_Click(object sender, EventArgs e) { #region codes ======================================== if (m_bOpen) { //Response Mode ResponseMode responseMode = ResponseMode.UNKNOWN; R1000Reader.RFIDGetResponseMode(ref responseMode); if (responseMode == ResponseMode.COMPACT) { cmbResponseMode.SelectedIndex = 0; } else { cmbResponseMode.SelectedIndex = 1; } //Operation Mode RadioOperationMode operationMode = RadioOperationMode.UNKNOWN; operationMode = R1000Reader.RFIDGetOperationMode(); if (operationMode == RadioOperationMode.CONTINUOUS) { cmbOperationMode.SelectedIndex = 0; m_bContinue = true; } else { cmbOperationMode.SelectedIndex = 1; m_bContinue = false; } //tag stop count numTagStopCount.Value = R1000Reader.RFIDGetStopCount(); AntennaPortConfig antPortConfig = new AntennaPortConfig(); R1000Reader.RFIDGetAntennaPortConfiguration(0, ref antPortConfig); txtdwelltime.Text = antPortConfig.dwellTime.ToString(); txtInvRounds.Text = antPortConfig.numberInventoryCycles.ToString(); traPowerLevel.Value = (int)antPortConfig.powerLevel / 10; lbldBm.Text = traPowerLevel.Value.ToString() + "dBm"; ErrorMessage(0, 0, "Config Refreshed"); } #endregion //end codes }
private void btnRead_Click(object sender, EventArgs e) { byte[] bRead = new byte[96 / 8]; string strRead = ""; int nRead; try { nRead = R1000Reader.RFIDTagReadFile(MemoryBank.EPC, 4, bRead, 96 / 8, 0); Utils.Byte2Hex(bRead, ref strRead); txtEPC.Text = strRead; lblStatus.Text = "Read completed."; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmMain_Load(object sender, EventArgs e) { #region codes ======================================== Result nRet = Result.FAILURE; String strVersion = String.Empty; nRet = R1000Reader.RFIDCreate(ref strVersion); if (nRet != Result.OK) { ErrorMessage(nRet, 0, "Initialized Reader Failed."); return; } //lblVersion.Text = "rfid.dll Ver:" + strVersion; btnOpen_Click(sender, e); scanTrigger.TriggerDown += new TriggerEventHandle(TriggerProc); // m_fnStopProc = new CallbackDelegate(InvStopProc); m_fnStopProc = new CallbackDelegate(InvStopProc1); #endregion //end codes }
private void TriggerProc(object sender, TriggerEventArgs args) { #region codes ======================================== if (m_bOpen && !m_bStart) { m_bStart = true; RFID_INVENTORY stInventory = new RFID_INVENTORY(); ACCESS_STATUS stAccessStatus = new ACCESS_STATUS(); //operation in Non-blocking mode //stInventory.lpfnStartProc = new CallbackDelegate(InvStartProc); //stInventory.lpfnStopProc = new CallbackDelegate(InvStopProc); stInventory.lpfnStopProc = m_fnStopProc; R1000Reader.RFIDInventory(stInventory, ref stAccessStatus, false, 0); } scanTrigger.DoneTrigger(); #endregion //end codes }
private void RetrieveData(ref ACCESS_STATUS lpAccessStatus, InsertItemDelegate insertItem, Boolean bAdd) { #region codes ======================================== if (lpAccessStatus.dwStatus == 0 && lpAccessStatus.dwErrorCode == 0) { for (int i = 0; i < lpAccessStatus.unAntennas; i++) { ANTENNA_STATUS stAntennaStatus = new ANTENNA_STATUS(); R1000Reader.RFIDGetAntennaStatus(i, ref stAntennaStatus); for (int j = 0; j < stAntennaStatus.unCount; j++) { ACCESS_DATA accessData = new ACCESS_DATA(); UInt32 nRet = R1000Reader.RFIDGetAccessData(i, j, ref accessData); if (nRet == 1 && accessData.unEPCLength > 0) { this.Invoke(insertItem, new object[] { accessData, stAntennaStatus.unAntenna, bAdd }); } } } } #endregion //end codes }
private void btnSet_Click(object sender, EventArgs e) { #region codes ======================================== Result nRet = Result.FAILURE; AntennaPortConfig antPortConfig = new AntennaPortConfig(); nRet = R1000Reader.RFIDGetAntennaPortConfiguration(0, ref antPortConfig); if (nRet != Result.OK) { ErrorMessage(0, 0, "Get Antenna Config Failure"); return; } antPortConfig.dwellTime = Convert.ToUInt32(txtdwelltime.Text); antPortConfig.numberInventoryCycles = Convert.ToUInt32(txtInvRounds.Text); antPortConfig.physicalRxPort = 3; antPortConfig.physicalTxPort = 3; antPortConfig.powerLevel = (UInt32)traPowerLevel.Value * 10; nRet = R1000Reader.RFIDSetAntennaPortState(0, AntennaPortState.ENABLED); if (nRet != Result.OK) { ErrorMessage(0, 0, "Set Antenna Port State Failure"); return; } nRet = R1000Reader.RFIDSetAntennaPortConfiguration(0, ref antPortConfig); if (nRet != Result.OK) { ErrorMessage(0, 0, "Set Antenna Config Failure"); } else { ErrorMessage(0, 0, "Set Config OK"); } #endregion //end codes }