ZengTao
2023-12-25 9cb2015a78de000c9771bd8c34ffc77dce807e88
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
@@ -3,8 +3,10 @@
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.springboot.controller.HomeController;
import com.example.springboot.mapper.HomeMapper;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.StorageCageService;
import java.io.*;
import java.util.ArrayList;
@@ -18,6 +20,9 @@
public class PlcParameter2 extends Thread {
    @Autowired
    StorageCageService StorageCageService  ;
    // 用于存储应用程序的配置信息
    private Configuration config;
@@ -39,7 +44,7 @@
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            StorageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class);
            //  id
            List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(","));
@@ -127,7 +132,7 @@
//        jsonObject.set("message", "Hello, Parameter2!");
//        sendwServer.sendMessage(jsonObject.toString());
//      }
            HomeController controller = new HomeController();
//            HomeController controller = new HomeController();
            ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter2");
            if (sendwServer != null) {
                for (WebSocketServer webserver : sendwServer) {
@@ -182,19 +187,19 @@
                                            }
                                        }
                                    }
//完成出片
                                    for (int i = 1; i <= 5; i++) {
                                        boolean value = sValue.get(i);
                                        if (value) {
                                            switch (i) {
                                                case 1:
                                                    controller.UpdateTask(0, 0, paramlist.get(i));
                                                    StorageCageService.UpdateTask(2, 0, paramlist.get(i));
                                                    break;
                                                case 2:
                                                case 3:
                                                case 4:
                                                case 5:
                                                    controller.UpdateTask(1, 0, paramlist.get(i));
                                                    StorageCageService.UpdateTask(3, 0, paramlist.get(i));
                                                    break;
                                                default:
                                                    // 处理索引值不在范围内的情况
@@ -251,16 +256,16 @@
                                            }
                                        }
                                    }
// 终止进片任务
                                    boolean Value1 = sValue.get(0);
                                    boolean Value2 = sValue.get(1);
                                    if (Value1) {
                                        controller.EndTask(0);
                                        StorageCageService.EndTask(0);
                                    }
                                    if (Value2) {
                                        controller.EndTask(0);
                                        StorageCageService.EndTask(1);
                                    }
                                    // 检查布尔值列表是否为空