/// <summary> /// 重载收到Main模块消息处理 /// </summary> /// <param name="str">消息内容</param> public void OnReceiveMainMsg(MsgStruct.InterModuleMsgStruct MainMsg) { //在此处理MainController发送过来的信息 if (MainMsg == null || MainMsg.Body == null) { OnOutputLog(LogInfoType.EROR, "收到MainController模块消息内容为空!"); return; } if (MainMsg.AppInfo.Ip == null || MainMsg.AppInfo.Type == null) { OnOutputLog(LogInfoType.EROR, "收到MainController模块消息AppInfo内容错误!"); return; } if ((!MainMsg.AppInfo.Ip.Equals(MsgStruct.AllDevice)) && (!MainMsg.AppInfo.Type.Equals(MODE_NAME))) { //OnOutputLog(LogInfoType.DEBG, "收到MainController模块消息,不是本模块消息!"); return; } OnOutputLog(LogInfoType.INFO, string.Format("处理MainController消息。消息类型:{0}。", MainMsg.Body.type)); DeviceServerMsgStruct deviceServerMsgStruct = new DeviceServerMsgStruct(); deviceServerMsgStruct.Version = MainMsg.Version; deviceServerMsgStruct.ApInfo = MainMsg.ApInfo; deviceServerMsgStruct.Body = MainMsg.Body; SendMsg2App(MainMsg.AppInfo, deviceServerMsgStruct); return; }
/// <summary> /// 重载收到Main模块消息处理 /// </summary> /// <param name="msg">消息内容</param> public void OnReceiveMainMsg(MsgStruct.InterModuleMsgStruct MainMsg) { if (MainMsg == null || MainMsg.Body == null) { OnOutputLog(LogInfoType.EROR, "收到MainController模块消息内容为空!"); return; } if (MainMsg.ApInfo.IP == null || MainMsg.ApInfo.Type == null) { OnOutputLog(LogInfoType.EROR, "收到MainController模块消息ApInfo内容错误!"); return; } if ((!MainMsg.ApInfo.IP.Equals(MsgStruct.AllDevice)) && (!MainMsg.ApInfo.Type.Equals(MODE_NAME))) { //OnOutputLog(LogInfoType.DEBG, "收到MainController模块消息,不是本模块消息!"); return; } //处理透传消息 if (MainMsg.MsgType == MsgType.TRANSPARENT.ToString()) { Send2ap_TransparentMsg(MainMsg); return; } HandleMainMsg(MainMsg); return; }
/// <summary> /// 处理收到的Main模块的消息 /// </summary> /// <param name="MainMsg">消息内容</param> private void HandleMainMsg(MsgStruct.InterModuleMsgStruct MainMsg) { OnOutputLog(LogInfoType.INFO, string.Format("处理MainController消息。消息类型:{0}。", MainMsg.Body.type)); //上、下线消息回复 if (MainMsg.Body.type == Main2ApControllerMsgType.OnOffLine_Ack) { //所有在线AP数与数据库不一至,回复所有在线AP if (GetMsgIntValueInList("ReturnCode", MainMsg.Body) != 0) { OnOutputLog(LogInfoType.EROR, "[OnOffLine_Ack]Main模块返回错误:" + GetMsgStringValueInList("ReturnStr", MainMsg.Body)); //暂时不发送,等待后续定义 //Send2main_OnLineList(); } else { string status = GetMsgStringValueInList("Status", MainMsg.Body); if (status.Equals(OnLine) || status.Equals(OffLine)) { //修改状态 MyDeviceList.SetMainControllerStatus(status, MainMsg.ApInfo.IP, MainMsg.ApInfo.Port); } else { OnOutputLog(LogInfoType.EROR, "Main模块返回消息中,Status字段错误!"); } } } else if (MainMsg.Body.type == Main2ApControllerMsgType.ApDelete) { //修改状态为下线状态 MyDeviceList.SetMainControllerStatus(OffLine, MainMsg.ApInfo.IP, MainMsg.ApInfo.Port); } else if (MainMsg.Body.type == Main2ApControllerMsgType.ApSetRadio) { AsyncUserToken apToKen = MyDeviceList.FindByApInfo(MainMsg.ApInfo); if (apToKen == null) { OnOutputLog(LogInfoType.WARN, string.Format("在线AP列表中找不到Ap[{0}:{1}]设备({2})!", MainMsg.ApInfo.IP, MainMsg.ApInfo.Port.ToString(), MainMsg.ApInfo.Fullname)); return; } //byte carry = GetMsgByteValueInList("carry", MainMsg.Body.dic, Byte.MaxValue); //if (carry != 0) //{ // OnOutputLog(LogInfoType.EROR, string.Format("Main模块发送消息[{0}]中,carry字段非法!", // Main2ApControllerMsgType.ApSetRadio)); // return; //} Byte active_mode = GetMsgByteValueInList("active_mode", MainMsg.Body.dic, Byte.MaxValue); if (active_mode != 1 && active_mode != 2) { OnOutputLog(LogInfoType.EROR, string.Format("Main模块发送消息[{0}]中,active_mode字段非法!", Main2ApControllerMsgType.ApSetRadio)); return; } Byte mode = GetMsgByteValueInList("mode", MainMsg.Body.dic, Byte.MaxValue); if (mode != 1 && mode != 2) { OnOutputLog(LogInfoType.EROR, string.Format("Main模块发送消息[{0}]中,mode字段非法!", Main2ApControllerMsgType.ApSetRadio)); return; } Send2ap_activate_nodeb_request(apToKen, active_mode, mode); } //状态改变回复 else if (MainMsg.Body.type == Main2ApControllerMsgType.ApStatusChange_Ack) { RecvAckSaveApStatus(MainMsg); } else if (MainMsg.Body.type == Main2ApControllerMsgType.OnOffLineCheck) { string status = GetMsgStringValueInList("Status", MainMsg.Body); Send2main_OnOffLineCheck(status, MainMsg.ApInfo); } else if (MainMsg.Body.type == Main2ApControllerMsgType.ReportGenParaAck) { //返回错误 if (GetMsgIntValueInList("ReturnCode", MainMsg.Body) != 0) { OnOutputLog(LogInfoType.EROR, "[ReportGenParaAck]Main模块返回错误:" + GetMsgStringValueInList("ReturnStr", MainMsg.Body)); } return; } else if (MainMsg.Body.type == Main2ApControllerMsgType.app_add_bwlist_request) { //添加黑白名单 Send2ap_imsi_list_setconfig(MainMsg); return; } else if (MainMsg.Body.type == Main2ApControllerMsgType.app_del_bwlist_request) { //删除黑白名单 Send2ap_imsi_list_delconfig(MainMsg); return; } else if (MainMsg.Body.type == Main2ApControllerMsgType.SetGenParaReq) { MainMsg.Body.type = ApMsgType.set_general_para_request; Send2ap_RecvMainMsg(MainMsg); } else //其它消息 { if ((string.IsNullOrEmpty(MainMsg.ApInfo.IP)) || (MainMsg.ApInfo.IP == MsgStruct.NullDevice)) { OnOutputLog(LogInfoType.WARN, string.Format("目的设备为Null,不向Ap发送信息!")); Send2APP_GeneralError(MainMsg.ApInfo, MainMsg.AppInfo, MainMsg.Body.type, string.Format("目的设备为Null,不向Ap发送信息!")); } else { Send2ap_RecvMainMsg(MainMsg); } } return; }
/// <summary> /// 收到ApStatusChange_Ack后,将ap状态保存到设备列表 /// </summary> /// <param name="MainMsg">收到Main模块发过来的原始消息</param> protected void RecvAckSaveApStatus(MsgStruct.InterModuleMsgStruct MainMsg) { if (GetMsgIntValueInList("ReturnCode", MainMsg.Body) != 0) { OnOutputLog(LogInfoType.EROR, "[ApStatus_Ack]Main模块返回错误:" + GetMsgStringValueInList("ReturnStr", MainMsg.Body)); return; } int carry = GetMsgIntValueInList("carry", MainMsg.Body); if (carry != 0 && carry != 1) { OnOutputLog(LogInfoType.EROR, "[ApStatus_Ack]Main模块返回错误。carry不为0或1!"); return; } UInt32 detail = 0; string sDetail = GetMsgStringValueInList("detail", MainMsg.Body); if (!string.IsNullOrEmpty(sDetail)) { detail = Convert.ToUInt32(sDetail, 16); //UInt32 oldDetail = MyDeviceList.GetDetail(MainMsg.ApInfo.IP, MainMsg.ApInfo.Port); ////OnOutputLog(LogInfoType.EROR, "oldDetail=" + oldDetail); ////还原以前的射频状态 //if (carry == 0) //{ // UInt32 oleRadio = oldDetail & AP_STATUS_LTE.RADIO2; // detail |= oleRadio; //} //else //{ // UInt32 oleRadio = oldDetail & AP_STATUS_LTE.RADIO; // detail |= oleRadio; //} //OnOutputLog(LogInfoType.EROR, "detail=" + detail); //修改状态 MyDeviceList.SetDetail(detail, MainMsg.ApInfo.IP, MainMsg.ApInfo.Port); } else { OnOutputLog(LogInfoType.EROR, "Main模块返回消息中,detail字段错误!"); } Byte ApReadySt = 0; string sApReadySt = GetMsgStringValueInList("ApReadySt", MainMsg.Body); if (!string.IsNullOrEmpty(sApReadySt)) { sApReadySt = sApReadySt.Replace("-", "_"); ApReadySt = Convert.ToByte(Enum.Parse(typeof(ApReadyStEnum), sApReadySt));; //修改状态 MyDeviceList.SetApReadySt(ApReadySt, MainMsg.ApInfo.IP, MainMsg.ApInfo.Port); } else { OnOutputLog(LogInfoType.EROR, "Main模块返回消息中,ApReadySt字段错误!"); } }