From 21989973eb90e0fbf60c60ef9343a117fa67d354 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期日, 28 四月 2024 08:55:56 +0800
Subject: [PATCH] 靳总离职前,应元谋二期项目要求(慧图),做了通信协议修改,在他离职后,从韩月处得到最新协议,并做了部分协议软件实现修改,发现新协议中有一些协议定义有重复,也有错误的,所以这版本协议未全部实现,但实现的部分可以用来测试测控一体阀(与段志强一起测试过)。目前情况下,这版本协议实现不能应用于实际项目中,如果必须实现,还需要结合硬件协议具体实现内容再实现通信中间件的协议解析与构造部分,还需要实现上行数据处理任务树部分。

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
index 8635450..eda37b9 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
@@ -131,6 +131,42 @@
 			throw new Exception("byte2Int鏃舵暟缁勮秺鐣�");
 		}
 	}
+
+	/**
+	 * 灏忕妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍浣庡瓧鑺傘��
+	 * 涓庢柟娉昩ytes2Int绠楁硶涓�鏍凤紝鍙槸鎶婇『搴忓弽杩囨潵
+	 * @param bs 瀛楄妭鏁扮粍
+	 * @param from 瀛楄妭鏁扮粍璧峰浣嶇疆
+	 * @param has3Byte 鏄惁鍖呭惈鏁版嵁涓嬫爣涓�3鐨勫瓧鑺傦紝濡傛灉涓嶅寘鍚疄闄呭鐞嗙殑鏄�3瀛楄妭鐨勬暣鏁�
+	 * @return
+	 */
+	public static long bytes2Int_LE(byte[] bs, int from, boolean has3Byte) throws Exception {
+		boolean b = isOutOfArrLength(bs.length, (from - 1) + 4);
+		if (!b) {
+			long s = 0;
+			long s0 = bs[from + 0] & 0xFF ;// 鏁版嵁鐨勬渶浣庝綅鍦ㄤ綆瀛楄妭
+			long s1 = bs[from + 1] & 0xFF ;
+			long s2 = bs[from + 2] & 0xFF ;
+			long s3 = 0L ;
+			if(!has3Byte){
+				s3 = bs[from + 3] & 0xFF ;
+			}
+
+
+			// S0涓嶅彉
+			s1 <<= 8;
+			s2 <<= 16;
+			s3 <<= 24;
+			s = s0 | s1 | s2 | s3;
+			if(s < 0){
+				//s = Integer.MAX_VALUE -s ;
+				s = Integer.MAX_VALUE * 2 + 1 + s + 1 ;
+			}
+			return s;
+		} else {
+			throw new Exception("byte2Int鏃舵暟缁勮秺鐣�");
+		}
+	}
 	/**
 	 * 澶х妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍楂樺瓧鑺傘��
 	 * 鏃犵鍙穝hort绫诲瀷杞崲鎴�2浣峛yte鏁扮粍

--
Gitblit v1.8.0