wuyouming666
2023-09-05 c7df23be1f204458883088c18cbe33a451b8e50d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.example.springboot.component;
 
import java.util.List;
 
import cn.hutool.json.JSONObject;
 
public class PlcHold extends Thread {
    @Override
    public void run() {
        while (this != null) {
            try {
 
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            List<Boolean> bitlist = S7control.getinstance().ReadBits("DB2.0.0", 100);
 
            List<Short> paramlist = S7control.getinstance().ReadWord("DB100.6", 1);
 
            //查询数据库
            //推送到前端
 
            JSONObject jsonObject = new JSONObject();
            jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5 });
            WebSocketServer sendwServer = WebSocketServer.sessionMap.get("talkvue");
            if (sendwServer != null) {
                sendwServer.sendMessage(jsonObject.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());
            }
        }
    }
}