private void init() { System.Threading.Thread.Sleep(100); //power byte power = 0; /*if (UHF.UHFGetPower(ref power)) * { * this.cbpower.Text = power.ToString(); * } * else * { * this.cbpower.Text = "24"; * }*/ System.Threading.Thread.Sleep(300); //MessageBox.Show("1"); //frequency //frequency byte[] uFreMode = new byte[1]; byte[] uFreBase = new byte[1]; byte[] uBaseFre = new byte[2]; byte[] uChannNum = new byte[1]; byte[] uChannSpc = new byte[1]; byte[] uFreHop = new byte[1]; /*if (UHF.UHFGetFrequency(uFreMode, uFreBase, uBaseFre, uChannNum, uChannSpc, uFreHop)) * { * this.cbregulation.Text = UHFHelper.dicFreMode[uFreMode[0]]; * } * else * { * cbregulation.SelectedIndex = 1; * }*/ //cbqvalue.SelectedIndex = 3; //MessageBox.Show("2"); //software version System.Threading.Thread.Sleep(600); byte[] uSerial = new byte[6]; byte[] uVersion = new byte[3]; if (UHF.UHFGetVersion(uSerial, uVersion)) { //BitConverter.ToString(uSerial).Replace("-", "") + BitConverter.ToString(uVersion).Replace("-", ""); // this.labhv.Text += CommonConvert.ByteArray2String(uSerial).Replace(" ",""); string vers = UHF.ByteArrayToHexString(uVersion); string hvers = UHF.ByteArrayToHexString(uSerial); //MessageBox.Show(hvers + " " + vers); //this.labsv.Text = vers; //this.labhv.Text = hvers; } }
/// <summary> /// Detiene el thread de lectura. /// </summary> public void stopReading() { if (UHF.UHFInventory(0x01, 0x03)) { //close UII receiving thread if (thrReceiveUii != null) { thrReceiveUii.Abort(); thrReceiveUii = null; } //stop get //Deja de escanear para leer físicamente el tag. UHF.UHFStopGet(); } }
//bool isCon = false;//if being connected void connection() { try { //serial port switch //ComID 0 UHF;1 WIFI;2 Barcode;3 GPS UHF.SerialPortSwitch_Ex(0); //initialize the module UHF.UHFInit(); //connect with the baudrate of 57600 byte[] statusArr = new byte[1]; statusArr[0] = 0; for (int i = 1; i < 5; i++) { //baudrate 0-9600、1-19200、2-57600、3-115200 if (UHF.UHFOpenAndConnect(statusArr)) { //isCon = true; UHF.UHFFlagCrcOn(); //enable CRC in case of messy codes Win32.PlayScanSound(); break; //frmMain fm = new frmMain(); //if (fm.ShowDialog() == DialogResult.No) //{ // UHF.UHFCloseAndDisconnect(); //} } else { if (i == 5) { MessageBox.Show("Connect Fail!", "Notice"); this.Close(); } } System.Threading.Thread.Sleep(1000); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Hasta aqui... /// <summary> /// Genera el Thread para que se pueda ejecutar la lectura. /// </summary> /// <param name="run"></param> public void Read(bool isConnected) { //MessageBox.Show("Reading Mode:" + flagAnti + ",Q" + iniAntiQ); //Activa el Escaneo Físico del Tag de forma continua para leer su data de acuerdo a los parámetros de información. //this.canReceive = UHF.UHFInventory(flagAnti, iniAntiQ); //this.canReceive = UHF.UHFInventory(0x01, 0x15); if (this.canReceive = UHF.UHFInventory(0x01, 0x03)) { //Abre un UII thread para recibir la data if (thrReceiveUii == null) { //ReceiveUiiProc se genera como thread thrReceiveUii = new System.Threading.Thread(ReceiveUiiProc); thrReceiveUii.IsBackground = true; thrReceiveUii.Start(); } else { thrReceiveUii.Start(); } } }
private void ReceiveUiiProc() { this.datalist = new Dictionary <string, int>(); //the reading EPC list and times int[] uLenUii = new int[1]; //largo del codigo o EPC. byte[] uUii = new byte[128]; //Codigo o EPC - UII should be at least 66 bytes while (canReceive) { //int[] uLenUii = new int[1]; //byte[] uUii = new byte[128]; //UII should be at least 66 bytes //Se extrae la data de la capa física del Hand held if (UHF.UHFGetReceived(uLenUii, uUii)) { if (uLenUii[0] > 0) { if (FlagSound) { Win32.PlayScanSound(); } //Se convierte la data de entrada en formato Base a un Array para su lectura string uii = BitConverter.ToString(uUii, 0, uLenUii[0]).Replace("-", ""); //show to the interface //TagRead ent = new TagRead(); Uii = uii; Epc = uii.Substring(4, uii.Length - 4); //Epc Count = 1; if (!datalist.ContainsKey(Epc)) { datalist.Add(Epc, 1); foreach (string s in datalist.Keys) { MessageBox.Show(s); } //MessageBox.Show(datalist.Values[0]); //System.out /*ListViewItem lv = new ListViewItem(); * lv.Text = (datalist.Count).ToString(); * lv.SubItems.Add(ent.Epc); * lv.SubItems.Add("1"); * _lvReadID.Invoke(new EventHandler(delegate * { * _lvReadID.Items.Add(lv); * })); * * _lbSumTagsReadID.Invoke(new EventHandler(delegate * { * _lbSumTagsReadID.Text = datalist.Count.ToString(); * }));*/ } else { datalist[Epc] += 1; // DisplayTagID(ent); } //UpdateControl(ent); } } System.Threading.Thread.Sleep(20); } }