1、完善协议解析(RTU地址解析);
2、测试系统增加设置RTU地址的命令测试。
4个文件已修改
1个文件已添加
104 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/CommonV1_0_1.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/downVos/Com10Vo.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_10_Down.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/CommandP206V1_0_0Ctrl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,48 +55,58 @@
     * @throws Exception 异常
     */
    public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception {
        CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ;
        byte[] bytes ;
        byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ;
        byte index = 0 ;
        bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
        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("测试新地址不能为空");
            }
        index++ ;
        bsHead[index] = 0 ;//帧长度
            CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1();
            byte[] bytes;
            byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code];
            byte index = 0;
            bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte;
        index++ ;
        bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
            index++;
            bsHead[index] = 0;//帧长度
        index++ ;
        bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ;
            index++;
            bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte;
        index++ ;
        GlCreate.createRtuAddr(para.rtuAddr, bsHead, index);
        index += 5 ;
            index++;
            bsHead[index] = commonV1_0_1.createCtrl((byte) 0, (byte) 0);
        ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ;
            index++;
            GlCreate.createRtuAddr(para.rtuAddr, bsHead, index);
            index += 5;
        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);
            index += 5 ;
            ByteUtil.hex2Bytes(para.commandCode, bsHead, index);
            index = 0;
            byte[] bs = new byte[13];
            GlCreate.createRtuAddr(cvo.rtuAddr, bs, index);
            index += 5;
            GlCreate.createPw(bs, index);
            index += 2 ;
            index += 2;
            GlCreate.createTp(bs, index);
            bytes = ByteUtil.bytesMerge(bsHead, bs) ;
            bytes = ByteUtil.bytesMerge(bsHead, bs);
            GlCreate.createLen(bytes);//长度放字节数组中
            byte[] bsTail = GlCreate.createCrcTail(bytes);//CRC和尾叠加字节数组中
            bytes = ByteUtil.bytesMerge(bytes, bsTail);
            return bytes;
        }
        GlCreate.createLen(bytes);//长度放字节数组中
        byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中
        bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
        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)