From 0d3f741da10c048bc4eb25c4b46b842759f54905 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期五, 26 一月 2024 13:52:24 +0800
Subject: [PATCH] 增加测试位 ,标志位,报警 DB区

---
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java |   95 ++++++++++++++++++++++++++++-------------------
 1 files changed, 57 insertions(+), 38 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
index 10e33c3..296a397 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -1,5 +1,6 @@
 package com.example.springboot.component;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.example.springboot.service.JdbcConnections;
@@ -24,11 +25,12 @@
     while (this != null) {
       try {
 
-        Thread.sleep(50);
+        Thread.sleep(100);
       } catch (InterruptedException e) {
         // \\ TODO Auto-generated catch block
         e.printStackTrace();
       }
+
       // if (S7control.getinstance().CheckConnected() == false) {
       spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
       spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
@@ -41,26 +43,38 @@
       // // TODO Auto-generated catch block
       // e.printStackTrace();
       // }
+
       // 鍑虹墖浠诲姟////////////////////////////////
       List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 鍑虹墖杞︾姸鎬�
       List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 鍑虹墖浠诲姟鏄惁鍚姩
+
+      boolean Plcout = spianService.listbool("DB106.64"); // 鍑虹墖璇锋眰瀛�
+      boolean Plcout2 = spianService.listbool("DB105.18"); // 鍑虹墖鍚姩
+      if (Plcout == false&&Plcout2==true) {
+        S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
+        System.out.println("鍏抽棴鍑虹墖鍚姩" + LocalDateTime.now());// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负0
+      }
+      boolean Plcadd = spianService.listbool("DB106.24"); // 杩涚墖璇锋眰瀛�
+      boolean Plcadd2 = spianService.listbool("DB105.16"); // 杩涚墖鍚姩
+      if (Plcadd == false&&Plcadd2==true) {
+        S7control.getinstance().WriteWord("DB105.16", (short) 0);//杩涚墖浠诲姟鍚姩鏀逛负0
+        System.out.println("鍏抽棴杩涚墖鍚姩" + LocalDateTime.now());// 杩涚墖浠诲姟鍙戦�佸瓧鏀逛负0
+      }
+      
+
+
       // StringBuilder writedstrIdOut = new StringBuilder();
       // 鑾峰彇宸蹭笅鍙戠殑鍑虹墖id
       byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14);
       String writedstrIdOut = new String(writedglassidbytesOut);
 
-      boolean outstate = false;// 鍑虹墖杞︾┖闂插垽鏂�
-      boolean outstate1 = false;// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
-      if (outlist != null && outlist1 != null) {
-
-        outstate = outlist.contains((short) 0);// 鍑虹墖杞︾┖闂插垽鏂� 褰撳嚭鐗囪溅绌洪棽鏃朵负true
-        outstate1 = outlist1.contains((short) 1);// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔� 褰撳嚭鐗囪溅浠诲姟鍚姩鏃朵负true
-
+   
+      if (Plcout == true) {
         // 鍒ゆ柇褰撳墠鏄惁鏈夋湭鎵ц鐨勪换鍔�
-        int outnum = spianMapper.SelectOutSliceshu();
-        int cageoutsum = spianMapper.Selectcageout(3);
+        int outnum = spianMapper.SelectOutSliceshu();//鏄惁鏈夋鍦ㄥ嚭鐗囩殑浠诲姟
+        int cageoutsum = spianMapper.Selectcageout(3);//绗煎瓙鍐呮槸鍚﹁繕鏈夊湪鍑虹墖鐨勭幓鐠�
         // 褰撴病鏈変换鍔℃墽琛屽苟涓斿嚭鐗囪溅绌洪棽鏃�
-        if (outnum == 0 && outstate == true && Plchome.isAllowQueue == true && cageoutsum == 0) {
+        if (outnum == 0 &&  Plchome.isAllowQueue == true && cageoutsum == 0) {
           // 鍒ゆ柇閾濇鍑虹墖闃熷垪琛ㄦ槸鍚︽湁寰呭嚭鐗囩殑鐜荤拑
           String outglassid = spianMapper.SelectOutSlice();
           // 褰撴湁寰呭嚭鐗囩殑鐜荤拑鏃�
@@ -71,18 +85,13 @@
             if (glassdisabled == 0) {
               spianService.selectout2(outglassid);
               Plchome.isQueueWarning = false;
-              outstate = false;
             } else { // 绂佺敤鏇存敼鐘舵�佸脊鍑烘彁绀�
               Plchome.isQueueWarning = true;
             }
 
           }
         }
-        if (outstate == true) {// 褰撳嚭鐗囪溅绌洪棽鏃�,涓斿嚭鐗囧惎鍔ㄤ负1鏃讹紝浠诲姟鍚姩鏀逛负0
-          if (outstate1 == true) {
-            S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
-          }
-        }
+     
       }
 
       ///////////// 杩涚墖浠诲姟
@@ -92,28 +101,46 @@
 
       boolean B01backs = spianService.listbool("DB106.60");// b01姹囨姤
       boolean B02backs = spianService.listbool("DB106.62");// b02姹囨姤
-
       StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1鐨勭幓鐠僫d
       StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02鐨勭幓鐠僫d
 
       // 褰撹繘鐗囧皬杞﹀畬鎴愪换鍔℃椂
       if (B01backs == true) {
-        // 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
-        // spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
-        // S7control.getinstance().WriteWord("DB106.60", (short) 0);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负0
-        boolean yingda = spianService.listbool("DB106.60");// b01姹囨姤
-        System.out.println("姹囨姤鏃禕01|绗�" + aaa + "娆�" + B01glassid + "搴旂瓟" + yingda);
-        aaa += 1;
+        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+        int HB = spianMapper.SelectHB(B01glassid.toString());
+        if (HB > 0) {
+          // 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
+          S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+          boolean yingda = spianService.listbool("DB105.48");// b01姹囨姤
+          if (yingda == true) {
+            spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
+          }
+          System.out.println("姹囨姤鏃禕01|绗�" + aaa + "娆�" + B01glassid + "搴旂瓟" + yingda);
+          aaa += 1;
+        }
+
+      }else{
+        S7control.getinstance().WriteWord("DB105.48", (short) 0);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
       }
 
       // 褰撳嚭鐗囧皬杞﹀畬鎴愪换鍔℃椂
       if (B02backs == true) {
-        // 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
-        // spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
-        // S7control.getinstance().WriteWord("DB106.62", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
+        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+        int HB = spianMapper.SelectHB(B02glassid.toString());
         System.out.println("姹囨姤鏃禕02|" + B02glassid);
-        boolean yingda1 = spianService.listbool("DB106.62");// b02姹囨姤
-        System.out.println("姹囨姤鏃禕02|绗�" + aaa + "娆�" + B02glassid + "搴旂瓟" + yingda1);
+        if (HB > 0) {
+          // 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
+
+          S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
+          System.out.println("姹囨姤鏃禕02ID|" + B02glassid);
+          boolean yingda = spianService.listbool("DB105.50");// b02姹囨姤
+          if (yingda == true) {
+            spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
+          }
+          System.out.println("姹囨姤鏃禕02|绗�" + aaa + "娆�" + B02glassid + "搴旂瓟" + yingda);
+        }
+      }else{
+         S7control.getinstance().WriteWord("DB105.50", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
       }
 
 
@@ -139,6 +166,7 @@
         }
 
       }
+
       if (queueid2 != null) {
         // 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛�
         if (glass2 == null) {
@@ -152,15 +180,6 @@
         }
 
       }
-
-      // if (outstate == true) { // 鍑虹墖杞︾姸鎬佺┖闂叉椂
-      // Integer state = spianMapper.Selectoutstate();
-      // String orderid = spianMapper.SelectOrderout();
-
-      // if (orderid != null && state == 0) {
-      // spianService.selectout(orderid);
-      // }
-      // }
 
       // 鏌ヨ鏁版嵁搴�
       // 鎺ㄩ�佸埌鍓嶇

--
Gitblit v1.8.0