wu
2023-09-11 184ae3b061765e8fbe54bcef06b67c6b4f2e024c
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
package com.example.springboot.component;
 
import cn.hutool.json.JSONObject;
 
import java.util.ArrayList;
import java.util.List;
 
public class Plcsign extends Thread {
  @Override
  public void run() {
    while (this != null) {
      try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
 
      List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.DBX0.0", 58);
 
      JSONObject jsonObject = new JSONObject();
      // jsonObject3.append("sig",
      // new short[] { 0, 0, 0, 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,
      // 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
      // });
      jsonObject.append("sig", plclist);
      WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign");
      if (sendwServer3 != null) {
        sendwServer3.sendMessage(jsonObject.toString());
      }
 
    }
  }
}