private AutoResetEvent delayRecEvent; //延迟接收锁 public bool SendCmd(string strCmd, out string str) { string strHex = StrPramToHexPram.StrToHex(strCmd); if (strHex != "") { relationship.RelShip(strCmd); SendHex(strHex); Console.WriteLine(strHex);//测试用 recStr = recDataStr; Log.Debug(strCmd + "-->命令返回-->" + recStr); return(true); } else { recStr = "status=NOT"; return(true); } }
public bool SendCmd(string strCmd, string strPram, out string str) { delay = DelayCmd.WhetherCmd(strCmd); //解析发送过来的字符串命令 string strHex = StrPramToHexPram.StrToHex(strCmd); string sendHex = (strHex + " " + ShujuChuli.StrToHex(param) + " 81"); relationship.RelShip(strCmd); if (strHex != "") { if (delay == true)//命令是一条延迟命令 { lock (delaylook) { SendHex(sendHex);//发送命令 recStr = recDataStr; Log.Debug(strCmd + "-->命令返回-->" + recStr); delyEvent.WaitOne();//等待延迟数据返回 return(true); } } else { SendHex(sendHex);//发送命令 recStr = recDataStr; Log.Debug(strCmd + "-->命令返回-->" + recStr); return(true); } } else { recStr = "status=NOT"; return(true); } }