ZengTao
2024-05-09 63574bf6cf94613385cb8d0e2c2beb1829f644b5
springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -2,6 +2,7 @@
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.FileInputStream;
@@ -15,6 +16,7 @@
import com.example.springboot.mapper.AlarmMapper;
@Slf4j
public class Plcalarm extends Thread {
  private AlarmMapper alarmMapper;
@@ -78,16 +80,12 @@
    while (this != null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
//      this.readValue();
//      String PlcAddress = this.name;
//      Integer Plccount = this.count;
        this.readValue();
      String PlcAddress = this.name;
      Integer Plccount = this.count;
      // 根据地址读取PCL数据
      List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71);
      List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", Plccount);
//      List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount);
      // System.out.println(plclist);
      // Boolean[] values = { false, false, true, false, true, false, true, false,
@@ -117,7 +115,8 @@
            }
            // 将Intlist转换为数组
            // System.out.println(Intlist);
//             System.out.println(Intlist);
//     System.out.println(Intlist.toArray().length);
            Integer[] shuzu1 = Intlist.toArray(new Integer[0]);
            // 定义的报警内容数组,获取json返回的集合
@@ -140,7 +139,10 @@
              }
            }
          }
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    }
  }
}