Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
# Conflicts:
# CanadaMes-ui/src/layout/index.vue
# springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
# springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
| | |
| | | "Parameter": "参数设置",
|
| | | "Action": "开关控制",
|
| | | "Sign": "IO状态",
|
| | | "State": "设备状态",
|
| | | "State": "状态",
|
| | | "Alarm": "报警信息",
|
| | | "Distribute": "下发",
|
| | | "Search": "搜索",
|
| | |
| | | // import store from '../store'; |
| | | let socket; |
| | | let timer; |
| | | |
| | | export default { |
| | | name: "Layout", |
| | | // store, |
| | |
| | | }, |
| | | //45秒复位倒数计时 |
| | | CountDown() { |
| | | let count = 60; |
| | | clearInterval(timer); |
| | | let count = 45; |
| | | timer = setInterval( |
| | | () => { |
| | | if (this.EmergencyStop == true) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if ( |
| | | obj2.button && |
| | | (obj2.button.name === "回零" || obj2.button.name === "Home") |
| | | ) { |
| | | obj2.button.value = obj.huiling[0][i]; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //未回零更新 |
| | | |
| | | jsonData2[2][3].button.value = weihuiling[0][0]; |
New file |
| | |
| | | <component name="libraryTable">
|
| | | <library name="Maven: com.google.code.gson:gson:2.8.9">
|
| | | <CLASSES>
|
| | | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar!/" />
|
| | | </CLASSES>
|
| | | <JAVADOC>
|
| | | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9-javadoc.jar!/" />
|
| | | </JAVADOC>
|
| | | <SOURCES>
|
| | | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9-sources.jar!/" />
|
| | | </SOURCES>
|
| | | </library>
|
| | | </component> |
| | |
| | | { |
| | | "plcAddressBegin":"DB100.0.0", |
| | | "plcAddressLenght":"20", |
| | | "plcAddressLenght":"10", |
| | | "dataType":"bit", |
| | | "parameteInfor":[ |
| | | { |
| | |
| | | }, |
| | | { |
| | | "codeId": "A01A02TURNPOSVelocityAUTO", |
| | | "addressIndex":"12" |
| | | "addressIndex":"7" |
| | | }, |
| | | { |
| | | "codeId": "A01A02TURNPOSVelocitymanual", |
| | | "addressIndex":"14" |
| | | "addressIndex":"8" |
| | | }, |
| | | { |
| | | "codeId": "A01A02TRAVELPOSVelocityAUTO", |
| | | "addressIndex":"16" |
| | | "addressIndex":"9" |
| | | }, |
| | | { |
| | | "codeId": "DO1id", |
| | | "addressIndex":"18" |
| | | "addressIndex":"10" |
| | | } |
| | | ] |
| | | } |
New file |
| | |
| | | [
|
| | | {
|
| | | "codeId": "D01.State",
|
| | | "unit": "",
|
| | | "addressIndex": "0"
|
| | | },
|
| | | {
|
| | | "codeId": "D02.State",
|
| | | "unit": "",
|
| | | "addressIndex": "2"
|
| | | },
|
| | | {
|
| | | "codeId": "B01.State",
|
| | | "unit": "",
|
| | | "addressIndex": "4"
|
| | | },
|
| | | {
|
| | | "codeId": "B02.State",
|
| | | "unit": "",
|
| | | "addressIndex": "6"
|
| | | },
|
| | | {
|
| | | "codeId": "A01.State",
|
| | | "unit": "",
|
| | | "addressIndex": "8"
|
| | | },
|
| | | {
|
| | | "codeId": "A02.State",
|
| | | "unit": "",
|
| | | "addressIndex": "10"
|
| | | },
|
| | | {
|
| | | "codeId": "D03.State",
|
| | | "unit": "",
|
| | | "addressIndex": "12"
|
| | | },
|
| | | {
|
| | | "codeId": "D04.State",
|
| | | "unit": "",
|
| | | "addressIndex": "14"
|
| | | },
|
| | | {
|
| | | "codeId": "D05.State",
|
| | | "unit": "",
|
| | | "addressIndex": "16"
|
| | | },
|
| | | {
|
| | | "codeId": "D06.State",
|
| | | "unit": "",
|
| | | "addressIndex": "18"
|
| | | },
|
| | | {
|
| | | "codeId": "A01tavelActualPosition",
|
| | | "unit": "",
|
| | | "addressIndex": "20"
|
| | | },
|
| | | {
|
| | | "codeId": "A01turnActualangle",
|
| | | "unit": "",
|
| | | "addressIndex": "22"
|
| | | },
|
| | | {
|
| | | "codeId": "A02tavelActualPosition",
|
| | | "unit": "",
|
| | | "addressIndex": "24"
|
| | | },
|
| | | {
|
| | | "codeId": "A02turnActualangle",
|
| | | "unit": "",
|
| | | "addressIndex": "26"
|
| | | },
|
| | | {
|
| | | "codeId": "B01tavelActualPosition",
|
| | | "unit": "",
|
| | | "addressIndex": "28"
|
| | | },
|
| | | {
|
| | | "codeId": "B02tavelActualPosition",
|
| | | "unit": "",
|
| | | "addressIndex": "30"
|
| | | },
|
| | | {
|
| | | "codeId": "A01CurrentGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "32"
|
| | | },
|
| | | {
|
| | | "codeId": "A02CurrentGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "34"
|
| | | },
|
| | | {
|
| | | "codeId": "B01CurrentGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "36"
|
| | | },
|
| | | {
|
| | | "codeId": "B01TargetGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "38"
|
| | | },
|
| | | {
|
| | | "codeId": "B02CurrentGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "40"
|
| | | },
|
| | | {
|
| | | "codeId": "B02TargetGrid",
|
| | | "unit": "",
|
| | | "addressIndex": "42"
|
| | | },
|
| | | {
|
| | | "codeId": "D01ID",
|
| | | "unit": "",
|
| | | "addressIndex": "44"
|
| | | },
|
| | | {
|
| | | "codeId": "D02ID",
|
| | | "unit": "",
|
| | | "addressIndex": "58"
|
| | | },
|
| | | {
|
| | | "codeId": "D03ID",
|
| | | "unit": "",
|
| | | "addressIndex": "72"
|
| | | },
|
| | | {
|
| | | "codeId": "D04ID",
|
| | | "unit": "",
|
| | | "addressIndex": "86"
|
| | | },
|
| | | {
|
| | | "codeId": "D05ID",
|
| | | "unit": "",
|
| | | "addressIndex": "100"
|
| | | },
|
| | | {
|
| | | "codeId": "D06ID",
|
| | | "unit": "",
|
| | | "addressIndex": "114"
|
| | | },
|
| | | {
|
| | | "codeId": "A01ID1",
|
| | | "unit": "",
|
| | | "addressIndex": "128"
|
| | | },
|
| | | {
|
| | | "codeId": "A01ID2",
|
| | | "unit": "",
|
| | | "addressIndex": "142"
|
| | | },
|
| | | {
|
| | | "codeId": "A02ID1",
|
| | | "unit": "",
|
| | | "addressIndex": "156"
|
| | | },
|
| | | {
|
| | | "codeId": "A02ID2",
|
| | | "unit": "",
|
| | | "addressIndex": "170"
|
| | | },
|
| | | {
|
| | | "codeId": "B01ID1",
|
| | | "unit": "",
|
| | | "addressIndex": "184"
|
| | | },
|
| | | {
|
| | | "codeId": "B01ID2",
|
| | | "unit": "",
|
| | | "addressIndex": "198"
|
| | | },
|
| | | {
|
| | | "codeId": "B02ID1",
|
| | | "unit": "",
|
| | | "addressIndex": "212"
|
| | | },
|
| | | {
|
| | | "codeId": "B02ID2",
|
| | | "unit": "",
|
| | | "addressIndex": "226"
|
| | | },
|
| | | {
|
| | | "codeId": "A01conveyorFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "240"
|
| | | },
|
| | | {
|
| | | "codeId": "A01turnservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "242"
|
| | | },
|
| | | {
|
| | | "codeId": "A01travelservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "244"
|
| | | },
|
| | | {
|
| | | "codeId": "A02conveyorFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "246"
|
| | | },
|
| | | {
|
| | | "codeId": "A02turnservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "248"
|
| | | },
|
| | | {
|
| | | "codeId": "A02travelservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "250"
|
| | | },
|
| | | {
|
| | | "codeId": "B01travelservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "252"
|
| | | },
|
| | | {
|
| | | "codeId": "B02travelservoFaultcodes",
|
| | | "unit": "",
|
| | | "addressIndex": "254"
|
| | | },
|
| | | {
|
| | | "codeId": "",
|
| | | "unit": "",
|
| | | "addressIndex": ""
|
| | | }
|
| | | ] |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-websocket</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.google.code.gson</groupId> |
| | | <artifactId>gson</artifactId> |
| | | <version>2.8.9</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.2.8.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.2.8.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.xingshuangs:iot-communication:1.4.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" /> |
| | | </component> |
| | | </module> |
New file |
| | |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONObject;
|
| | | import com.google.gson.Gson;
|
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| | | import org.apache.poi.ss.usermodel.*;
|
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileWriter;
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
|
| | | public class ExcelToJsonConverter {
|
| | | public static void main(String[] args) {
|
| | | String excelFilePath = "JsonFile/state.xlsx";
|
| | | String sheetName = "Sheet1";
|
| | | int addressColumnIndex = 0;
|
| | | int nameColumnIndex = 1;
|
| | |
|
| | | int unitColumnIndex = 2;
|
| | | String outputFilePath = "JsonFile/state.json";
|
| | |
|
| | | try (Workbook workbook = new HSSFWorkbook(new FileInputStream(excelFilePath))) {
|
| | | Sheet sheet = workbook.getSheet(sheetName);
|
| | |
|
| | | List<JSONObject> jsonList = new ArrayList<>();
|
| | |
|
| | | Iterator<Row> rowIterator = sheet.iterator();
|
| | | // Skip the header row
|
| | | if (rowIterator.hasNext()) {
|
| | | rowIterator.next();
|
| | | }
|
| | |
|
| | | while (rowIterator.hasNext()) {
|
| | | Row row = rowIterator.next();
|
| | |
|
| | | Cell nameCell = row.getCell(nameColumnIndex);
|
| | | Cell addressCell = row.getCell(addressColumnIndex);
|
| | | Cell unitCell = row.getCell(unitColumnIndex);
|
| | |
|
| | | String name = nameCell.getStringCellValue();
|
| | | String address = addressCell.getStringCellValue();
|
| | | String unit = unitCell.getStringCellValue();
|
| | |
|
| | | String addressIndex = extractAddressIndex(address);
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | jsonObject.put("codeId", name);
|
| | | jsonObject.put("addressIndex", addressIndex);
|
| | |
|
| | | jsonObject.put("unit", unit);
|
| | |
|
| | | jsonList.add(jsonObject);
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | String jsonOutput = gson.toJson(jsonList);
|
| | |
|
| | | try (FileWriter fileWriter = new FileWriter(outputFilePath)) {
|
| | | fileWriter.write(jsonOutput);
|
| | | }
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private static String extractAddressIndex(String address) {
|
| | | // Assuming the address format is "DB103.DBW0" or "DB103.DBB100~DBB113"
|
| | | if (address.startsWith("DB") && address.contains(".DBW")) {
|
| | | int startIndex = address.indexOf(".DBW") + 4;
|
| | | int endIndex = address.length();
|
| | | return address.substring(startIndex, endIndex);
|
| | | } else if (address.startsWith("DB") && address.contains(".DBB")) {
|
| | | int startIndex2 = address.indexOf(".DBB") + 4;
|
| | | int endIndex2 = address.indexOf("~");
|
| | | return address.substring(startIndex2, endIndex2);
|
| | | }
|
| | | return "";
|
| | | }
|
| | |
|
| | |
|
| | | } |
| | |
| | | import java.io.FileReader;
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class InitUtil {
|
| | |
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit"));
|
| | | plcParameterObject.addPlcParameter(plcParameterInfo);
|
| | | }
|
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
|
| | | byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | plcParameterObject.setPlcParameterList(getplcvlues);
|
| | |
|
| | | return plcParameterObject;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | public static PlcBitObject initbit(String jsonFilePath) {
|
| | | PlcBitObject plcBitObject = new PlcBitObject();
|
| | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true ,true };
|
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | // plcBitObject.setPlcBitList(getplcvlues);
|
| | | return plcBitObject;
|
| | | }
|
| | |
|
| | |
|
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) {
|
| | |
|
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true ,true };
|
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
|
| | | List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
|
| | | plcBitObject.setPlcBitList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) {
|
| | |
|
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
|
| | | byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
|
| | | plcParameterObject.setPlcParameterList(getplcvlues);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | |
| | | String addressList2 = "DB100.18"; |
| | | String addressList3 = "DB100.22"; |
| | | String addressList4 = "DB100.14"; |
| | | |
| | | System.out.println(plcParameterObject.getPlcParameterValues(Autoaddresses)); |
| | | |
| | | |
| | | |
| | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5} |
| | | // new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0} |
| | | System.out.println(plcParameterObject.getPlcParameterValues(addresses)); |
| | | //System.out.println(plcParameterObject.getPlcParameterValues(addresses)); |
| | | jsonObject.append("params", plcParameterObject.getPlcParameterValues(addresses)); |
| | | jsonObject.append("dache1", plcParameterObject.getPlcParameter("A01A02TRAVELPOSVelocityAUTO").getValue()); |
| | | jsonObject.append("xiaoche", plcParameterObject.getPlcParameter("B01B02TRAVELPOSVelocityAUTO").getValue()); |
| | |
| | | jsonObject.append("xiaoche2", plcParameterObject.getPlcParameter("B01B02TRAVELJOGVelocity").getValue()); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("AutomaticParameterSetting"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | // if (sendwServer != null) { |
| | | // for (WebSocketServer webserver : sendwServer) { |
| | | // webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | // WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("AutomaticParameterSetting"); |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | |
| | | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | // 整合第 1 到 2 个数组并去掉 null 元素 |
| | | List<Short> mergedList = new ArrayList<>(); |
| | | for (int i = 0; i < 2; i++) { |
| | | JSONArray sublist = messageArray.getJSONArray(i); |
| | | for (int j = 0; j < sublist.size(); j++) { |
| | | Object value = sublist.get(j); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | mergedList.add(sValue); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | System.out.println(messageArray); |
| | | // 写入第一个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList2,2); |
| | | // 写入第二个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList3,3); |
| | | // 写入第三个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList4,4); |
| | | // 写入第四个地址 |
| | | if (!mergedList.isEmpty()) { |
| | | S7control.getinstance().WriteWord(addressList1, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList1); |
| | | } |
| | | |
| | | //List<String> waddresses1 = Arrays.asList(config.getProperty("Auto.shusong").split(",")); |
| | | String addressList22 = "DB100.8"; |
| | | String addressList33 = "DB100.12"; |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | // 整合第 1 到 3 个数组并去掉 null 元素 |
| | | List<Short> mergedList2 = new ArrayList<>(); |
| | | for (int i = 5; i < 8; i++) { |
| | | JSONArray sublist = messageArray.getJSONArray(i); |
| | | for (int j = 0; j < sublist.size(); j++) { |
| | | Object value = sublist.get(j); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | mergedList2.add(sValue); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 写入第伍个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList22,8); |
| | | // 写入第六个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList33,9); |
| | | // 写入第七个地址 |
| | | // plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index) |
| | | if (!mergedList2.isEmpty()) { |
| | | //S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter(Autoaddresses), mergedList2); |
| | | // System.out.println("messageValue:" + mergedList2 + " written to PLC at address " + waddresses1); |
| | | } |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // if (webserver != null) { |
| | | // List<String> messages = webserver.getMessages(); |
| | | // |
| | | // |
| | | // if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为 short 类型的列表 |
| | | // String lastMessage = messages.get(messages.size() - 1); |
| | | // // System.out.println("lastMessage:" + lastMessage); |
| | | // JSONArray messageArray = new JSONArray(lastMessage); |
| | | // |
| | | // // 整合第 1 到 2 个数组并去掉 null 元素 |
| | | // List<Short> mergedList = new ArrayList<>(); |
| | | // for (int i = 0; i < 2; i++) { |
| | | // JSONArray sublist = messageArray.getJSONArray(i); |
| | | // for (int j = 0; j < sublist.size(); j++) { |
| | | // Object value = sublist.get(j); |
| | | // if (value != null && !value.toString().equals("null")) { |
| | | // try { |
| | | // String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | // short sValue = Short.parseShort(cleanedValue.trim()); |
| | | // mergedList.add(sValue); |
| | | // } catch (NumberFormatException e) { |
| | | // // 如果无法解析为 short 类型,则忽略该部分 |
| | | // System.err.println("Could not parse value: " + value); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // System.out.println(messageArray); |
| | | // // 写入第一个地址 |
| | | // customS7Control.WriteWordsToPLC(messageArray, addressList2,2); |
| | | // // 写入第二个地址 |
| | | // customS7Control.WriteWordsToPLC(messageArray, addressList3,3); |
| | | // // 写入第三个地址 |
| | | // customS7Control.WriteWordsToPLC(messageArray, addressList4,4); |
| | | // // 写入第四个地址 |
| | | // if (!mergedList.isEmpty()) { |
| | | // S7control.getinstance().WriteWord(addressList1, mergedList); |
| | | // System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList1); |
| | | // } |
| | | // |
| | | // //List<String> waddresses1 = Arrays.asList(config.getProperty("Auto.shusong").split(",")); |
| | | // String addressList22 = "DB100.8"; |
| | | // String addressList33 = "DB100.12"; |
| | | // if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为 short 类型的列表 |
| | | // // 整合第 1 到 3 个数组并去掉 null 元素 |
| | | // List<Short> mergedList2 = new ArrayList<>(); |
| | | // for (int i = 5; i < 8; i++) { |
| | | // JSONArray sublist = messageArray.getJSONArray(i); |
| | | // for (int j = 0; j < sublist.size(); j++) { |
| | | // Object value = sublist.get(j); |
| | | // if (value != null && !value.toString().equals("null")) { |
| | | // try { |
| | | // String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | // short sValue = Short.parseShort(cleanedValue.trim()); |
| | | // mergedList2.add(sValue); |
| | | // } catch (NumberFormatException e) { |
| | | // // 如果无法解析为 short 类型,则忽略该部分 |
| | | // System.err.println("Could not parse value: " + value); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // // 写入第伍个地址 |
| | | // customS7Control.WriteWordsToPLC(messageArray, addressList22,8); |
| | | // // 写入第六个地址 |
| | | // customS7Control.WriteWordsToPLC(messageArray, addressList33,9); |
| | | // // 写入第七个地址 |
| | | // // plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index) |
| | | // if (!mergedList2.isEmpty()) { |
| | | // //S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter(Autoaddresses), mergedList2); |
| | | // // System.out.println("messageValue:" + mergedList2 + " written to PLC at address " + waddresses1); |
| | | // } |
| | | // // 清空消息列表 |
| | | // webserver.clearMessages(); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | |
| | | } |
| | |
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray(
|
| | | A01readstart, A02readstart
|
| | | );
|
| | | // 故障地址
|
| | | List<String> waddresses3 = new ArrayList<>();
|
| | | waddresses3.add("DB103.242");
|
| | | waddresses3.add("DB103.248");
|
| | |
|
| | | // 复位地址
|
| | | List<String> waddresses4 = new ArrayList<>();
|
| | | waddresses4.add("DB101.3.6");
|
| | | waddresses4.add("DB101.4.1");
|
| | |
|
| | | // 回零地址
|
| | | List<String> waddresses5 = new ArrayList<>();
|
| | | waddresses5.add("DB101.3.7");
|
| | | waddresses5.add("DB101.4.2");
|
| | |
|
| | |
|
| | |
|
| | | List<Boolean> readreast = S7control.getinstance().readBits(waddresses4);
|
| | | short[] reast6 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readreast);
|
| | |
|
| | |
|
| | |
|
| | | List<Boolean> readhuiling = S7control.getinstance().readBits(waddresses5);
|
| | | short[] huiling7 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readhuiling);
|
| | |
|
| | |
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | |
| | | jsonObject.append("guzhang", params2);
|
| | | jsonObject.append("weihuiling", params3);
|
| | | jsonObject.append("qidong", combinedBinaryShortArray);
|
| | | jsonObject.append("fuwei", reast6);
|
| | | jsonObject.append("huiling", huiling7);
|
| | |
|
| | | // System.out.println(jsonObject);
|
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | // if (sendwServer != null) {
|
| | |
| | | waddresses2.add("DB100.192");
|
| | |
|
| | |
|
| | | // 故障地址
|
| | | List<String> waddresses3 = new ArrayList<>();
|
| | | waddresses3.add("DB103.242");
|
| | | waddresses3.add("DB103.248");
|
| | |
|
| | | // 复位地址
|
| | | List<String> waddresses4 = new ArrayList<>();
|
| | | waddresses4.add("DB101.3.6");
|
| | | waddresses4.add("DB101.4.1");
|
| | |
|
| | | // 回零地址
|
| | | List<String> waddresses5 = new ArrayList<>();
|
| | | waddresses5.add("DB101.3.7");
|
| | | waddresses5.add("DB101.4.2");
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | |
| | | byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | // int index = plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddressIndex(); |
| | | // S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index), (short) 100); |
| | | |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("conveyorVelocity(AutoFAST)"); |
| | | addresses.add("conveyorVelocity(AutoSLOW)"); |
| | | addresses.add("conveyorVelocity(Manual)"); |
| | | addresses.add("A01A02TURNJOGVelocity"); |
| | | addresses.add("A01A02TRAVELJOGVelocity"); |
| | | addresses.add("A01A02TURNPOSVelocityAUTO"); |
| | | // addresses.add("conveyorVelocity(AutoSLOW)"); |
| | | // addresses.add("conveyorVelocity(Manual)"); |
| | | // addresses.add("A01A02TURNJOGVelocity"); |
| | | // addresses.add("A01A02TRAVELJOGVelocity"); |
| | | |
| | | |
| | | System.out.println(plcParameterObject.getPlcParameterValues(addresses)); |
| | |
| | | A01readBstart, A01readstart, A02readsBtart, A02readstart |
| | | ); |
| | | |
| | | |
| | | // 回零地址 |
| | | |
| | | List<Boolean> readhuiling = S7control.getinstance().readBits(waddresses4); |
| | | short[] huiling7 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readhuiling); |
| | | |
| | | // System.out.println(A01readBstart); |
| | | |
| | | // 所有故障按钮转换为1和0 |
| | |
| | | jsonObject.append("qupianid", queueid2); |
| | | jsonObject.append("fuwei", rReset); |
| | | jsonObject.append("qidong", combinedBinaryShortArray); |
| | | jsonObject.append("huiling", huiling7); |
| | | |
| | | jsonObject.append("resumeTasks", resumeTask); |
| | | |
| | | |
| | |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("D:/Documents/canadames/Alarm.json"); |
| | | fileInputStream = new FileInputStream("D:/canadames/Alarm.json"); |
| | | // 读取 fileInputStream 中字节并将其解码为字符 |
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); |
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader |
| | |
| | | // List<Short> listd17 = S7control.getinstance().ReadWord("DB17.0",10);
|
| | | // String id=spianService.queGlassid("DB17.10", 14).toString();
|
| | | //
|
| | | // // 铝框线交互
|
| | |
|
| | | // 铝框线交互
|
| | | // 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);
|
| | | // }
|
| | | // }
|
| | | // 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
|
| | | // // TODO: handle exception
|
| | | // }
|
| | |
|
| | | if (S7control.getinstance().CheckConnected() == true) {
|
| | |
| | | System.out.println("启动完成"); |
| | | |
| | | new PlcHold().start(); |
| | | // new PLCAutoMes(); |
| | | new PLCAutomaticParameterSettingReview2(); |
| | | |
| | | new Plchome().start(); |
| | | new PlcLayout().start(); |
| | | new Plcalarm().start(); |
| | | // new Plchome().start(); |
| | | // new PlcLayout().start(); |
| | | // new Plcalarm().start(); |
| | | |
| | | new Plcsign().start(); |
| | | // new Plcsign().start(); |
| | | |
| | | new Plcstate().start(); |
| | | new PlcPositioning1().start(); |
| | | // new Plcstate().start(); |
| | | // new PlcPositioning1().start(); |
| | | |
| | | new PlcParameter2().start(); |
| | | // new PlcParameter2().start(); |
| | | |
| | | new PLCAutomaticParameterSetting().start(); |
| | | // new PLCAutomaticParameterSetting().start(); |
| | | |
| | | new PlcManualonePosition().start(); |
| | | new PlcManualonePosition2().start(); |
| | | new PlcServoManualone().start(); |
| | | new PLCManualJog().start(); |
| | | new Plclog().start(); |
| | | // new PlcManualonePosition().start(); |
| | | // new PlcManualonePosition2().start(); |
| | | // new PlcServoManualone().start(); |
| | | // new PLCManualJog().start(); |
| | | // new Plclog().start(); |
| | | |
| | | new PlcInteractionState().start(); |
| | | // new PlcInteractionState().start(); |
| | | //new PlcParameter1Review().start(); |
| | | // new PLCAutomaticParameterSettingReview().start(); |
| | | } |
| | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @param codeids 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public List<String> getPlcParameterValues(List<String> codeids) { |
| | | List<String> arrayList = new ArrayList(); |
| | | if (plcParameterList != null) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (codeids.contains(plcParameterInfo.getCodeId().toString())) |
| | | if (codeids.contains(plcParameterInfo.getCodeId())) |
| | | arrayList.add(plcParameterInfo.getValue()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public List<String> getPlcAddressList(String codeid) { |
| | | List<String> addressList = new ArrayList<>(); |
| | | if (plcParameterList != null) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (plcParameterInfo.getCodeId().equals(codeid)) { |
| | | int plcAddress = plcParameterInfo.getPlcAddress(); |
| | | if (!addressList.contains(plcAddress)) { |
| | | addressList.add(String.valueOf(plcAddress)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return addressList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | "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 |
| | | } |
| | | ] |
| | | } |