|  |  | 
 |  |  |     */ | 
 |  |  |    public String parseRtuAddr(byte[] bs)throws Exception{ | 
 |  |  |       String rtuAddrBCD = "" + ByteUtil.BCD2Long_BE(bs, ProtocolConstantV206V1_0_0.rtuAddr1Index_start, ProtocolConstantV206V1_0_0.rtuAddr1Index_end) ; | 
 |  |  |       String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1_0_0.rtuAddr2Index_start) ; | 
 |  |  |       while(rtuAddrStr.length() < 4){ | 
 |  |  |       String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V1_0_0.rtuAddr2Index_start) ; | 
 |  |  |       while(rtuAddrStr.length() <= 5){ | 
 |  |  |          rtuAddrStr = "0" + rtuAddrStr ; | 
 |  |  |       } | 
 |  |  |       return rtuAddrBCD + rtuAddrStr ; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |    /** | 
 |  |  |     * 分析Rtu地址 | 
 |  |  |     * @param bs 上行字节数组 | 
 |  |  |     * @param index 启始位 | 
 |  |  |     * @return 控制器地址 | 
 |  |  |     * @throws Exception 异常 | 
 |  |  |     */ | 
 |  |  |    public String parseRtuAddr(byte[] bs, int index)throws Exception{ | 
 |  |  |       String rtuAddrBCD = "" + ByteUtil.BCD2Long_BE(bs, index, index + 2) ;//地址是大端模式 | 
 |  |  |       String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index + 3) ; | 
 |  |  |       while(rtuAddrStr.length() <= 5){ | 
 |  |  |          rtuAddrStr = "0" + rtuAddrStr ; | 
 |  |  |       } | 
 |  |  |       return rtuAddrBCD + rtuAddrStr ; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |    /** | 
 |  |  |     * 分析功能码 | 
 |  |  | 
 |  |  |       //DIR = 0 | 
 |  |  |       return b ; | 
 |  |  |    } | 
 |  |  |    /** | 
 |  |  |     * 得到IC卡类型名称 ( 卡类型(1:用户卡;2:管理员卡;3:调试卡;4:开关阀卡;5:清空卡)) | 
 |  |  |     * @param type 字节 | 
 |  |  |     * @return 名称 | 
 |  |  |     */ | 
 |  |  |    public static String icCardType(byte type){ | 
 |  |  |       return switch (type) { | 
 |  |  |          case 0 -> "无卡"; | 
 |  |  |          case 1 -> "用户卡"; | 
 |  |  |          case 2 -> "管理员卡"; | 
 |  |  |          case 3 -> "调试卡"; | 
 |  |  |          case 4 -> "开关阀卡"; | 
 |  |  |          case 5 -> "清空卡"; | 
 |  |  |          default -> "未知"; | 
 |  |  |       }; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    /** | 
 |  |  |     * 得到关开阀类型名称 | 
 |  |  |     * 开关阀类型( | 
 |  |  |     * 1:刷卡开阀; | 
 |  |  |     * 2:刷卡关阀; | 
 |  |  |     * 3:中心站开阀; | 
 |  |  |     * 4:中心站关阀; | 
 |  |  |     * 5:余额不足关阀; | 
 |  |  |     * 6:流量计故障关阀; | 
 |  |  |     * 7:紧急关闭; | 
 |  |  |     * 8:用户远程开阀; | 
 |  |  |     * 9:用户远程关阀; | 
 |  |  |     * 10:开关阀卡关阀; | 
 |  |  |     * 11:开关阀卡刷卡卡开阀; | 
 |  |  |     * 12:黑名单命令关阀; | 
 |  |  |     * 13:远程定时关阀; | 
 |  |  |     * 14:远程定量关阀; | 
 |  |  |     * ) | 
 |  |  |     * @param type 字节 | 
 |  |  |     * @return 名称 | 
 |  |  |     */ | 
 |  |  | 
 |  |  |          case 2 -> "刷卡关阀"; | 
 |  |  |          case 3 -> "中心站开阀"; | 
 |  |  |          case 4 -> "中心站关阀"; | 
 |  |  |          case 5 -> "欠费关阀"; | 
 |  |  |          case 5 -> "余额不足关阀"; | 
 |  |  |          case 6 -> "流量计故障关阀"; | 
 |  |  |          case 7 -> "紧急关阀"; | 
 |  |  |          case 8 -> "用户远程开阀"; | 
 |  |  |          case 9 -> "用户远程关阀"; | 
 |  |  |          case 16 -> "管道无水自动关阀"; | 
 |  |  |          case 10 -> "开关阀卡关阀"; | 
 |  |  |          case 11 -> "开关阀卡开阀"; | 
 |  |  |          case 12 -> "黑名单命令关阀"; | 
 |  |  |          case 13 -> "远程定时关阀"; | 
 |  |  |          case 14 -> "远程定量关阀"; | 
 |  |  |          default -> "未知"; | 
 |  |  |       }; | 
 |  |  |    } | 
 |  |  | 	 | 
 |  |  |    /* | 
 |  |  |     * 分析版本号 | 
 |  |  |     * @param bs  上行字节数组 | 
 |  |  |     * @return 版本号 | 
 |  |  |     * @throws Exception 异常 | 
 |  |  |    public String parseVersion(byte[] bs)throws Exception{ | 
 |  |  |       short ver = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1_0_0.versionIndex) ; | 
 |  |  |       char[] cs = ("" + ver).toCharArray() ; | 
 |  |  |       StringBuilder vs = new StringBuilder() ; | 
 |  |  |       for(byte i = 0 ; i < cs.length; i++){ | 
 |  |  |          if(i == 0){ | 
 |  |  |             vs.append(cs[i]) ; | 
 |  |  |          }else{ | 
 |  |  |             vs.append(".").append(cs[i]) ; | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return vs.toString() ; | 
 |  |  |    public static Boolean isCloseValveType(byte type){ | 
 |  |  |       return switch (type) { | 
 |  |  |          case 1, 3, 8, 11 -> false ; | 
 |  |  |          case 2, 4, 5, 6, 7, 9, 10, 12, 13, 14 -> true ; | 
 |  |  |          default -> null ; | 
 |  |  |       }; | 
 |  |  |    } | 
 |  |  |    */ | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |