日期:2014-05-20 浏览次数:20831 次
public ClassHeader onDataType1(DatagramPacket data) { ClassAD clazz = new ClassAD(); for (int i = 0; i < data.getLength(); i++) { // 起始标志 4*2 if (i <= 1) { clazz.starter[i] = data.getData()[i]; } // 报文类型 1*2 -------------------- else if (i == 2) { clazz.type[i - 2] = data.getData()[i]; } // 正文长度 2*2 else if (3 <= i && i <= 4) { clazz.contentLength[i - 3] = data.getData()[i]; } // 时 else if (i == 5) { System.out.println("时:" + Integer.parseInt(data.getData()[i] + "", 16)); } // 分 else if (i == 6) { System.out.println("分:" + Integer.parseInt(data.getData()[i] + "", 16)); } // 秒 else if (i == 7) { System.out.println("秒:" + Integer.parseInt(data.getData()[i] + "", 16)); } // MMSI 4*2 else if (9 <= i && i <= 12) { clazz.mmsi[i - 9] = data.getData()[i]; } } System.out.println("start:" + clazz.getStarter()); System.out.println("type:" + clazz.getType()); System.out.println("contentLength:" + clazz.getContentLength()); return clazz; }