From 346b480ab7848c742065e9bf989abaf43b515613 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 21 四月 2025 15:05:26 +0800 Subject: [PATCH] 获取轮灌组详情 --- pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Close.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Close.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Close.java new file mode 100644 index 0000000..dfe1ecd --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Close.java @@ -0,0 +1,109 @@ +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.pipIrrMwTestRtu.ServerProperties; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * @Author: liurunyu + * @Date: 2024/7/15 14:58 + * @Description + */ +public class UpCd83Close extends UpData { + + private static final Logger log = LogManager.getLogger(UpCd83Close.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 { + UpConstant.addValve();//璋冩暣娴侀噺 + + byte[] bytes = creatHead(rtuAddr, "83", (byte)0xB0); + + byte[] bs = new byte[1] ; + bs[0] = (byte)0x02 ;//鍒峰崱鍏抽榾 + + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[5] ;//绱娴侀噺 + ByteUtil.int2BCD_LE(UpConstant.totalAmount, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[8] ;//IC鍗$紪鍙� + GlCreate.createIcCardNo(ServerProperties.icCardNo, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[4] ;//IC鍗″湴鍧� + ByteUtil.hex2Bytes_LE(ServerProperties.icCardAddr, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰� + ByteUtil.int2BCD_LE(UpConstant.remainMoney, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[6] ;//寮�闃�鏃堕棿 + GlCreate.createTp(UpConstant.openValveDt(), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + UpConstant.clearOpenValveDt();//娓呯┖寮�闃�鏃堕棿 + + bs = new byte[6] ;//鍏抽榾鏃堕棿 + GlCreate.createTp(UpConstant.closeValveDt(), bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[5] ;//鐢ㄦ按鎴锋湰娆$敤姘撮噺 + ByteUtil.int2BCD_LE(UpConstant.thisAmount, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[4] ;//鐢ㄦ按鎴锋湰娆℃秷璐归噾棰� + ByteUtil.int2BCD_LE(UpConstant.thisMoney, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ;//鐢ㄦ按鎴锋湰娆$敤姘存椂闀� + ByteUtil.int2BCD_LE(UpConstant.thisTime, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ;//姘翠环绫诲瀷 + bs[0] = ByteUtil.int2BCD_LE (1)[0] ; + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ;//姘翠环 + ByteUtil.int2BCD_LE(UpConstant.thisPrice, bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[1] ;//鍗$被鍨� + bs[0] = ByteUtil.int2BCD_LE (1)[0] ; + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[6] ;//鎺у埗鍣ㄦ椂閽� + GlCreate.createTp(bs, 0); + 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