private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { string Devname = ""; while (!backgroundWorker.CancellationPending) { Thread.Sleep(500); clients = ReaderControllor.GetClientInfo(); if (clients.Count == 1) //只有一台连接的时候直接默认选择这一台 { var currentclient = clients[0]; if (currentclient.types == connect.net) { ReaderControllor.GetMACDev(clients[0]); Devname = "Device:" + PrivateStringFormat.shortTolongNum(currentclient.dev); // + currentclient.dev; backgroundWorker.CancelAsync(); } else { // currentDev_l.Text = "Device:" + currentclient.com; Devname = "Device:" + COM_DevID; } } e.Result = Devname; } }
public void UpdateView(string[] result, string type) { int offset = 2; if (result[offset + 0] == ErrorNum.success) { new_mac_tb.Text = result[offset + 1]; new_dev_tb.Text = result[offset + 2]; textBox15.Text = result[offset + 3]; try { comboBox5.SelectedIndex = byte.Parse(result[offset + 4]); comboBox6.SelectedIndex = byte.Parse(result[offset + 5]); } catch (Exception ex) { // sd.UpdateLog(ex.ToString()); } UpdateDevID(result[offset + 2]); string devid = PrivateStringFormat.shortTolongNum(result[offset + 2]); string bz_str = ""; if (devid.Length < 15) { int bz_len = 15 - devid.Length; for (int i = 0; i < bz_len; i++) { bz_str += "0"; } devid = devid.Substring(0, 2) + bz_str + devid.Substring(2, 11); } LongDevIDlabel.Text = "长编码: " + devid; sd.UpdateLog("查询MAC地址和设备号成功"); if (SrDemo.isLogOpen) { EventLog.WriteEvent("获取读写器" + WorkingReader.dev + "MAC和设备号" + "数据接收" + "成功", null); } } else { sd.UpdateLog("查询MAC地址和设备号失败"); if (SrDemo.isLogOpen) { EventLog.WriteEvent("获取读写器" + WorkingReader.dev + "MAC和设备号" + "数据接收" + "失败", null); } } }
private void bu_opport_Click(object sender, RoutedEventArgs e) { portname = com_ports.Text; string s; try { ReaderControllor.ComStart(portname, baudRate, dataBits, parity, stopbits); // COM 115200 8 None One clients = ReaderControllor.GetClientInfo(); foreach (AsyncSocketState client in clients) { ReaderControllor.GetMACDev(client); } if (clients.Count == 1) //只有一台连接的时候直接默认选择这一台 { currentclient = clients[0]; if (currentclient.types == connect.net) { s = "Device:" + PrivateStringFormat.shortTolongNum(currentclient.dev); // + currentclient.dev; } else { // currentDev_l.Text = "Device:" + currentclient.com; s = "Device:" + COM_DevID; } } } catch (Exception ex) { UpdateLog("Error:" + ex.ToString()); ErrorLog.WriteError(ex.ToString()); return; } serialisstart = true; if ((serialisstart || serverisstart) && ((_IsActiveDatabaseWork) || (_IsRfidDatabaseWork) || (_IsCommandDatabaseWork))) { // timer_md_query_Tick.Enabled = true; } // TimerShowID.Enabled = true; // show_EPC_t.Enabled = true; // PortOpen_b.Text = stop; // UpdateLog(openserial + success); // EventLog.WriteEvent(openserial + success, null); }
public void UpdateView(string[] result, string type) { int offset = 2; if (result[offset + 0] == ErrorNum.success) { new_mac_tb.Text = result[offset + 1]; textBox15.Text = result[offset + 3]; string devid = PrivateStringFormat.shortTolongNum(result[offset + 2]); string bz_str = ""; if (devid.Length < 15) { int bz_len = 15 - devid.Length; for (int i = 0; i < bz_len; i++) { bz_str += "0"; } devid = devid.Substring(0, 2) + bz_str + devid.Substring(2, 11); } LongDevIDlabel.Text = "长编码: " + devid; sd.UpdateLog("查询长编码成功"); if (SrDemo.isLogOpen) { EventLog.WriteEvent("获取读写器" + WorkingReader.dev + "长编码" + "数据接收" + "成功", null); } } else { sd.UpdateLog("查询长编码失败"); if (SrDemo.isLogOpen) { EventLog.WriteEvent("获取读写器" + WorkingReader.dev + "长编码" + "数据接收" + "失败", null); } } }
public void ShowEPC(object sender, Command.ShowEPCEventArgs e) { // UpdateLog(e.CommandRespond); // string[] result = e.CommandRespond.Split(','); string[] result = (e.CommandRespond + "," + flag).Split(','); //每条命令后面加一个flag 用于循环盘存EPC显示 byte type = Convert.ToByte(result[1], 16); switch (type) { case Types.GET_MAC_ADD_RESPOND: COM_DevID = PrivateStringFormat.shortTolongNum(result[4]); string bz_str = ""; if (COM_DevID.Length < 15) { int bz_len = 15 - COM_DevID.Length; for (int i = 0; i < bz_len; i++) { bz_str += "0"; } COM_DevID = COM_DevID.Substring(0, 2) + bz_str + COM_DevID.Substring(2, 11); } // UpdateLBM(result); // 乔佳 2018-7-27 网络参数页面获取长编码 // UpdateMac(result); break; default: break; } }
private void ShowData(object sender, Command.ShowEPCEventArgs e) { string[] result = (e.CommandRespond + "," + flag).Split(','); //每条命令后面加一个flag 用于循环盘存EPC显示 byte type = Convert.ToByte(result[1], 16); readDataTimer.Tick += new EventHandler(timeCycle); readDataTimer.Interval = new TimeSpan(0, 0, 0, 1); switch (type) { case Types.START_MULTI_EPC_RESPOND: case Types.START_SINGLE_EPC_RESPOND: string ants = "天线:" + result[4].ToString() + "/", srfid = "卡号:" + result[5].ToString().Replace("-", "") + "/", times = "相对时间:" + result[8].ToString() + "/", ips = "端口:" + result[10].ToString() + "/", counts = "次数:" + result[11].ToString() + "/", stimes = "接收时间:" + result[12].ToString(); read_rfid = ants + srfid + counts + stimes + "\n"; isstate = 2; //this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, // (System.Threading.ThreadStart) delegate() // { // listinfo.DataContext = ""; // Thread.Sleep(TimeSpan.FromSeconds(1)); // listinfo.AppendText(read_rfid ); // }); //readDataTimer.Start(); //if (isSourceDataSave) //{ // GetSourceData(result); // UpdateMultiEPC(result); // 开始保存原始数据 // NNNum = NNNum + 1; // 记录每秒读标速度 // if (IsTagDoor == true) // { // updatedoor(); // } //} //else //{ // UpdateMultiEPC(result); // NNNum = NNNum + 1; // if (IsTagDoor == true) // { // updatedoor(); // } //} // dev_version = "97"; break; case Types.GET_MAC_ADD_RESPOND: COM_DevID = PrivateStringFormat.shortTolongNum(result[4]); string bz_str = ""; if (COM_DevID.Length < 15) { int bz_len = 15 - COM_DevID.Length; for (int i = 0; i < bz_len; i++) { bz_str += "0"; } COM_DevID = COM_DevID.Substring(0, 2) + bz_str + COM_DevID.Substring(2, 11); } isstate = 1; readDataTimer.Start(); // UpdateLBM(result); // 乔佳 2018-7-27 网络参数页面获取长编码 // UpdateMac(result); break; default: break; } }