From c2976b80e8850be2d28dc2132c6659856b871f3c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 08 五月 2025 21:10:42 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/CommonV202404.java | 88 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 78 insertions(+), 10 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/CommonV202404.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/CommonV202404.java index 2f27bbc..b27c2be 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/CommonV202404.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/CommonV202404.java @@ -1,8 +1,7 @@ package com.dy.common.mw.protocol.p206V202404; import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; -import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; -import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; + import com.dy.common.util.ByteUtil; import com.dy.common.util.ByteUtilUnsigned; import com.dy.common.util.CRC16; @@ -17,8 +16,8 @@ * @param ioSession 浼氳瘽 */ public void setThisProtocolArr2IoSession(IoSession ioSession){ - ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolName) ; - ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolVer) ; + ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V202404.protocolName) ; + ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V202404.protocolVer) ; } /** * 妫�鏌ュご @@ -123,8 +122,8 @@ * @throws Exception 寮傚父 */ public int parseDataLen4Ug(byte[] bs)throws Exception{ - int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V2.UG_dataLenIndex_start) ; - return len - ProtocolConstantV206V2.UG_lenCmd - ProtocolConstantV206V2.UG_lenRtuAddr ; + int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V202404.UG_dataLenIndex_start) ; + return len - ProtocolConstantV206V202404.UG_lenCmd - ProtocolConstantV206V202404.UG_lenRtuAddr ; } @@ -253,6 +252,44 @@ } /** + * 1涓狧EX + * 0x01:姝e父鍒峰崱寮�娉�/闃�鐢ㄦ按 + * 0x02:骞冲彴杩滅▼寮�娉�/闃�鐢ㄦ按 + * 0x08:鐢ㄦ埛杩滅▼寮�娉�/闃�鐢ㄦ按 + * 0x0b:宸℃鍗★紝 + * 0x04:鍏跺畠 + * @param type + * @return + */ + public static String openValveType(byte type){ + return switch (type) { + case 1 -> "鍒峰崱寮�闃�"; + case 2 -> "涓績绔欏紑闃�"; + case 8 -> "鐢ㄦ埛杩滅▼寮�闃�"; + case 11 -> "宸℃鍗″紑闃�"; + case 4 -> "鍏跺畠寮�闃�"; + default -> "鏈煡"; + }; + } + /** + * 0x01锛氬埛鍗″紑闃� => p206V1 1 + * 0x02锛氫腑蹇冪珯寮�闃� => p206V1 3 + * 0x08锛氱敤鎴稟pp杩滅▼寮�闃� => p206V1 3 + * 0x0B锛氬贰妫�鍗″紑闃� => p206V1 11 + * @param type + * @return + */ + public static byte openType2P206V1(byte type){ + return switch (type) { + case 1 -> (byte)1 ; + case 2 -> (byte)3 ; + case 8 -> (byte)8 ; + case 11 -> (byte)11 ; + default -> (byte)-1; + }; + } + + /** * 寰楀埌鍏冲紑闃�绫诲瀷鍚嶇О * 0x00:鍒峰崱闂� * 0x01:骞冲彴鍏� @@ -263,10 +300,10 @@ * 0x06:鍓╀綑姘撮噺涓嶈冻鍏� * 0x07:鍓╀綑閲戦涓�0鍏� * 0x08:寮�娉�/闃�鍚庣閬撴病鏈夋祦閲忓叧 - * 0x09:鎺夌數鍐嶄笂鐢靛叧锛� - * 0x0a:姘磋〃鐬椂娴侀噺涓�0鍏筹紝 - * 0x0b:鍒峰崱寮�娉碉紝杩滅▼鍏炽�� - * 0x0c:鐢垫睜浣庣數鍘嬪叧銆� + * 0x09:鎺夌數鍐嶄笂鐢靛叧 + * 0x0a:姘磋〃鐬椂娴侀噺涓�0鍏� + * 0x0b:鍒峰崱寮�娉碉紝杩滅▼鍏� + * 0x0c:鐢垫睜浣庣數鍘嬪叧 * @param type 瀛楄妭 * @return 鍚嶇О */ @@ -288,6 +325,37 @@ default -> "鏈煡"; }; } + /** + * 寰楀埌鍏冲紑闃�绫诲瀷鍚嶇О + * 0x00:鍒峰崱闂� => p206V1 2 + * 0x01:骞冲彴鍏� => p206V1 4 + * 0x02:APP鍏� => p206V1 4 + * 0x03:闈炴硶鍗″叧 => p206V1 12 + * 0x04:姘磋〃閫氳寮傚父鍏� => p206V1 6 + * 0x05:鐢佃〃寮傚父鍏� => p206V1 6 + * 0x06:鍓╀綑姘撮噺涓嶈冻鍏� => p206V1 5 + * 0x07:鍓╀綑閲戦涓�0鍏� => p206V1 5 + * 0x08:寮�娉�/闃�鍚庣閬撴病鏈夋祦閲忓叧 => p206V1 16 + * 0x09:鎺夌數鍐嶄笂鐢靛叧锛� => p206V1 7 + * 0x0a:姘磋〃鐬椂娴侀噺涓�0鍏筹紝 => p206V1 5 + * 0x0b:鍒峰崱寮�娉碉紝杩滅▼鍏炽�� => p206V1 9 + * 0x0c:鐢垫睜浣庣數鍘嬪叧銆� => p206V1 7 + * @param type 瀛楄妭 + * @return 鍚嶇О + */ + public static byte closeType2P206V1(byte type){ + return switch (type) { + case 0 -> (byte)2; + case 1,11 -> (byte)4; + case 2 -> (byte)9; + case 3 -> (byte)12; + case 4,5,10 -> (byte)6; + case 6,7 -> (byte)5; + case 8 -> (byte)16; + case 9,12 -> (byte)7; + default -> (byte)-1; + }; + } public static String ctrlDevType(String hex){ return switch (hex) { -- Gitblit v1.8.0