layout 布局页增加A01 A02终止继续后选择 弹框
| | |
| | | import { changePassword } from '../api/user' |
| | | import { removeToken } from "../utils/auth"; |
| | | import LanguageMixin from '../lang/LanguageMixin' |
| | | import { MessageBox } from 'element-ui'; |
| | | // import { mapState, mapMutations } from 'vuex'; |
| | | // import Tag from '../layout/tag.vue'; |
| | | // import store from '../store'; |
| | |
| | | pageNum: -1 |
| | | }, |
| | | dialogFormVisible2: false, |
| | | dialogFormVisible3: true, |
| | | dialogFormVisible3: false, |
| | | alarm: [], |
| | | alarm2: [] |
| | | } |
| | |
| | | }, |
| | | methods: { |
| | | toggleButtonValue(buttonNumber) { |
| | | |
| | | MessageBox.confirm(this.$t('Are you sure to perform this operation?'), this.$t('prompt'), { |
| | | confirmButtonText: this.$t('confirm'), |
| | | cancelButtonText: this.$t('cancel'), |
| | | type: 'warning' |
| | | }).then(() => { |
| | | // 点击确认按钮后执行的操作 |
| | | if (buttonNumber === 1) { |
| | | this.receivedData = this.receivedData === 0 ? 1 : 0; |
| | | } else if (buttonNumber === 2) { |
| | |
| | | const jsonString3 = JSON.stringify(jsonObject3); |
| | | console.log("急停后中止/继续选择:", jsonString3); |
| | | socket?.send(jsonString3); |
| | | // setTimeout(()=> |
| | | // window.location.reload(),2000 |
| | | // ) |
| | | setTimeout(() => { |
| | | this.dialogFormVisible3 = false; |
| | | }, 1000); // 延迟时间为1秒(1000毫秒) |
| | | }).catch(() => { |
| | | // 点击取消按钮后执行的操作 |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | |
| | | socket.onmessage = function (msg) { |
| | | //console.log("收到数据====" + msg.data); |
| | | let obj = JSON.parse(msg.data); |
| | | if(obj.alarmmg){ |
| | | |
| | | |
| | | if (obj.alarmmg[0].length > 0) { |
| | | if (this.alarm.length > 0) { |
| | |
| | | this.dialogFormVisible2 = true; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | this.$forceUpdate(); |
| | | |
| | | if(obj.Abort){ |
| | | |
| | | |
| | | |
| | | |
| | |
| | | this.receivedData2=obj.Abort[0][1]; |
| | | this.dialogFormVisible3 = true; |
| | | } |
| | | |
| | | } |
| | | |
| | | }.bind(this); |
| | | //关闭事件 |
| | |
| | | |
| | | // System.out.println(stt); |
| | | |
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.120", 8); |
| | | List<Short> dache1 = S7control.getinstance().ReadWord("DB100.18", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.22", 1); |
| | | List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.14", 1); |
| | | |
| | | List<String> addresses = Arrays.asList(config.getProperty("Auto.addresses").split(",")); |
| | | |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses); |
| | | //System.out.println("lastMessage:" + arraylist2); |
| | | |
| | | //翻转 |
| | | List<Short> fanzhuan2 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | List<Short> xiaoche2 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | |
| | | |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] fanzhuan = { 4 }; |
| | | // List<Short> fanzhuan1 = new ArrayList<>(Arrays.asList(fanzhuan)); |
| | | // Short[] dache = { 5 }; |
| | | // List<Short> dache1 = new ArrayList<>(Arrays.asList(dache)); |
| | | // Short[] xiaoche = { 6 }; |
| | | // List<Short> xiaoche1 = new ArrayList<>(Arrays.asList(xiaoche)); |
| | | // List<Short> arraylist = S7control.getinstance().ReadWord("DB100.120", 8); |
| | | // List<Short> dache1 = S7control.getinstance().ReadWord("DB100.18", 1); |
| | | // List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.22", 1); |
| | | // List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.14", 1); |
| | | // |
| | | // Short[] values2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] fanzhuan22 = { 4 }; |
| | | // List<Short> fanzhuan2 = new ArrayList<>(Arrays.asList(fanzhuan22)); |
| | | // Short[] xiaoche22 = {5}; |
| | | // List<Short> xiaoche2 = new ArrayList<>(Arrays.asList(xiaoche22)); |
| | | // List<String> addresses = Arrays.asList(config.getProperty("Auto.addresses").split(",")); |
| | | // |
| | | // List<Short> arraylist2 = S7control.getinstance().readWords(addresses); |
| | | // //System.out.println("lastMessage:" + arraylist2); |
| | | // |
| | | ////翻转 |
| | | // List<Short> fanzhuan2 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | // List<Short> xiaoche2 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | |
| | | |
| | | Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| | | List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | Short[] fanzhuan = { 4 }; |
| | | List<Short> fanzhuan1 = new ArrayList<>(Arrays.asList(fanzhuan)); |
| | | Short[] dache = { 5 }; |
| | | List<Short> dache1 = new ArrayList<>(Arrays.asList(dache)); |
| | | Short[] xiaoche = { 6 }; |
| | | List<Short> xiaoche1 = new ArrayList<>(Arrays.asList(xiaoche)); |
| | | |
| | | Short[] values2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
| | | List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | Short[] fanzhuan22 = { 4 }; |
| | | List<Short> fanzhuan2 = new ArrayList<>(Arrays.asList(fanzhuan22)); |
| | | Short[] xiaoche22 = {5}; |
| | | List<Short> xiaoche2 = new ArrayList<>(Arrays.asList(xiaoche22)); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5} |
| | |
| | | |
| | | public class PlcParameter2 extends Thread { |
| | | @Autowired |
| | | StorageCageService StorageCageService ; |
| | | StorageCageService storageCageService; |
| | | |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | StorageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class); |
| | | storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class); |
| | | // id |
| | | List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(",")); |
| | | |
| | |
| | | System.out.println(id); |
| | | switch (i) { |
| | | case 1: |
| | | StorageCageService.UpdateTask(2, 0, paramlist.get(i)); |
| | | storageCageService.UpdateTask(2, 0, paramlist.get(i)); |
| | | break; |
| | | case 2: |
| | | case 3: |
| | | case 4: |
| | | case 5: |
| | | StorageCageService.UpdateTask(3, 0, paramlist.get(i)); |
| | | storageCageService.UpdateTask(3, 0, paramlist.get(i)); |
| | | break; |
| | | default: |
| | | // 处理索引值不在范围内的情况 |
| | |
| | | boolean Value2 = sValue.get(1); |
| | | |
| | | if (Value1) { |
| | | StorageCageService.EndTask(0); |
| | | storageCageService.EndTask(0); |
| | | |
| | | } |
| | | if (Value2) { |
| | | StorageCageService.EndTask(1); |
| | | storageCageService.EndTask(1); |
| | | |
| | | } |
| | | // 检查布尔值列表是否为空 |
| | | if (!sValue.isEmpty()) { |
| | | |
| | | // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表 |
| | | S7control.getinstance().WriteBit(addressList0, sValue); |
| | | System.out.println("Values " + sValue + " written to PLC at address " + addressList0); |
| | | S7control.getinstance().WriteBit(niuanaddressList3, sValue); |
| | | System.out.println("Values " + sValue + " written to PLC at address " + niuanaddressList3); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | 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 |
| | |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | |
|
| | | import java.io.IOException;
|
| | |
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | import com.example.springboot.service.*;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
|
| | | import com.example.springboot.entity.Out_slice;
|
| | |
| | | import com.example.springboot.entity.alarmmg;
|
| | | import com.example.springboot.mapper.HomeMapper;
|
| | | import com.example.springboot.mapper.SpianMapper;
|
| | | import com.example.springboot.service.JdbcConnections;
|
| | | import com.example.springboot.service.North_Glass_Buffer1Service;
|
| | | import com.example.springboot.service.OutSliceServive;
|
| | | import com.example.springboot.service.SpianService;
|
| | | import com.example.springboot.service.StorageCageService;
|
| | |
|
| | | public class Plchome extends Thread {
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | private StorageCageService storageCageService;
|
| | |
|
| | |
|
| | | public Plchome() throws IOException {
|
| | | config = new Configuration("config.properties");
|
| | |
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | // 注入mapper
|
| | |
|
| | | homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
|
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
|
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
|
| | |
| | | boolean value = anniuread.get(i);
|
| | | anniuparams[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | |
|
| | | short[] resets2 = new short[resets.size()];
|
| | | for (int i = 0; i < resets.size(); i++) {
|
| | | boolean value = resets.get(i);
|
| | | resets2[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | // System.out.println(resets);
|
| | | for (short number : resets2) {
|
| | |
|
| | | if (number == 1) {
|
| | | System.out.println(resets);
|
| | | jsonObject.append("Abort", anniuparams);
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | // 铝框线交互
|
| | |
|
| | | // //铝框id请求字
|
| | |
| | | // }
|
| | | // S7control.getinstance().WriteWord("铝框翻转发送地址", (short)send);
|
| | | // }
|
| | |
|
| | | storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
|
| | | dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
|
| | | boolean dbconnected = false;
|
| | | try {
|
| | |
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | |
|
| | | if (webserver != null) {
|
| | |
|
| | |
|
| | | List<String> messages = webserver.getMessages();
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为整数类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | |
|
| | |
|
| | | try {
|
| | | // 检查索引是否有效
|
| | | if (messageArray.getJSONArray(0).size() > 0) {
|
| | | // 获取消息数组
|
| | | JSONArray jsonArray = messageArray.getJSONArray(0);
|
| | | // 创建一个布尔值列表
|
| | | List<Boolean> sValue = new ArrayList<>();
|
| | | // 遍历消息数组
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | // 获取消息数组中的值
|
| | | Object value = jsonArray.get(i);
|
| | | // 检查值是否有效
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | // 移除非数字和数字字符
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | // 解析为布尔值
|
| | | boolean val = "1".equals(cleanedValue.trim());
|
| | | // 将布尔值添加到布尔值列表中
|
| | | sValue.add(val);
|
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
|
| | |
|
| | |
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 boolean 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | // 终止进片任务
|
| | | boolean Value1 = sValue.get(0);
|
| | | boolean Value2 = sValue.get(1);
|
| | |
|
| | | if (Value1) {
|
| | | storageCageService.EndTask(0);
|
| | |
|
| | | }
|
| | | if (Value2) {
|
| | | storageCageService.EndTask(1);
|
| | |
|
| | | }
|
| | | // 检查布尔值列表是否为空
|
| | | if (!sValue.isEmpty()) {
|
| | |
|
| | | // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表
|
| | | S7control.getinstance().WriteBit(niuanaddressList3, sValue);
|
| | | System.out.println("Values " + sValue + " written to PLC at address " + niuanaddressList3);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | System.err.println("An error occurred while writing bit to PLC: " + e.getMessage());
|
| | | }
|
| | | webserver.clearMessages();
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // |
| | | System.out.println("启动完成"); |
| | | |
| | | new PlcHold().start(); |
| | | //new PlcHold().start(); |
| | | |
| | | new Plchome().start(); |
| | | |