From ff55f15de19cb5bf02fa4d2313f4882ef9b3a452 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 30 四月 2025 10:47:34 +0800 Subject: [PATCH] 表阀一体机上报心跳数据最小间隔经常改动,时常不通知软件开发人员,所以通信中间件根据最小上报数据间隔会切断设备网络连接,为此改变中间件配置,最小心跳间隔改为在properties文件中配置。 --- pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java | 76 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java new file mode 100644 index 0000000..3db4a2a --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java @@ -0,0 +1,76 @@ +package com.dy.simRtu.tcpClient.upData; + +import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; +import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; +import com.dy.common.util.ByteUtil; +import org.apache.mina.core.session.IoSession; + +/** + * @Author: liurunyu + * @Date: 2024/7/15 14:20 + * @Description + */ +public class UpData { + + protected static IoSession session ; + + private static Object synObj = new Object() ; + + public static void setSession(IoSession session){ + UpData.session = session ; + } + + protected static void upSend(byte[] bs) throws Exception{ + synchronized (synObj){ + session.write(bs) ; + } + } + + protected static byte[] creatHead(String rtuAddr, String code, byte ctrl)throws Exception { + byte[] bsHead = new byte[ProtocolConstantV206V1.lenHead2Code] ; + byte index = 0 ; + bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; + + index++ ; + bsHead[index] = 0 ;//甯ч暱搴� + + index++ ; + bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; + + index++ ; + bsHead[index] = ctrl; //鎺у埗鍩熷姛鑳界爜 + + index++ ; + GlCreate.createRtuAddr4P206(rtuAddr, bsHead, index); + index += 5 ; + + ByteUtil.hex2Bytes(code, bsHead, index) ; + + return bsHead ; + } + + protected static byte[] creatHead4Upgrade(String rtuAddr, String preCode, String sufCode)throws Exception { + byte[] bsHead = new byte[12] ; + byte index = 0 ; + bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ; + + index++ ; + bsHead[index] = 0 ;//甯ч暱搴� + index++ ; + bsHead[index] = 0 ;//甯ч暱搴� + + index++ ; + bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ; + + index++ ; + bsHead[index] = ByteUtil.hex2Bytes(preCode)[0]; //鍔熻兘鐮佸煙 + + index++ ; + bsHead[index] = ByteUtil.hex2Bytes(sufCode)[0]; //鍔熻兘鐮佸煙 + + index++ ; + GlCreate.createRtuAddr4P206(rtuAddr, bsHead, index); + + return bsHead ; + } +} -- Gitblit v1.8.0