package com.mes.netty; // 固定格式报文各参数获取方法 // 协议 V3:8 字符工位号;AQDW/MQDW 响应使用 3 字符 LX 字段。 public class ProtocolParam { public static Integer fixedLength = 99; // 获取消息类型 所有报文都可使用 public static String getMsgType(String msg){ System.out.print(msg); if(msg.length() < 16){ return ""; } return msg.substring(12,16); } // 获取工位号(8 字符) public static String getOprno(String msg){ if(msg.length() < 26){ return ""; } return msg.substring(18,26); } // 获取工艺号 public static String getCraft(String msg){ if(msg.length() < 34){ return ""; } return msg.substring(28,34); } // 获取镭雕码或设备报警故障代码 public static String getSn(String msg){ if(msg.length() < 72){ return ""; } return msg.substring(36,72); } public static String getLx(String msg){ if(msg.length() < 75){ return ""; } return msg.substring(72,75).trim(); } // 获取结果 public static String getResult(String msg){ if(msg.length() < 77){ return ""; } return msg.substring(75,77); } // 获取日期 public static String getDay(String msg){ if(msg.length() < 89){ return ""; } return msg.substring(79,89); } // 获取时间 public static String getTime(String msg){ if(msg.length() < 99){ return ""; } return msg.substring(91,99); } }