/// <summary> /// 清空消息对列 /// </summary> private void ClearGWQuene() { byte[] cData = new byte[200]; int gwid; short tagNode, subCmd, msgType, dataCnt; gwid = 0; tagNode = 0; subCmd = -1; msgType = 0; dataCnt = 0; while (Dapapi.AB_Tag_RcvMsg(ref gwid, ref tagNode, ref subCmd, ref msgType, cData, ref dataCnt) > 0) { } }
/// <summary> /// 接收标签信息 /// </summary> private void RcvMsg() { int gwid, ret; short tagNode, subCmd, msgType, dataCnt; short gwPort, keyType, maxTag; byte[] rcvData = new byte[200]; Dapapi.Tccb ccb_data; string tmpStr, rcvStr; gwid = 0; //all gateway tagNode = 0; //all tagnode subCmd = -1; //all subcmd msgType = 0; dataCnt = 200; Dapapi.AB_GW_Status(0); ret = Dapapi.AB_Tag_RcvMsg(ref gwid, ref tagNode, ref subCmd, ref msgType, rcvData, ref dataCnt); if (ret > 0) { rcvStr = System.Text.Encoding.Default.GetString(rcvData); if (tagNode < 0) { gwPort = 1; } else { gwPort = 2; } tmpStr = "GW_ID:" + gwid + ",GW Port:" + gwPort + ",TagNode:" + System.Math.Abs(tagNode) + ",SubCmd:" + subCmd + ",Data:" + rcvStr; switch (subCmd) { case SUMCMD_CONFIRM_BUTTON: //写日志 monitorLog = MonitorLog.NewMonitorLog(); monitorLog.LOGNAME = "接收到标签信号"; monitorLog.LOGINFO = tmpStr; monitorLog.LOGLOCATION = "设备"; monitorLog.LOGTYPE = 0; monitorLog.Save(); //ShowMsg(tmpStr); if (Tags.ContainsKey(System.Math.Abs(Convert.ToInt32(tagNode)))) { Tags[System.Math.Abs(Convert.ToInt32(tagNode))].Qty = 0; } break; default: monitorLog = MonitorLog.NewMonitorLog(); monitorLog.LOGNAME = "设备初始化"; monitorLog.LOGINFO = tmpStr; monitorLog.LOGLOCATION = "设备"; monitorLog.LOGTYPE = 0; monitorLog.Save(); break; } } }