public void ReceivedCmd(byte[] bytes) { if (ByteUtils.ByteArrayEquals2(currentCmd.GetLastCommand(), bytes)) { string addr = ""; //表示 发送指令已经收到了,可以丢给对应的模块Station处理了 addr = bytes[0] + ""; baseStationDic[addr].Parse(bytes); sendPollingCMD(); } }
/// <summary> /// 针对这个模块的所有初始化指令, /// 有一个匹配上,就返回true ,具体规则自己写 /// 初始化时候,服务器每收到一个数据,都要调用下这个函数 /// 判断下是否初始化完成 /// </summary> /// <param name="bytes"></param> /// <returns></returns> public virtual bool isInit(byte[] bytes) { //处理这个isInitSccess for (int i = 0; i < initComand.Count; i++) { BaseCmd ce = initComand[i]; if (ce.canUse) { if (ce.GetLastCommand() == null) { break; } if (ByteUtils.ByteArrayEquals2(ce.GetLastCommand(), bytes)) { //如果相等,那就是在这个初始化指令的对应回复值 ce.canUse = false; var query = initComand.Where(item => item.canUse == true && item.stationId == ce.stationId); if (!query.Any()) { var pollingQuery = pollingComand.Where(item => item.stationId == ce.stationId); foreach (var bas in pollingQuery) { bas.canUse = true; } } break; } } } var queryAll = initComand.Where(item => item.canUse == true); if (!queryAll.Any()) { isInitSccess = true; } return(false); }