Browse Source

增加测试类

menglu 3 years ago
parent
commit
d5157d78e2

+ 10 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -10,6 +10,7 @@ import javax.annotation.PostConstruct;
 import org.springframework.stereotype.Component;
 
 import com.persagy.ibms.core.util.KeywordUtil;
+import com.persagy.ibms.data.sdk.test.CheckTest;
 import com.persagy.ibms.data.sdk.util.Constant;
 import com.persagy.ibms.data.sdk.util.DeamonUtil;
 import com.persagy.ibms.data.sdk.util.RWDDownloadUtil;
@@ -108,6 +109,15 @@ public class DaemonThread extends Thread {
 			}
 		}
 
+		if (Constant.test) {
+			try {
+				CheckTest.test(new String[0]);
+			} catch (Exception e) {
+				log.error(e.getMessage(), e);
+			}
+			return;
+		}
+
 		try {
 			if (Constant.iot_websocket_url != null) {
 				log.warn("iot-websocket");

+ 60 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/test/CheckTest.java

@@ -0,0 +1,60 @@
+package com.persagy.ibms.data.sdk.test;
+
+import java.io.File;
+import java.util.List;
+
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.ibms.core.data.SceneObject;
+import com.persagy.ibms.core.data.SceneProperty;
+import com.persagy.ibms.core.util.ComputeUtil;
+import com.persagy.ibms.core.util.FastJsonReaderUtil;
+import com.persagy.ibms.core.util.FastJsonUtil;
+import com.persagy.ibms.data.sdk.util.Constant;
+import com.persagy.ibms.data.sdk.util.RWDLoadUtil;
+import com.persagy.ibms.data.sdk.util.RepositoryContainer;
+import com.persagy.ibms.data.sdk.util.RepositoryImpl;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class CheckTest {
+
+	public static void test(String[] args) throws Exception {
+		Constant.debug = false;// 调试模式设为true
+		RepositoryImpl Repository = RepositoryContainer.instance;
+		Repository.use_thread = !Constant.debug;
+		Repository.RepositoryBase = RepositoryContainer.RepositoryBase;
+		{
+			Repository.property2SDV_enable = true;
+			Repository.property2SDV.clear();
+
+			log.warn("LoadConfig");
+			SceneObject sceneObject = new SceneObject();
+			JSONObject sceneJSON = FastJsonReaderUtil.Instance().ReadJSONObject(new File(Constant.getLatestPath(Constant.config, false)));
+			FastJsonUtil.Set_JavaObject(sceneJSON, sceneObject);
+			Repository.sceneObject = sceneObject;
+			ComputeUtil.RefreshRepository(Repository);
+			List<List<SceneProperty>> spListList = ComputeUtil.computePrepare(Repository);
+
+			log.warn("LoadPhysicalWorld");
+			RWDLoadUtil.LoadPhysicalWorld(Repository);
+			log.warn("LoadReference");
+			RWDLoadUtil.LoadReference(Repository);
+			if (Constant.zkt_physical_world_enable) {
+				log.warn("LoadZKTPhysicalWorld");
+				RWDLoadUtil.LoadZKTPhysicalWorld(Repository);
+			}
+			if (Constant.ibms_physical_world_enable) {
+				log.warn("LoadIBMSPhysicalWorld");
+				RWDLoadUtil.LoadIBMSPhysicalWorld(Repository);
+			}
+			log.warn("computeAll");
+			ComputeUtil.computeAll(Repository, spListList);
+
+			Repository.property2SDV_enable = false;
+			Repository.property2SDV.clear();
+		}
+		log.warn("compute finish");
+		RepositoryContainer.RepositoryBase.compute_finish = true;
+	}
+}

+ 1 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/Constant.java

@@ -18,6 +18,7 @@ import java.util.*;
 @SuppressWarnings({ "rawtypes" })
 @Slf4j
 public class Constant {
+	public static boolean test = false;
 	public static boolean debug = false;
 
 	public static String sdk_version;