pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/CommonV1_0_1.java
@@ -99,7 +99,7 @@ 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){ while(rtuAddrStr.length() <= 5){ rtuAddrStr = "0" + rtuAddrStr ; } return rtuAddrBCD + rtuAddrStr ; pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/downVos/Com10Vo.java
New file @@ -0,0 +1,10 @@ package com.dy.common.mw.protocol.p206V1_0_0.downVos; /** * @Author: liurunyu * @Date: 2024/7/25 15:27 * @Description */ public class Com10Vo { public String rtuAddr ; } pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_10_Down.java
@@ -1,10 +1,14 @@ package com.dy.common.mw.protocol.p206V1_0_0.parse; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.dy.common.mw.protocol.*; import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.ParseParamsForDownV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com10Vo; import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com3AVo; import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; import com.dy.common.util.ByteUtil; @@ -51,6 +55,19 @@ * @throws Exception 异常 */ public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception { if(para.param == null) { throw new Exception("命令参数为null") ; }else { JSONObject obj = (JSONObject) para.param; String json = obj.toJSONString(); Com10Vo cvo = JSON.parseObject(json, Com10Vo.class); if (cvo == null) { throw new Exception("json转Com10Vo为null"); } if (cvo.rtuAddr == null) { throw new Exception("测试新地址不能为空"); } CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; byte[] bytes ; byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; @@ -72,19 +89,15 @@ ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; if(para.param == null){ throw new Exception("未提供命令参数数据,不能构造功能码为" + para.commandCode + "的下行命令") ; }else{ index = 0 ; byte[] bs = new byte[13] ; String newRtuAddr = (String)para.param ; GlCreate.createRtuAddr(newRtuAddr, bs, index); GlCreate.createRtuAddr(cvo.rtuAddr, bs, index); index += 5 ; GlCreate.createPw(bs, index); index += 2 ; GlCreate.createTp(bs, index); bytes = ByteUtil.bytesMerge(bsHead, bs) ; } GlCreate.createLen(bytes);//长度放字节数组中 @@ -94,5 +107,6 @@ return bytes ; } } } pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java
@@ -20,7 +20,7 @@ public class ComSupportP206V1_0_0 { protected static String mwUrlTest = "http://127.0.0.1:8070/rtuMw/com/test" ; protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send" ; protected static String rtuAddr = "532328059995" ; protected static String rtuAddr = "370829000001" ; // protected static String mwUrlTest = "http://8.140.179.55:8071/rtuMw/com/test" ; // protected static String mwUrlSendCom = "http://8.140.179.55:8071/rtuMw/com/send" ; pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/CommandP206V1_0_0Ctrl.java
@@ -29,7 +29,9 @@ if(com == null){ rt = this.connect() ;//连接通信中间件测试 }else{ if(com.equals("21")){ if(com.equals("10")){ rt = this.cd10() ; }else if(com.equals("21")){ rt = this.cd21() ; }else if(com.equals("37")){ rt = this.cd37() ; @@ -81,6 +83,12 @@ return this.sendTest() ; } private BaseResponse cd10(){ Com10Vo comVo = new Com10Vo() ; comVo.rtuAddr = "532328059995" ;//前6位是行政区划码,后6位是序列号最大是065535 return this.sendCom2Mw(this.command(CodeV1_0_1.cd_10, comVo, null)) ; } private BaseResponse cd21(){ Com21Vo comVo = new Com21Vo() ; comVo.ip = "8.140.180.59" ;//IP(例如 125.235.35.89)