From 52952d6feed8a9df738c652cda6c7d1ca50d2921 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 23 十一月 2023 17:20:23 +0800 Subject: [PATCH] 1、修改rtuAddr注释 2、实现开关阀自报协议 3、实现开阀工作报 4、《编码设计》 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Down.java | 39 ++++++++++++--------------------------- 1 files changed, 12 insertions(+), 27 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Down.java index 9a28b35..c314b69 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Down.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Down.java @@ -2,17 +2,15 @@ import com.dy.common.mw.protocol.*; import com.dy.common.mw.protocol.p206V1_0_0.*; +import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; import com.dy.common.util.ByteUtil; -import com.dy.common.util.ByteUtilUnsigned; -import com.dy.common.util.CRC8_for_2_0; -import com.dy.common.util.DateTime; @AnnotationCodeDown(ifAny={ CodeV1_0_1.cd_06 }) public class Cd_02_Down implements CodeParse { - //private static Logger log = LogManager.getLogger(Cd_XY_Down.class); + //private static Logger log = LogManager.getLogger(Cd_02_Down.class); @Override public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { @@ -21,7 +19,7 @@ MidResultToRtu midRs = new MidResultToRtu() ; midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О - midRs.rtuAddr = para.rtuAddr ;//IMEI鍙凤紙鐢典俊骞冲彴璁惧IMEI锛� + midRs.rtuAddr = para.rtuAddr ;//Rtu鍦板潃锛堢數淇″钩鍙拌澶嘔MEI锛� midRs.commandId = para.commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉 midRs.downCode = para.commandCode ;//涓嬭鍛戒护鍔熻兘鐮�; midRs.downBuffer = bs ;//涓嬭鍛戒护鏁版嵁 @@ -42,9 +40,9 @@ } /** * 鏋勯�犱笅琛屾暟鎹� - * @param para - * @return - * @throws Exception + * @param para 鍙傛暟 + * @return 瀛楄妭鏁扮粍 + * @throws Exception 寮傚父 */ public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception { CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; @@ -62,34 +60,21 @@ index++ ; bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; - String rtuAddr = para.rtuAddr ; - String rtuAddr1 = rtuAddr.substring(0, 6) ; - String rtuAddr2 = rtuAddr.substring(6) ; - index++ ; - ByteUtil.string2BCD_BE(bsHead, rtuAddr1, index) ; - index += 3 ; - - Integer rtuAddr2Int = Integer.parseInt(rtuAddr2) ; - ByteUtilUnsigned.short2Bytes_BE(bsHead, rtuAddr2Int.shortValue(), index); - index += 2 ; + GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); + index += 5 ; ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; byte[] bs = new byte[7] ; - bs[0] = (byte)0xF2 ; - ByteUtil.string2BCD_BE(bs, DateTime.yyMMddhhmmss(), 1) ; + bs[0] = (byte)0xF2 ;//鏁版嵁鍩燂細 1 涓瓧鑺傦紝F0 鐧诲綍锛� F1 閫�鍑虹櫥褰曪紝F2 鍦ㄧ嚎淇濇寔銆� + GlCreate.createTp(bs, 1); bytes = ByteUtil.bytesMerge(bsHead, bs) ; - int len = bytes.length + ProtocolConstantV206V1_0_0.lenTail; - bytes[ProtocolConstantV206V1_0_0.dataLenIndex] = (byte)len ; + GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑 - int crc = new CRC8_for_2_0().CRC8(bytes, ProtocolConstantV206V1_0_0.ctrlIndex, bytes.length -1) ; - bs = new byte[ProtocolConstantV206V1_0_0.lenTail] ; - bs[0] = (byte)crc ; - bs[1] = ProtocolConstantV206V1_0_0.P_Tail_Byte ; - bytes = ByteUtil.bytesMerge(bytes, bs) ; + bytes = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓� return bytes ; } -- Gitblit v1.8.0