From f978d4ecdf83cbf7c8b778f1362b86be5aa510bd Mon Sep 17 00:00:00 2001
From: lxw <810412026@qq.com>
Date: 星期五, 10 二月 2023 17:04:26 +0800
Subject: [PATCH] 充放电数据解析和内阻数据解析

---
 src/main/java/com/whyc/res/RESDataInfo.java |   90 +++++++-------------------------------------
 1 files changed, 15 insertions(+), 75 deletions(-)

diff --git a/src/main/java/com/whyc/res/RESDataInfo.java b/src/main/java/com/whyc/res/RESDataInfo.java
index ff8f0bf..3627793 100644
--- a/src/main/java/com/whyc/res/RESDataInfo.java
+++ b/src/main/java/com/whyc/res/RESDataInfo.java
@@ -1,5 +1,9 @@
 package com.whyc.res;
 
+import com.whyc.util.StaticInf;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -8,91 +12,27 @@
 
 
 //FBS9600 鍐呴樆鏁版嵁闆�
+@Data
+@AllArgsConstructor
 public class RESDataInfo {
 	
-	public RESDataHead resDataHead;			//鍐呴樆鏁版嵁澶�
-	public List<RESData> resDatas;			//鍐呴樆鏁版嵁闆�
-	
-	public int parse_result = PARSE_RESULT_NULL;
-	
-	public static final int PARSE_RESULT_NULL = 0;			//鏈煡
-	public static final int PARSE_RESULT_SUCCESS = 1;		//瑙f瀽鎴愬姛
-	public static final int PARSE_RESULT_NOTFOUNDFILE = 2;	//鏂囦欢鏈壘鍒�
-	public static final int PARSE_RESULT_FILETYPEERR = 3;	//鏂囦欢鏍煎紡閿欒
-	public static final int PARSE_RESULT_FILEERROR = 4;		//鏂囦欢寮傚父
+	public RESDataHead resDataHead;					//鍐呴樆鏁版嵁澶�
+	public List<RESData> resDatas;					//鍐呴樆鏁版嵁闆�
+
+	public  int parse_result;
+	public int file_type = StaticInf.FILE_TYPE_RES;		//鏂囦欢绫诲瀷
 	
 	public RESDataInfo() {
 		resDataHead = new RESDataHead();			//鍐呴樆鏁版嵁澶�
-		resDatas = new ArrayList<>();			//鍐呴樆鏁版嵁闆�
+		resDatas = new ArrayList<>();				//鍐呴樆鏁版嵁闆�
 	}
 	
-	public void readResFile(String filePath)
-	{
-		
-    	FileInputStream fis = null;
-    	try {
-    		File f = new File(filePath);
-    		if(!filePath.endsWith(".BRES") && !filePath.endsWith(".bres")) {
-    			System.out.println("鏂囦欢鏍煎紡閿欒");
-    			parse_result = PARSE_RESULT_FILETYPEERR;
-    			return;
-    		}
-    		if(!f.exists()) {
-    			parse_result = PARSE_RESULT_NOTFOUNDFILE;
-    			System.out.println("鏂囦欢涓嶅瓨鍦�..........");
-    			return;
-    		}
-			fis = new FileInputStream(f);
-			byte[] buf = new byte[4];
-        	if(fis.read(buf, 0, buf.length) == RESDataHead.BYTE_LEN)
-        	{
-        		if(this.resDataHead.setHeadData(buf)) {
-        			parse_result = PARSE_RESULT_SUCCESS;
-        		}else {
-        			parse_result = PARSE_RESULT_FILEERROR;
-        		}
-        		while(true)
-        		{        			
-        			if(resDataHead.checkDataHead(fis))
-        			{
-        				byte[] databuf = new byte[RESData.DATABYTE_LEN];
-        				if(fis.read(databuf) == databuf.length)
-        				{
-        					RESData resData = new RESData();
-        					if(resData.setData(databuf)) {
-        						//System.out.println(resData);
-        						resDatas.add(resData);
-        					}
-        				}
-        			}
-        			if(fis.available() <1) {
-        				//System.out.println("瑙f瀽瀹屾垚");
-        				break;
-        				
-        			}
-        		}
-        	}else {
-        		parse_result = PARSE_RESULT_FILEERROR;
-        	}
-        		
-		} catch (IOException e) {
-			e.printStackTrace();
-		} finally {
-			if(null != fis)
-			{
-				try {
-					fis.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-	}
+
 	
 	
 	public static void main(String[] args) {
 		RESDataInfo info = new RESDataInfo();
-		info.readResFile("D:\\妗岄潰鏂囦欢澶囦唤\\鍏徃鍚勭璁惧璧勬枡\\FBS瀛樺偍鏂囦欢瑙f瀽/resdata.bres");
+		//info.readFileData("D:\\妗岄潰鏂囦欢澶囦唤\\鍏徃鍚勭璁惧璧勬枡\\FBS瀛樺偍鏂囦欢瑙f瀽/resdata.bres");
 	}
-	
+
 }

--
Gitblit v1.9.1