wuyouming666
2023-09-07 f193e7058f32f759d5a5e8c4a6b1f71c7fb2f3a8
springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
@@ -3,7 +3,9 @@
import cn.hutool.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Plcaction extends Thread {
    private static final long SEND_INTERVAL = 2000; // 发送消息的时间间隔
@@ -39,9 +41,18 @@
        if (sendwServer != null) {
            List<Boolean> paramlist = S7control.getinstance().ReadBits("DB100.DBW", 12);
            List<Boolean> paramlist2 = new ArrayList<>(Arrays.asList(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
            List<Integer> binaryList = new ArrayList<>();
            for (Boolean value : paramlist2) {
                int binaryValue = value ? 1 : 0;
                binaryList.add(binaryValue);
            }
            //        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}
            JSONObject jsonObject = new JSONObject();
            jsonObject.append("params", 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});
            jsonObject.append("params", binaryList);
            sendwServer.sendMessage(jsonObject.toString());
        }