From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 07 四月 2025 15:18:51 +0800 Subject: [PATCH] 整理版本 --- pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd38.java | 80 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd38.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd38.java new file mode 100644 index 0000000..c64177c --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd38.java @@ -0,0 +1,80 @@ +package com.dy.pipIrrMwTestRtu.tcpClient.upData; + +import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; +import com.dy.common.util.ByteUtil; +import com.dy.common.util.DateTime; +import com.dy.pipIrrMwTestRtu.ServerProperties; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * @Author: liurunyu + * @Date: 2024/7/22 15:01 + * @Description + */ +public class UpCd38 extends UpData { + + private static final Logger log = LogManager.getLogger(UpCd38.class); + + public static void upData() { + try { + if (UpData.session != null && UpData.session.isConnected()) { + byte[] bs = createData(ServerProperties.rtuAddr); + UpData.upSend(bs); + } else { + log.error("鏈繛鎺ラ�氫俊涓棿浠讹紝涓嶈兘鍙戦�佹暟鎹�"); + } + } catch (Exception e) { + log.error("鍚戦�氫俊涓棿浠跺彂閫佹暟鎹骇鐢熷紓甯�", e); + } + } + + + /** + * 鏋勯�犳暟鎹� + * + * @return 瀛楄妭鏁扮粍 + * @throws Exception 寮傚父 + */ + private static byte[] createData(String rtuAddr) throws Exception { + byte[] bytes = creatHead(rtuAddr, "38", (byte)0xB0); + + byte[] bs = new byte[1] ; + bs[0] = (byte)0x00 ;//鎶ヨ閲戦楂樹綅 + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ; + ByteUtil.int2BCD_LE(40, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[1] ;//绉掗挓 + ByteUtil.int2BCD_LE(Integer.parseInt(DateTime.ss()), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ;//鍒嗛挓 + ByteUtil.int2BCD_LE(Integer.parseInt(DateTime.mm()), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ;//鏃堕挓 + ByteUtil.int2BCD_LE(Integer.parseInt(DateTime.HH()), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ;//鏃� + ByteUtil.int2BCD_LE(Integer.parseInt(DateTime.dd()), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[]{(byte)0x0A} ;// + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑 + + byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓� + + bytes = ByteUtil.bytesMerge(bytes, bsTail) ; + + return bytes ; + } +} + + -- Gitblit v1.8.0