clll
2023-09-05 d6a26f8fee29a5d68466bb9d2fc716128292e030
提交后端界面
2个文件已修改
44 ■■■■ 已修改文件
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -2,6 +2,9 @@
import java.util.List;
import javax.websocket.Session;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
public class PlcHold extends Thread {
@@ -10,7 +13,7 @@
        while (this != null) {
            try {
                Thread.sleep(2000);
        Thread.sleep(10000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
@@ -22,20 +25,42 @@
            //查询数据库
            //推送到前端
      // Parameter
            JSONObject jsonObject = new JSONObject();
            jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5 });
            WebSocketServer sendwServer = WebSocketServer.sessionMap.get("talkvue");
      jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, });
      WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
            if (sendwServer != null) {
                sendwServer.sendMessage(jsonObject.toString());
            }
      // Action
      // JSONObject jsonObject2 = new JSONObject();
      // jsonObject2.append("acion",
      // new short[] { 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      // 1, 1, 1, 0, 0, });
      // WebSocketServer sendwServer2 = WebSocketServer.sessionMap.get("Action");
      // if (sendwServer2 != null) {
      // sendwServer2.sendMessage(jsonObject2.toString());
      // }
            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.append("params", new short[] { 0, 3, 2, 3, 4, 5 });
            WebSocketServer sendwServer2 = WebSocketServer.sessionMap.get("action");
            if (sendwServer2 != null) {
                sendwServer2.sendMessage(jsonObject2.toString());
      // Sign
      JSONObject jsonObject3 = new JSONObject();
      jsonObject3.append("sig",
          new short[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
              1, });
      WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign");
      if (sendwServer3 != null) {
        sendwServer3.sendMessage(jsonObject3.toString());
            }
      // State
      JSONObject jsonObject4 = new JSONObject();
      jsonObject4.append("sta", new short[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, });
      WebSocketServer sendwServer4 = WebSocketServer.sessionMap.get("State");
      if (sendwServer4 != null) {
        sendwServer4.sendMessage(jsonObject4.toString());
      }
        }
    }
}
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -5,7 +5,7 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import com.example.springboot.component.PlcHold;
import com.example.springboot.component.Plcaction;
@Component
@@ -17,6 +17,7 @@
       //
       System.out.println("启动完成");
    new PlcHold().start();
        new Plcaction().start();
    }