|
|
|
@ -5,10 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.websocket.OnClose;
|
|
|
|
|
import javax.websocket.OnMessage;
|
|
|
|
|
import javax.websocket.OnOpen;
|
|
|
|
|
import javax.websocket.Session;
|
|
|
|
|
import javax.websocket.*;
|
|
|
|
|
import javax.websocket.server.ServerEndpoint;
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArraySet;
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
@ -49,9 +46,11 @@ public class SimulationWebsocket {
|
|
|
|
|
//发送开始仿真的信息
|
|
|
|
|
String result = simulationService.getPlantData(message);
|
|
|
|
|
if ("Simulation Started".equals(result)) {
|
|
|
|
|
if (!isSimulationRunning) {
|
|
|
|
|
isSimulationRunning = true;
|
|
|
|
|
log.info("【仿真开始】");
|
|
|
|
|
scheduler.scheduleAtFixedRate(() -> {
|
|
|
|
|
try {
|
|
|
|
|
if (isSimulationRunning) {
|
|
|
|
|
String data = simulationService.getPlantData("SimulationProgress");
|
|
|
|
|
// 根据需要处理和发送获取到的数据
|
|
|
|
@ -60,10 +59,13 @@ public class SimulationWebsocket {
|
|
|
|
|
if ("1".equals(data) || "1.00".equals(data)) {
|
|
|
|
|
sendMessage("ending");
|
|
|
|
|
isSimulationRunning = false;
|
|
|
|
|
scheduler.shutdown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
isSimulationRunning = false;
|
|
|
|
|
}
|
|
|
|
|
}, 0, 10, TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sendMessage("Simulation Start Failed");
|
|
|
|
|
}
|
|
|
|
|