From 429f9d85eddbb07081c149d7156964337ba688aa Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 22 十一月 2023 15:28:40 +0800
Subject: [PATCH] 通信中间件开发,阶段性提交

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/PrefixedDataAvailableV1_0_1.java |   57 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/PrefixedDataAvailableV1_0_1.java
similarity index 75%
rename from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java
rename to pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/PrefixedDataAvailableV1_0_1.java
index 63ec806..e53f268 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/PrefixedDataAvailableV1_0_1.java
@@ -1,36 +1,36 @@
-package com.dy.common.mw.protocol.pMeterV1_0_1;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.mina.core.buffer.BufferDataException;
-import org.apache.mina.core.buffer.IoBuffer;
+package com.dy.common.mw.protocol.p206V1_0_0;
 
 import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus;
 import com.dy.common.mw.protocol.AnnotationPrefixedDataAvailable;
 import com.dy.common.mw.protocol.PrefixedDataAvailable;
 import com.dy.common.util.ByteUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.buffer.BufferDataException;
+import org.apache.mina.core.buffer.IoBuffer;
 
 
 @AnnotationPrefixedDataAvailable(
-		protocolName = ProtocolConstantV1_0_1.protocolName,
-		priority = ProtocolConstantV1_0_1.priority,
-		onLineDataMinLength = ProtocolConstantV1_0_1.onLineDataMinLength,
-		headMinLength = ProtocolConstantV1_0_1.headMinLength) 
-public class PrefixedDataAvailableV1_0_1  implements PrefixedDataAvailable {
+		protocolName = ProtocolConstantV206V1_0_0.protocolName,
+		priority = ProtocolConstantV206V1_0_0.priority,
+		onLineDataMinLength = ProtocolConstantV206V1_0_0.onLineDataMinLength,
+		headMinLength = ProtocolConstantV206V1_0_0.headMinLength)
+@SuppressWarnings("unused")
+public class PrefixedDataAvailableV1_0_1 implements PrefixedDataAvailable {
 
-	private static Logger log = LogManager.getLogger(PrefixedDataAvailableV1_0_1.class) ;
+	private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV1_0_1.class) ;
 	
-	private static String protocolName = ProtocolConstantV1_0_1.protocolName ;
+	private static final String protocolName = ProtocolConstantV206V1_0_0.protocolName ;
 
 
 	/**
 	 * 鍒嗘瀽涓婄嚎鏁版嵁(缃戠粶杩炴帴鍚庣涓�鍖呮暟鎹�)鏄惁鍙幏寰�
-	 * @param in
+	 * @param in IoBuffer
 	 * @param remain 涓�瀹氭椂澶т簬0鐨勬暟鎹�
 	 * @param minDataLength 鏈�灏忔暟鎹暱搴�
 	 * @param maxDataLength 鏈�澶ф暟鎹暱搴︼紝杈惧埌鎴栬秴杩囨闀垮害锛岃涓烘槸鍨冨溇鏁版嵁銆備緥濡傦細鏁版嵁澶撮儴鏄纭殑锛屼絾鍚堟硶鏁版嵁缁撳熬鎬讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
 	 * @return 涓嶆槸鏈崗璁暟鎹椂杩斿洖绌�
-	 * @throws Exception
+	 * @throws Exception 寮傚父
 	 */
 	public PrefixedDataAvailableStatus forOnLine(IoBuffer in, 
 			int remain,
@@ -49,11 +49,12 @@
 
 	/**
 	 * 鍒嗘瀽涓婄嚎鍚�(缃戠粶杩炴帴鍚庨潪绗竴鍖呮暟鎹�)鏄惁鍙幏寰�
-	 * @param in
-	 * @param protocolConf Rtu閰嶇疆
-	 * @param maxDataLength
-	 * @return
-	 * @throws Exception
+	 * @param in IoBuffer
+	 * @param remain  鍓╀綑
+	 * @param minDataLength 鏈�灏忔暟鎹暱搴�
+	 * @param maxDataLength 鏈�澶ф暟鎹暱搴�
+	 * @return PrefixedDataAvailableStatus
+	 * @throws Exception 寮傚父
 	 */
 	@Override
 	public PrefixedDataAvailableStatus forUpData(IoBuffer in, 
@@ -71,9 +72,11 @@
     }
 	/**
 	 * 杩涜鍒ゆ柇
-	 * @param preByte
-	 * @param maxDataLength
-	 * @return
+	 * @param preByte byte[]
+	 * @param minDataLength 鏈�灏忔暟鎹暱搴�
+	 * @param maxDataLength 鏈�澶ф暟鎹暱搴�
+	 * @return PrefixedDataAvailableStatus
+	 * @throws Exception 寮傚父
 	 */
 	private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{
 		int remain = preByte.length ;
@@ -98,14 +101,14 @@
 		}
 
 		Integer dataLen = parseCommon.parseDataLen(preByte) ;
-		
-		String headHex = ByteUtil.bytes2Hex(preByte, true) ;
-		
+
 		if(dataLen == null){
+			String headHex = ByteUtil.bytes2Hex(preByte, true) ;
 			throw new BufferDataException("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾涓ラ噸閿欒锛屽湪杩涜鏂寘涓庣矘鍖呮鏌ユ椂锛屾湭鑳藉緱鍒版暟鎹抚鐨勯暱搴︺��");
 		}
 		
         if (dataLen <= 0 || dataLen > maxDataLength) {
+			String headHex = ByteUtil.bytes2Hex(preByte, true) ;
             throw new BufferDataException("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾涓ラ噸閿欒锛屽湪杩涜鏂寘涓庣矘鍖呮鏌ユ椂锛屾暟鎹抚鐨勯暱搴�(" + dataLen + ")瓒呭嚭鍚堟硶鑼冨洿銆�");
         }
         
@@ -113,10 +116,12 @@
         	//涓嶆柇涓嶇矘
             return new PrefixedDataAvailableStatus().completed(dataLen) ;
         }else if(remain > dataLen){
+			String headHex = ByteUtil.bytes2Hex(preByte, true) ;
         	log.warn("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾鍙戠敓绮樺寘鐜拌薄銆�") ;
             return new PrefixedDataAvailableStatus().adjoined(dataLen) ;
         }else{
         	// remain < dataLen
+			String headHex = ByteUtil.bytes2Hex(preByte, true) ;
         	log.warn("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾鍙戠敓鏂寘鐜拌薄銆�") ;
             return new PrefixedDataAvailableStatus().breaked() ;
         }

--
Gitblit v1.8.0