From f3aa497f5b4abea42792ec2e89433a78e967b406 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期二, 23 一月 2024 16:59:38 +0800
Subject: [PATCH] 添加铝框线交互

---
 CanadaMes-ui/src/views/home/index.vue                                           |   17 
 CanadaMes-ui/src/views/Electrical/Servomanual.vue                               |    4 
 CanadaMes-ui/src/views/Electrical/Sign.vue                                      |    4 
 CanadaMes-ui/src/views/Electrical/ManualonePosition.vue                         |    4 
 CanadaMes-ui/src/views/Electrical/Parameter2.vue                                |    4 
 CanadaMes-ui/src/views/Electrical/State.vue                                     |    4 
 CanadaMes-ui/src/views/Electrical/InteractionState.vue                          |    4 
 springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java    |    2 
 springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java     |   91 +++---
 Alarm.json                                                                      |  123 +++++++++
 CanadaMes-ui/src/views/Electrical/Positioning1.vue                              |    4 
 CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue                 |    4 
 CanadaMes-ui/src/views/Electrical/alarm.vue                                     |    2 
 CanadaMes-ui/src/views/Electrical/Action.vue                                    |    4 
 springboot-vue3/src/main/java/com/example/springboot/component/S7controlLK.java |  456 +++++++++++++++++++++++++++++++++++
 CanadaMes-ui/src/views/Electrical/ServoManualone.vue                            |    4 
 16 files changed, 659 insertions(+), 72 deletions(-)

diff --git a/Alarm.json b/Alarm.json
index 89bf615..e6d4d0c 100644
--- a/Alarm.json
+++ b/Alarm.json
@@ -497,11 +497,132 @@
       "type": "3",
       "page": "1"
     }
+    ,{
+      "name": "B02.SR right in pos error",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 servo turn  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 servo turn  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 servo travel  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 servo travel  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "B01 servo travel  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "B02 servo travel  homed",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "resetDelay",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 travel Negative limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 travel Positive limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 turn up limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A01 turn down limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 travel Negative limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 travel Positive limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 turn up limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    } ,{
+      "name": "A02 turn down limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    },{
+      "name": "B01 travel Negative limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    },{
+      "name": "B01 travel Positive limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    },{
+      "name": "B02 travel Negative limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    },{
+      "name": "B02 travel Positive limit",
+      "value": "1",
+      "state": "1",
+      "type": "3",
+      "page": "1"
+    }
   ],
   "address": [
     {
       "name": "DB104.0.0",
-      "count": 71
+      "count": 91
     }
   ]
 }
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/Action.vue b/CanadaMes-ui/src/views/Electrical/Action.vue
index 14bdbb6..35546ef 100644
--- a/CanadaMes-ui/src/views/Electrical/Action.vue
+++ b/CanadaMes-ui/src/views/Electrical/Action.vue
@@ -4,8 +4,8 @@
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
       <router-link to="/Electrical/ServoManualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
index 053ff12..ca7eb8f 100644
--- a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
+++ b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -3,8 +3,8 @@
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/InteractionState.vue b/CanadaMes-ui/src/views/Electrical/InteractionState.vue
index 6bc920a..a773eb9 100644
--- a/CanadaMes-ui/src/views/Electrical/InteractionState.vue
+++ b/CanadaMes-ui/src/views/Electrical/InteractionState.vue
@@ -8,13 +8,13 @@
         active-class="blue-button"
         >{{ $t("Alarm") }}</router-link
       >
-      <router-link
+      <!-- <router-link
         to="/Electrical/State"
         tag="el-button"
         type="text"
         active-class="blue-button"
         >{{ $t("State") }}</router-link
-      >
+      > -->
       <!-- <router-link
         to="/Electrical/Action"
         tag="el-button"
diff --git a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
index 79d41fa..74eda79 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -3,8 +3,8 @@
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter2.vue b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
index df63997..da4a5b6 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter2.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
@@ -8,13 +8,13 @@
         active-class="blue-button"
         >{{ $t("Alarm") }}</router-link
       >
-      <router-link
+      <!-- <router-link
         to="/Electrical/State"
         tag="el-button"
         type="text"
         active-class="blue-button"
         >{{ $t("State") }}</router-link
-      >
+      > -->
       <!-- <router-link
         to="/Electrical/Action"
         tag="el-button"
diff --git a/CanadaMes-ui/src/views/Electrical/Positioning1.vue b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
index e777694..c38c23a 100644
--- a/CanadaMes-ui/src/views/Electrical/Positioning1.vue
+++ b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
@@ -8,13 +8,13 @@
         active-class="blue-button"
         >{{ $t("Alarm") }}</router-link
       >
-      <router-link
+      <!-- <router-link
         to="/Electrical/State"
         tag="el-button"
         type="text"
         active-class="blue-button"
         >{{ $t("State") }}</router-link
-      >
+      > -->
       <!-- <router-link
         to="/Electrical/Action"
         tag="el-button"
diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index 3eae7c3..922ffff 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -8,13 +8,13 @@
         active-class="blue-button"
         >{{ $t("Alarm") }}</router-link
       >
-      <router-link
+      <!-- <router-link
         to="/Electrical/State"
         tag="el-button"
         type="text"
         active-class="blue-button"
         >{{ $t("State") }}</router-link
-      >
+      > -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
         }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/Servomanual.vue b/CanadaMes-ui/src/views/Electrical/Servomanual.vue
index a3fed75..45eab45 100644
--- a/CanadaMes-ui/src/views/Electrical/Servomanual.vue
+++ b/CanadaMes-ui/src/views/Electrical/Servomanual.vue
@@ -3,8 +3,8 @@
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/Sign.vue b/CanadaMes-ui/src/views/Electrical/Sign.vue
index 160e9f0..ed8284f 100644
--- a/CanadaMes-ui/src/views/Electrical/Sign.vue
+++ b/CanadaMes-ui/src/views/Electrical/Sign.vue
@@ -5,8 +5,8 @@
 
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/State.vue b/CanadaMes-ui/src/views/Electrical/State.vue
index 585edd4..ecb1563 100644
--- a/CanadaMes-ui/src/views/Electrical/State.vue
+++ b/CanadaMes-ui/src/views/Electrical/State.vue
@@ -5,8 +5,8 @@
 
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
       }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+      }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
diff --git a/CanadaMes-ui/src/views/Electrical/alarm.vue b/CanadaMes-ui/src/views/Electrical/alarm.vue
index 4c3eff5..b5cc575 100644
--- a/CanadaMes-ui/src/views/Electrical/alarm.vue
+++ b/CanadaMes-ui/src/views/Electrical/alarm.vue
@@ -4,7 +4,7 @@
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
 
       <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') }}</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link>
+      <!-- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link> -->
       <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link> -->
       <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') }}</router-link> -->
     <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') }}</router-link>
diff --git a/CanadaMes-ui/src/views/home/index.vue b/CanadaMes-ui/src/views/home/index.vue
index 48158a8..64b1e31 100644
--- a/CanadaMes-ui/src/views/home/index.vue
+++ b/CanadaMes-ui/src/views/home/index.vue
@@ -1011,7 +1011,7 @@
             reset: false,
             isQueueWarning: false,
             CurrentFrame: [],
-            DeviceList: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+            DeviceList: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
             GlassIdList: [],
             Scanningmethod: true,
             CurrrentGlassId: ""
@@ -1045,12 +1045,14 @@
                     //console.log("鏀跺埌鏁版嵁====" + msg.data);
                     let obj = JSON.parse(msg.data);
                     if (obj.params != null) {
-
-                        this.car1 = 145 + 8.15 * Math.abs(obj.params[0][0] - this.carlist[0]['start']) / Math.abs(this.carlist[0]['end'] - this.carlist[0]['start']) * 100;
-                        this.car2 = 210 + 8.15 * Math.abs(obj.params[0][1] - this.carlist[1]['start']) / Math.abs(this.carlist[1]['end'] - this.carlist[1]['start']) * 100;
+                        var zhi1=obj.params[0][0];
+                        var zhi2=obj.params[0][1];
+                        this.car1 = 145 + 8.15 * Math.abs(zhi1 - this.carlist[0]['start']) / Math.abs(this.carlist[0]['end'] - this.carlist[0]['start']) * 100;
+                        this.car2 = 210 + 8.15 * Math.abs(zhi2 - this.carlist[1]['start']) / Math.abs(this.carlist[1]['end'] - this.carlist[1]['start']) * 100;
                         // this.car1 = 210 + 11.25 * (obj.params[0][1]-this.carlist[1]['start'])/(this.carlist[1]['end']-this.carlist[1]['start'])*100;
                         // this.car2 = 300 + 11.25 * (obj.params[0][1]-this.carlist[1]['start'])/(this.carlist[1]['end']-this.carlist[1]['start'])*100;
                     }
+                    
                     this.tableData = obj.tableData[0];
                     this.cagelist1 = obj.cagelist1[0];
                     this.cagelist2 = obj.cagelist2[0];
@@ -1072,10 +1074,11 @@
 
                     //鏌ヨ褰撳墠閾濇淇℃伅
                     this.CurrentFrame = obj.CurrentFrame;
+                    
                     //鑾峰彇璁惧鐘舵��
-                    if (obj.DeviceList != null) {
-                        this.DeviceList = obj.DeviceList[0];
-                    }
+                    // if (obj.DeviceList != null) {
+                    //     this.DeviceList = obj.DeviceList[0];
+                    // }
                     //鑾峰彇璁惧涓婄殑鐜荤拑id
                     if (obj.GlassIdList != null) {
                         this.GlassIdList = obj.GlassIdList[0];
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
index 2d0c98d..4de113f 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -28,7 +28,7 @@
     FileInputStream fileInputStream;
     try {
       // 浠庢枃浠朵腑璇诲彇瀛楄妭鏁版嵁瀛樺叆 fileInputStream
-      fileInputStream = new FileInputStream("D:/canadames/Alarm.json");
+      fileInputStream = new FileInputStream("D:/code/canadames/Alarm.json");
       // 璇诲彇 fileInputStream 涓瓧鑺傚苟灏嗗叾瑙g爜涓哄瓧绗�
       InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
       // 鎻愰珮璇诲彇鏁堢巼锛屽湪 BufferedReader 鍐呭寘瑁� InputStreamReader
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
index ba8ef60..d81c8d7 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -54,21 +54,19 @@
     @Override
     public void run() {
         while (this != null) {
+            JSONObject jsonObject = new JSONObject();
             try {
                 Thread.sleep(1000);
-
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-            JSONObject jsonObject = new JSONObject();
-
-            // 娉ㄥ叆mapper
+                // 娉ㄥ叆mapper
 
             homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
             spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
             spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
             outSliceServive = WebSocketServer.applicationContext.getBean(OutSliceServive.class);
             north_Glass_Buffer1Service = WebSocketServer.applicationContext.getBean(North_Glass_Buffer1Service.class);
+            storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
+            dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
+
             // 绗煎瓙浣跨敤鎯呭喌
             List<StorageCage> tableData = homeMapper.selectAll();
             jsonObject.append("tableData", tableData);
@@ -119,41 +117,46 @@
             Out_slice CurrentFrame = outSliceServive.SelectCurrentFrame();
             jsonObject.append("CurrentFrame", CurrentFrame);
 
-            // List<Short> listd17 = S7control.getinstance().ReadWord("DB17.0",10);
-            // String id=spianService.queGlassid("DB17.10", 14).toString();
-            //
+            // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16));
+            // String J01id = new String( S7controlLK.getinstance().ReadByte("DB17.22",14));
+
+            
+
+            
+            
+
+           
 
             // 閾濇绾夸氦浜�
-            try {
-                if (CurrentFrame != null) {
-                    spianService.outmesid(CurrentFrame.getBarCode(), "DB17.0");
-                }
-
-                List<Short> framerequests = S7control.getinstance().ReadWord("閾濇id璇锋眰瀛楀湴鍧�", 1);
-                for (Short framerequest : framerequests) {
-                    if (framerequest == 1) {
-                        // 閾濇id
-                        String franmeno = spianService.queGlassid("DB17.10", 14).toString();
-                        String position;
-                        try {
-                            position = dbserve.SelectPositionByFrameBarcode(franmeno);
-                        } catch (SQLException e) {
-                            // TODO Auto-generated catch block
-                            position = "0";
-                            e.printStackTrace();
-                        }
-                        Short send;
-                        if (position == "0") {
-                            send = 0;
-                        } else {
-                            send = 1;
-                        }
-                        S7control.getinstance().WriteWord("閾濇缈昏浆鍙戦�佸湴鍧�", (short) send);
-                    }
-                }
-            } catch (Exception e) {
-                // TODO: handle exception
+            if (CurrentFrame != null) {
+                S7controlLK.getinstance().writeStrings(CurrentFrame.getBarCode(),"DB17.0");
             }
+            String E01id=S7controlLK.getinstance().readStrings("DB17.0");
+            String J01id=S7controlLK.getinstance().readStrings("DB17.22");
+            
+            List<Short> liststates=S7controlLK.getinstance().ReadWord("DB17.38", 1);
+            List<Short> liststate=S7controlLK.getinstance().ReadWord("DB17.20", 1);
+            Short framerequest = liststate.get(0);
+                if (framerequest == 1) {
+                    // 閾濇id
+                    String position;
+                    try {
+                        position = dbserve.SelectPositionByFrameBarcode(J01id);
+                    } catch (SQLException e) {
+                        // TODO Auto-generated catch block
+                        position = "0";
+                        e.printStackTrace();
+                    }
+                    Short send;
+                    if (position.equals("0")) {
+                        send = 0;
+                    } else {
+                        send = 1;
+                    }
+                    S7controlLK.getinstance().WriteWord("DB17.38", (short) send);
+                }
+            
+            
 
             if (S7control.getinstance().CheckConnected() == true) {
                 // 鑾峰彇褰撳墠鎵爜鏂瑰紡
@@ -211,7 +214,6 @@
                     if (inglassInfo.size() > 0) {
                         jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
                     }
-
                 }
                 // // 鑾峰彇閾濇idDB106.DBW64锛屾坊鍔犲埌鍑虹墖闃熷垪
                 // String frameno="X21763329601FB";
@@ -268,8 +270,13 @@
                 }
             }
 
-            storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
-            dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            
+
+            
+            
             boolean dbconnected = false;
             try {
                 dbserve.getConn();
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/S7controlLK.java b/springboot-vue3/src/main/java/com/example/springboot/component/S7controlLK.java
new file mode 100644
index 0000000..ac613d4
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/S7controlLK.java
@@ -0,0 +1,456 @@
+package com.example.springboot.component;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+import java.sql.Time;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import com.google.common.primitives.Bytes;
+import org.apache.ibatis.jdbc.Null;
+
+public class S7controlLK {
+
+    S7PLC s7PLC; // PLC閫氳绫诲疄渚�
+    private EPlcType plcType = EPlcType.S1500; // 瑗块棬瀛怭LC绫诲瀷
+    private String ip = "192.168.10.101"; // plc ip鍦板潃
+    private int port = 102; // plc 绔彛鍙�
+
+    private static volatile S7controlLK instance = null;
+
+    private S7controlLK() {
+        if (s7PLC == null)
+            s7PLC = new S7PLC(plcType, ip, port, 0, 0);
+    }
+
+    // 鍗曚緥妯″紡 鑾峰彇绫荤殑鍞竴瀹炰緥
+    public static S7controlLK getinstance() {
+        if (instance == null) {
+            synchronized (S7controlLK.class) {
+                if (instance == null)
+                    instance = new S7controlLK();
+            }
+        }
+        return instance;
+    }
+
+    /**
+     * 鍏抽棴瑗块棬瀛恠7閫氳杩炴帴
+     */
+    public void CloseS7client() {
+        if (s7PLC == null)
+            s7PLC.close();
+        s7PLC.checkConnected();
+    }
+
+    /**
+     * s7閫氳杩炴帴鐘舵��
+     */
+    public boolean CheckConnected() {
+        return s7PLC.checkConnected();
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆涓�涓獁ord
+     * 
+     * @param address 鍦板潃
+     * @param data    word鐨勫��
+     */
+    public void WriteWord(String address, short data) {
+        if (s7PLC == null) {
+            return;
+        }
+        s7PLC.writeInt16(address, data);
+    }
+
+    /**
+     * 浠庢煇鍦板潃杩炵画 鍐欏叆澶氫釜word
+     * 
+     * @param address 鍦板潃
+     * @param datas   word鐨勫��
+     */
+    public void WriteWord(String address, List<Short> datas) {
+        if (s7PLC == null)
+            return;
+        // s7PLC.write(address, data);
+        List<String> addresslist = GetAddressList(address, datas.size(), 16);
+        MultiAddressWrite addressWrite = new MultiAddressWrite();
+        for (int i = 0; i < datas.size(); i++) {
+            addressWrite.addInt16(addresslist.get(i), datas.get(i));
+        }
+        s7PLC.writeMultiData(addressWrite);
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆澶氫釜word
+     * 
+     * @param address 鍦板潃
+     * @param datas   word鐨勫��
+     */
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆涓�涓狟it
+     * 
+     * @param address 鍦板潃
+     * @param data    Bit鐨勫��
+     */
+    public void WriteBit(String address, Boolean data) {
+        if (s7PLC == null)
+            return;
+        s7PLC.writeBoolean(address, data);
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆澶氫釜bit
+     * 
+     * @param address 鍦板潃
+     * @param datas   bit鐨勫��
+     */
+    public void WriteBit(List<String> address, List<Boolean> datas) {
+        if (s7PLC == null)
+            return;
+        // s7PLC.write(address, data);
+
+        MultiAddressWrite addressWrite = new MultiAddressWrite();
+        for (int i = 0; i < address.size(); i++) {
+            addressWrite.addBoolean(address.get(i), datas.get(i));
+        }
+        s7PLC.writeMultiData(addressWrite);
+    }
+
+    /**
+     * 浠庢煇鍦板潃杩炵画 鍐欏叆澶氫釜bit
+     * 
+     * @param address 鍦板潃
+     * @param datas   word鐨勫��
+     */
+    public void WriteBit(String address, List<Boolean> datas) {
+        if (s7PLC == null)
+            return;
+        // s7PLC.write(address, data);
+        List<String> addresslist = GetAddressList(address, datas.size(), 1);
+        MultiAddressWrite addressWrite = new MultiAddressWrite();
+        for (int i = 0; i < datas.size(); i++) {
+            addressWrite.addBoolean(addresslist.get(i), datas.get(i));
+        }
+        s7PLC.writeMultiData(addressWrite);
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆澶氫釜byte
+     * 
+     * @param address 鍦板潃
+     * @param datas   byte鐨勫��
+     */
+    public void WriteByte(String address, byte[] datas) {
+        if (s7PLC == null)
+            return;
+        // s7PLC.write(address, data);
+        s7PLC.writeByte(address, datas);
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 璇诲彇word缁撴灉闆�
+     * 
+     * @param address 鍦板潃
+     * @return 缁撴灉
+     */
+    public List<Short> ReadWord(List<String> address) {
+        if (s7PLC == null)
+            return null;
+
+        try {
+            return s7PLC.readInt16(address);
+        } catch (Exception e) {
+            System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+            return null;
+        }
+    }
+
+    private int getIndexFromAddress(String address) {
+
+        // 鍙互瑙f瀽鍑哄湴鍧�涓殑鏁板瓧閮ㄥ垎锛屽苟杞崲涓烘暣鏁�
+        return 0;
+    }
+
+    private String getAddressFromIndex(int index) {
+
+        // 鏁存暟杞崲涓哄湴鍧�鏍煎紡鐨勫瓧绗︿覆
+        return "";
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 璇诲彇word缁撴灉闆�
+     * 
+     * @param address 鍦板潃
+     * @param count   杩炵画璇诲灏戜釜word
+     * @return 缁撴灉
+     */
+    public List<Short> ReadWord(String address, int count) {
+        if (s7PLC == null)
+            return null;
+
+        List<String> addresslist = GetAddressList(address, count, 16);
+        try {
+            return s7PLC.readInt16(addresslist);
+        } catch (Exception e) {
+            System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+
+            return null;
+        }
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 璇诲彇byte缁撴灉闆�
+     * 
+     * @param address 鍦板潃
+     * @param count   杩炵画璇诲灏戜釜byte
+     * @return 缁撴灉
+     */
+    public byte[] ReadByte(String address, int count) {
+        if (s7PLC == null)
+            return null;
+        // List<String> addresslist = GetAddressList(address, count, 16);
+
+        try {
+            return s7PLC.readByte(address, count);
+        } catch (Exception e) {
+            // 澶勭悊寮傚父
+            System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+            return null;
+        }
+
+    }
+
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 鎸塨it浣� 0 flase 1 true 璇诲彇缁撴灉
+     *
+     * @param addresslist 鍦板潃闆�
+     * @return Boolean缁撴灉
+     */
+    public List<Boolean> ReadBits(List<String> addresslist) {
+        if (s7PLC == null)
+            return null;
+        return s7PLC.readBoolean(addresslist);
+    }
+
+    // 璇诲彇涓嶈繛缁湴鍧�bit
+    public List<Boolean> readBits(List<String> addressList) {
+        if (s7PLC == null || addressList.isEmpty()) {
+            return null;
+        }
+
+        List<Boolean> values = new ArrayList<>();
+        for (String address : addressList) {
+            try {
+                boolean value = s7PLC.readBoolean(address);
+                values.add(value);
+            } catch (Exception e) {
+                // 澶勭悊寮傚父
+                System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+            }
+        }
+
+        return values;
+    }
+
+    // 璇诲彇String
+    public List<String> readStrings(List<String> addressList) {
+        if (s7PLC == null) {
+            return null;
+        }
+        List<String> result = new ArrayList<>();
+        for (String address : addressList) {
+            try {
+                byte[] bytes = s7PLC.readByte(address, 14);
+                if (bytes != null) {
+                    String str = new String(bytes, StandardCharsets.UTF_8);
+                    result.add(str);
+                }
+            } catch (Exception e) {
+                System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+                result.add(null);
+            }
+        }
+
+        return result;
+    }
+
+    public List<String> readStringsandword(List<String> addressList) {
+        if (s7PLC == null) {
+            return null;
+        }
+        List<String> result = new ArrayList<>();
+        for (String address : addressList) {
+            try {
+                if (address.contains("-")) {
+                    address = address.substring(0, address.indexOf("-"));
+
+                    byte[] bytes = s7PLC.readByte(address, 14);
+                    if (bytes != null) {
+                        String str = new String(bytes, StandardCharsets.UTF_8);
+                        result.add(str);
+                    }
+
+                } else {
+                    Short value = s7PLC.readInt16(address);
+                    result.add(value.toString());
+
+                }
+            } catch (Exception e) {
+                System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+                result.add(null);
+            }
+        }
+
+        return result;
+    }
+
+    // 涓嶈繛缁湴鍧�鍐欏叆Word
+    public void WriteWord(List<String> address, List<Short> datas) {
+        if (s7PLC == null)
+            return;
+
+        for (int i = 0; i < address.size(); i++) {
+            String addr = address.get(i);
+            short data = datas.get(i);
+
+            if (addr.contains("-")) {
+                outmesid(String.valueOf(data), addr); // 鍗曠嫭澶勭悊甯︾牬鎶樺彿鐨勫湴鍧�
+            } else {
+                s7PLC.writeInt16(addr, data); // 灏嗘暟鎹啓鍏ュ崟涓湴鍧�
+            }
+        }
+    }
+
+    // 瀛楃涓插啓鍏�
+    public void outmesid(String data, String addr) {
+        // System.out.println("outmesid: " + data);
+        List<Byte> glassidlist = new ArrayList<>();
+        String[] parts = addr.split("-");
+        if (parts.length == 2) {
+            addr = parts[0]; // 鍙繚鐣� "-" 鍓嶉潰鐨勯儴鍒�
+        }
+        for (char iditem : data.toCharArray()) {
+            glassidlist.add(Byte.valueOf(String.valueOf(iditem)));
+        }
+        byte[] bytes = Bytes.toArray(glassidlist);
+        S7controlLK.getinstance().WriteByte(addr, bytes);
+    }
+
+    // 璇诲彇涓嶈繛缁瓀ord
+    public List<Short> readWords(List<String> addresses) {
+        if (s7PLC == null) {
+            return null;
+        }
+
+        List<Short> data = new ArrayList<>();
+
+        for (String address : addresses) {
+            try {
+
+                // 鍗曚釜鍦板潃
+                Short value = s7PLC.readInt16(address);
+                data.add(value);
+            } catch (Exception e) {
+                System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+
+            }
+
+        }
+        return data;
+    }
+
+    // 璇诲彇鏃堕棿
+    public Long readtime(String address) {
+        if (s7PLC == null)
+            return null;
+        try {
+            return s7PLC.readTime(address);
+        } catch (Exception e) {
+            System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+            return null;
+        }
+    }
+
+    public void writetime(String address, long datas) {
+        if (s7PLC == null)
+            return;
+
+        s7PLC.writeTime(address, datas); // 灏嗘暟鎹啓鍏ュ崟涓湴鍧�
+    }
+
+    private int extractAddressNumber(String address) {
+        String numberStr = address.replaceAll("\\D+", ""); // 浣跨敤姝e垯琛ㄨ揪寮忔彁鍙栨暟瀛楅儴鍒�
+        return Integer.parseInt(numberStr);
+    }
+
+    /**
+     * 浠庢寚瀹氱殑鍦板潃寮�濮� 杩炵画鎸塨it浣嶈鍙�
+     *
+     * @param address 鍦板潃
+     * @param count   闀垮害
+     * @return Boolean缁撴灉
+     */
+    public List<Boolean> ReadBits(String address, int count) {
+        if (s7PLC == null)
+            return null;
+        List<String> addresslist = GetAddressList(address, count, 1);
+        try {
+            return s7PLC.readBoolean(addresslist);
+        } catch (Exception e) {
+            System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+            return null;
+        }
+
+    };
+
+    private List<String> GetAddressList(String address, int count, int addedbit) {
+        List<String> addresslist = new ArrayList<String>();
+
+        String[] stringdatas = address.trim().split("\\.");
+        if (stringdatas.length < 2 || !address.startsWith("DB"))
+            return null;
+        int dbwindex = 0;
+        int bitindex = 0;
+        if (stringdatas.length == 2) {
+            dbwindex = Integer.parseInt(stringdatas[1]);
+        } else if (stringdatas.length == 3) {
+            dbwindex = Integer.parseInt(stringdatas[1]);
+            bitindex = Integer.parseInt(stringdatas[2]);
+        } else
+            return null;
+
+        addresslist.add(address);
+        for (int i = 0; i < count - 1; i++) {
+
+            int bitcurrent = bitindex + addedbit;
+            if (bitcurrent > 7) {
+                dbwindex += bitcurrent / 8;
+                bitindex = 0;
+            } else
+                bitindex = bitcurrent;
+
+            String endstr = stringdatas.length == 3 ? "." + bitindex : "";
+            addresslist.add(stringdatas[0] + "." + dbwindex + endstr);
+        }
+        return addresslist;
+    }
+
+    public void writeStrings(String data, String addr) {
+        // List<Byte> glassidlist = new ArrayList<>();
+        String[] parts = addr.split("-");
+        if (parts.length == 2) {
+            addr = parts[0];
+        }
+        s7PLC.writeString(addr, data);
+    }
+
+    public String readStrings(String addr) {
+        return s7PLC.readString(addr);
+    }
+}

--
Gitblit v1.8.0