public static byte[] ReadWithRetry(CAENRFIDTag tag, short memBank, short address, short length) { int retry_count = 0; bool retry = true; byte[] result = null; while (retry) { try { result = tag.Source.ReadTagData_EPC_C1G2(tag, memBank, address, length); retry = false; } catch (CAENRFIDException err) { retry_count++; if (retry_count == MAX_RETRY) { retry = false; } } } return(result); }
private void timerRecord_Tick(object sender, EventArgs e) { try { string EPC; int scanStatus = 0; CAENRFIDTag[][] MyTags = new CAENRFIDTag[4][]; if (checkBox0.Checked == true) { CAENRFIDLogicalSource MySource = MyReader.GetSource("Source_0"); MyTags[0] = MySource.InventoryTag(new byte[] { }, 0, 0, (short)1); //All tag with rssi } if (checkBox1.Checked == true) { CAENRFIDLogicalSource MySource1 = MyReader.GetSource("Source_1"); MyTags[1] = MySource1.InventoryTag(new byte[] { }, 0, 0, (short)1); } if (checkBox2.Checked == true) { CAENRFIDLogicalSource MySource2 = MyReader.GetSource("Source_2"); MyTags[2] = MySource2.InventoryTag(new byte[] { }, 0, 0, (short)1); } if (checkBox3.Checked == true) { CAENRFIDLogicalSource MySource3 = MyReader.GetSource("Source_3"); MyTags[3] = MySource3.InventoryTag(new byte[] { }, 0, 0, (short)1); } for (int i = 0; i < 4; i++) { if (MyTags[i] != null) { if (MyTags[i].Length > 0) { for (int j = 0; j < MyTags[i].Length; j++) { EPC = BitConverter.ToString(MyTags[i][j].GetId()); foreach (ListViewItem item in this.listViewInventory.Items) { if (item.Text.Equals(EPC)) // if the tags is read before , we do not search in datebase { scanStatus++; } } if (scanStatus == 0) { scanner_datebase(EPC,MyTags[i][j]); } } } } } } catch { CheckTotTagsTimer.Stop(); timerRecord.Stop(); toolStripStatusLabelMain.Text = "Record stop! "; buttonStart.Text = "start record"; } }
private void scanner_datebase(string id, CAENRFIDTag tag) { int Flags =0; string idTags = ""; string prenom = ""; string nom = ""; string No = ""; string major = ""; try { OleDbCommand sqlcmd = new OleDbCommand(@"SELECT * FROM infos WHERE ID = '" + id + "'", objConnection); using (OleDbDataReader reader = sqlcmd.ExecuteReader()) { if (reader.Read()) // s'il existe dans base de donnee, on l'ajoute dans le ListViewInventory { idTags = reader["ID"].ToString(); prenom = reader["prenomStu"].ToString(); nom = reader["nomStu"].ToString(); No = reader["NumberStu"].ToString(); major = reader["MajorStu"].ToString(); ListViewItem lvi = new ListViewItem(new string[] { idTags, prenom, nom, No, major, DateTime.Now.ToString(), tag.GetReadPoint() }); lvi.Tag = reader; listViewInventory.Items.Add(lvi); } else // sinon on demande pour enregistrer par une fenetre FormAlert { if (!SessionList.Contains(id)) { SessionList.Add(id); } else { Flags++; } if(Flags == 0) { FormAlert fa = new FormAlert(); fa.Owner = this; fa.StartPosition = FormStartPosition.CenterScreen; fa.labelAlertID.Text = id; fa.ShowDialog(); } } } } catch { } }
public static bool WriteTag(CAENRFIDTag tag, MemoryBankType MemType, int nStartAddr, int nLength, byte[] data) { try { source.WriteTagData_EPC_C1G2(tag, (short)MemType, (short)nStartAddr, (short)nLength, data); return true; } catch { return false; } }
public static bool ReadTag(CAENRFIDTag tag, MemoryBankType MemType, int nStartAddr, int nLength, out byte[] data) { try { data = source.ReadTagData_EPC_C1G2(tag, (short)MemType, (short)nStartAddr, (short)nLength); } catch { data = null; return false; } return true; }
public static bool GetSelectedTag(out CAENRFIDTag tag) { try { CAENRFIDTag[] tags; tags = source.InventoryTag(); if (tags != null) { tag = tags[0]; return true; } else { tag = null; return false; } } catch { tag = null; return false; } }