| | |
| | | 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; |
| | |
| | | |
| | | |
| | | public class PlcParameter2 extends Thread { |
| | | @Autowired |
| | | StorageCageService StorageCageService ; |
| | | |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | StorageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class); |
| | | // id |
| | | List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(",")); |
| | | |
| | |
| | | // 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) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | //完成出片 |
| | | 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: |
| | | // 处理索引值不在范围内的情况 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 终止进片任务 |
| | | 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); |
| | | |
| | | } |
| | | // 检查布尔值列表是否为空 |