ZengTao
2024-04-29 7687eb6cc76ab8ca20b39e7567255939abc4ff66
springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -28,7 +28,7 @@
    FileInputStream fileInputStream;
    try {
      // 从文件中读取字节数据存入 fileInputStream
      fileInputStream = new FileInputStream("D:/Code/canadames/Alarm.json");
      fileInputStream = new FileInputStream("D:/canadames/Alarm.json");
      // 读取 fileInputStream 中字节并将其解码为字符
      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
      // 提高读取效率,在 BufferedReader 内包装 InputStreamReader
@@ -78,16 +78,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 +113,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 +137,10 @@
              }
            }
          }
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    }
  }
}