| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.mes.netty;
- public class MesMsgUtils {
- public static int SYNR_LEN = 46;
- public static int AXTW_LEN = 46;
- public static int ACLW_LEN = 46;
- public static int MCJW_LEN = 96;
- public static int AQDW_LEN = 96;
- public static int MBDW_LEN = 96;
- public static int MJBW_LEN = 96;
- public static int MQDW_LEN = 96;
- public static int MKSW_LEN = 96;
- public static int MSBW_LEN = 96;
- public static int MCSW_LEN = 96;
- public static int AQRW_LEN = 96;
- public static String MSG_TYPE[] = {
- "SYNR",
- "AXTW",
- "ACLW",
- "MCJW",
- "AQDW",
- "MBDW",
- "MJBW",
- "MQDW",
- "MKSW",
- "MSBW",
- "MCSW",
- "AQRW",
- };
- public static int isMsgContentOK(String msg, String msg_type) {
- //ret=0OK,1 空内容,2 长度不符
- int ret = 0;
- if(msg==null||msg.equalsIgnoreCase("")) {
- ret = 1;
- return ret;
- }
- int len = msg.length();
- //System.out.println("len="+len);
- switch(msg_type) {
- case "SYNR":
- case "AXTW":
- case "ACLW":
- if(len==SYNR_LEN) {
- ret = 0;
- }else {
- ret = 2;
- }
- break;
- default:
- if(len==AQDW_LEN) {
- ret = 0;
- }else {
- ret = 2;
- }
- break;
- }
- return ret;
- }
- // 判断报文类型是否在清单里
- public static boolean isMsgTypeOk(String msg_type) {
- for (String str : MSG_TYPE) {
- if (str.equals(msg_type)) {
- return true;
- }
- }
- return false;
- }
- // 处理报文数据
- public static String processMsg(String msg, String msg_type) {
- String processMsgRet = "";
- if(msg_type.equalsIgnoreCase("SYNR")) {
- }else if(msg_type.equalsIgnoreCase("AXTW")) {
- }else if(msg_type.equalsIgnoreCase("ACLW")) {
- }else{
- processMsgRet = ProtocolParam.getResult(msg);
- }
- return processMsgRet;
- }
- }
|