public void NewMessageArrived() { string r3 = rmu900Helper.CheckWriteEpc(); if (r3 != string.Empty) { Debug.WriteLine("写入标签成功 " + r3); } //string r2 = rmu900Helper.CheckInventory(); //if (r2 != string.Empty) //{ // this.UpdateEpcList(r2); // //AudioAlert.PlayAlert(); // Debug.WriteLine("读取到标签 " + r2); //} string r1 = rmu900Helper.ChekcInventoryOnce(); if (r1 != string.Empty) { Debug.WriteLine("读取到标签 " + r1); AudioAlert.PlayAlert(); this.UpdateEpcList(r1); } //string r = rmu900Helper.CheckRmuStatus(); //if (r == "ok") //{ // MessageBox.Show("设备状态良好!"); //} }
void comport_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { string temp = comport.ReadExisting(); sbuilder.Append(temp); while (true) { temp = sbuilder.ToString(); if (temp == null || temp == string.Empty) { break; } int indexLeft = temp.IndexOf("["); int indexRight = temp.IndexOf("]"); if (indexRight == -1 || indexLeft == -1) { break; //return; } if (indexLeft >= indexRight) { //前面有数据错误 sbuilder.Remove(0, indexLeft); } else { string data = temp.Substring(indexLeft, indexRight - indexLeft + 1); sbuilder.Remove(0, indexRight + 1); //Data dataTemp = new Data(data); ProtocolHelper p = ProtocolHelper.getProtocolHelper(data); if (p != null) { if (p.epcID == "0000000000") { AudioAlert.Msg(); } else { AudioAlert.PlayAlert(); } Action invoke = () => { this.lblEquip.Text = p.localDeviceID.Substring(9); this.lblEPC.Text = p.epcID; // FFFFFFFFFF00000F }; this.Invoke(invoke); } } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void button3_Click(object sender, EventArgs e) { AudioAlert.PlayAlert(); }