From 560303799978bd141dc1e9553b7607012591fb42 Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期二, 17 六月 2025 17:02:53 +0800
Subject: [PATCH] 1.json文件优化 增加配置项:【1.触发点;2.逻辑线程时间间隔】 2.优化处理代码 【1.去除多余日志输出点;2.两个设备json文件进行根据codeId进行关联;3.调整代码先后顺序】 3.json文件路径提出jar包外,可在设备表上配置上配置路径。因原方式修改地址json 后需重新打包,实际调试中传递jar包比较浪费时间
---
JsonFile/EdgLogicView.json | 89 ++++
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/Api.java | 142 ++++--
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/LogicItem.java | 6
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/Thread/MachineThread.java | 148 ++----
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicProcedure.json | 92 ++++
JsonFile/ShelfModbusTcp.json | 0
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/ApiService.java | 5
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application-prod.yml | 14
JsonFile/EdgLogicHttp.json | 141 ++++++
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application.yml | 17
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/Edg.json | 52 ++
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicView.json | 89 ++++
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/AppRunnerConfig.java | 22
ShangHaiMesParent/moduleService/plcConnectModule/src/test/java/com/mes/plcConnectModuleApplicationTest.java | 27
JsonFile/EdgLogicProcedure.json | 92 ++++
/dev/null | 85 ---
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java | 19
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/model/entity/Machine.java | 19
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfS7.json | 0
JsonFile/ShelfS7.json | 0
ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/ApiConfig.java | 17
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicHttp.json | 141 ++++++
ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfModbusTcp.json | 0
JsonFile/Edg.json | 52 ++
24 files changed, 980 insertions(+), 289 deletions(-)
diff --git a/JsonFile/Edg.json b/JsonFile/Edg.json
new file mode 100644
index 0000000..01c0091
--- /dev/null
+++ b/JsonFile/Edg.json
@@ -0,0 +1,52 @@
+{
+ "parameters": [
+ {
+ "serialNumber": 0,
+ "content": "PLC璇锋眰",
+ "codeId": "plcRequest",
+ "plcDataType": "Word",
+ "fontLocation": 0,
+ "length": 2,
+ "ratio": 1,
+ "scale": 10,
+ "address": "S7.DB8.DBW0",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 1,
+ "content": "Mes鍙戦�佸瓧",
+ "codeId": "mesSend",
+ "plcDataType": "Word",
+ "fontLocation": 18,
+ "length": 2,
+ "ratio": 1,
+ "scale": 10,
+ "address": "S7.DB8.DBW2",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 2,
+ "content": "MES鍙戦�侀暱",
+ "codeId": "width",
+ "plcDataType": "Word",
+ "fontLocation": 20,
+ "length": 2,
+ "ratio": 11,
+ "scale": 11,
+ "address": "S7.DB8.DBW4",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 11,
+ "content": "MES鍙戦�佸",
+ "codeId": "height",
+ "plcDataType": "Word",
+ "fontLocation": 22,
+ "length": 2,
+ "ratio": 12,
+ "scale": 12,
+ "address":"S7.DB8.DBW6",
+ "remarks": ""
+ }
+ ]
+}
\ No newline at end of file
diff --git a/JsonFile/EdgLogicHttp.json b/JsonFile/EdgLogicHttp.json
new file mode 100644
index 0000000..e79c601
--- /dev/null
+++ b/JsonFile/EdgLogicHttp.json
@@ -0,0 +1,141 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "loadSelect",
+ "type": "Http",
+ "address": "http://localhost:8082/account/testApi",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 1
+ },
+ {
+ "codeId": "width",
+ "fixed": false,
+ "value": 1
+ }
+ ,
+ {
+ "codeId": "height",
+ "fixed": false,
+ "value": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "apiConfigBefore": {
+ "codeId": "",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ },
+ {
+ "name":"瀹屾垚閫昏緫",
+ "sequence":"3",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcComplete",
+ "value": [1]
+ },
+ {
+ "codeId": "mesComplete",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesComplete",
+ "fixed": true,
+ "value": 1
+ }
+ ]
+ },
+ {
+ "name":"瀹屾垚娓呯┖",
+ "sequence":"4",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcComplete",
+ "value": [0]
+ },
+ {
+ "codeId": "mesComplete",
+ "value": [1,2,3]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesComplete",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/JsonFile/EdgLogicProcedure.json b/JsonFile/EdgLogicProcedure.json
new file mode 100644
index 0000000..31cdd26
--- /dev/null
+++ b/JsonFile/EdgLogicProcedure.json
@@ -0,0 +1,92 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "Procedure",
+ "address": "testProcedure",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "address": "S7.DB8.DBW2",
+ "fixed": true,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ },
+ {
+ "codeId": "width",
+ "address": "S7.DB8.DBW4",
+ "fixed": false,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ,
+ {
+ "codeId": "height",
+ "address": "S7.DB8.DBW6",
+ "fixed": false,
+ "value": 2,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/JsonFile/EdgLogicView.json b/JsonFile/EdgLogicView.json
new file mode 100644
index 0000000..9cd2552
--- /dev/null
+++ b/JsonFile/EdgLogicView.json
@@ -0,0 +1,89 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname"
+ },
+ "apiConfigAfter": {
+ "codeId": "edgSelect",
+ "type": "Http",
+ "address": "http://localhost:8082/account/testApi",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "address": "S7.DB8.DBW2",
+ "fixed": true,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ },
+ {
+ "codeId": "width",
+ "address": "S7.DB8.DBW4",
+ "fixed": false,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ,
+ {
+ "codeId": "height",
+ "address": "S7.DB8.DBW6",
+ "fixed": false,
+ "value": 2,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelf.json b/JsonFile/ShelfModbusTcp.json
similarity index 100%
copy from ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelf.json
copy to JsonFile/ShelfModbusTcp.json
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfS7.json b/JsonFile/ShelfS7.json
similarity index 100%
copy from ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfS7.json
copy to JsonFile/ShelfS7.json
diff --git a/ShangHaiMesParent/JsonFile/PlcCacheGlass.json b/ShangHaiMesParent/JsonFile/PlcCacheGlass.json
deleted file mode 100644
index 01969b7..0000000
--- a/ShangHaiMesParent/JsonFile/PlcCacheGlass.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "plcAddressBegin":"DB11.0",
- "plcAddressLenght":"80",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "A06_request_word",
- "addressIndex":"0",
- "addressLenght":"2",
- "ratio":"1",
- "unit":"m/min"
- },
- {
- "codeId": "A05_scanning_ID",
- "addressIndex":"2",
- "addressLenght":"30",
- "ratio":"1",
- "unit":""
- },
- {
- "codeId": "Current_slot",
- "addressIndex":"36",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- },
- {
- "codeId": "MES_confirmation_word",
- "addressIndex":"38",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- },
- {
- "codeId": "A08_glass_status",
- "addressIndex":"68",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- },
- {
- "codeId": "A10_glass_status",
- "addressIndex":"70",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- },
- {
- "codeId": "A09_prohibit_film_production",
- "addressIndex":"72",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- }
- ,
- {
- "codeId": "A10_prohibit_film_production",
- "addressIndex":"74",
- "addressLenght":"2",
- "ratio":"1",
- "unit":""
- }
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcCleaning.json b/ShangHaiMesParent/JsonFile/PlcCleaning.json
deleted file mode 100644
index da2a580..0000000
--- a/ShangHaiMesParent/JsonFile/PlcCleaning.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "plcAddressBegin":"DB1.8000",
- "plcAddressLenght":"84",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "edgSpeed",
- "addressIndex": "48",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "thinness",
- "addressIndex": "50",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- }
-
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcEdging.json b/ShangHaiMesParent/JsonFile/PlcEdging.json
deleted file mode 100644
index 41bf3e5..0000000
--- a/ShangHaiMesParent/JsonFile/PlcEdging.json
+++ /dev/null
@@ -1,190 +0,0 @@
-{
- "plcAddressBegin":"0000",
- "plcAddressLength":"50",
- "requestHead":"000100000006010300000032",
- "parameterInfo":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "10",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "12",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReport2",
- "addressIndex": "16",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReportID2",
- "addressIndex": "18",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "20",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSendID",
- "addressIndex": "22",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "length",
- "addressIndex": "24",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "width",
- "addressIndex": "26",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "thickness",
- "addressIndex": "28",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "38",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID",
- "addressIndex": "40",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirm2",
- "addressIndex": "46",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID2",
- "addressIndex": "48",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "58",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord1",
- "addressIndex": "60",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord2",
- "addressIndex": "62",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord3",
- "addressIndex": "64",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "68",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut2",
- "addressIndex": "70",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut3",
- "addressIndex": "72",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut4",
- "addressIndex": "74",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut5",
- "addressIndex": "76",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut6",
- "addressIndex": "78",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut7",
- "addressIndex": "80",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- }
- ]
-
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcFlipSlice.json b/ShangHaiMesParent/JsonFile/PlcFlipSlice.json
deleted file mode 100644
index 036eb1f..0000000
--- a/ShangHaiMesParent/JsonFile/PlcFlipSlice.json
+++ /dev/null
@@ -1,148 +0,0 @@
-{
- "plcAddressBegin":"DB100.0",
- "plcAddressLenght":"568",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcRequestType",
- "addressIndex": "258",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby20",
- "addressIndex": "260",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby21",
- "addressIndex": "262",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "264",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "266",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby25",
- "addressIndex": "268",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby26",
- "addressIndex": "270",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby27",
- "addressIndex": "272",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "274",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSendID",
- "addressIndex": "276",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "length",
- "addressIndex": "532",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "width",
- "addressIndex": "534",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "thickness",
- "addressIndex": "536",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby28",
- "addressIndex": "538",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSendType",
- "addressIndex": "540",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby30",
- "addressIndex": "542",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby31",
- "addressIndex": "544",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby32",
- "addressIndex": "546",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- }
-
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcLamination.json b/ShangHaiMesParent/JsonFile/PlcLamination.json
deleted file mode 100644
index b30baf0..0000000
--- a/ShangHaiMesParent/JsonFile/PlcLamination.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "plcAddressBegin":"DB44.0",
- "plcAddressLenght":"22",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "2",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "4",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
-
- {
- "codeId": "mesSendID",
- "addressIndex": "6",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "length",
- "addressIndex": "8",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "width",
- "addressIndex": "10",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "thickness",
- "addressIndex": "12",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "14",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID",
- "addressIndex": "16",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "18",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "20",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- }
-
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcLoad.json b/ShangHaiMesParent/JsonFile/PlcLoad.json
deleted file mode 100644
index 9bc560c..0000000
--- a/ShangHaiMesParent/JsonFile/PlcLoad.json
+++ /dev/null
@@ -1,134 +0,0 @@
-{
- "plcAddressBegin":"0000",
- "plcAddressLength":"50",
- "requestHead":"000100000006010300000032",
- "parameterInfo":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "10",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "12",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "20",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSendCount",
- "addressIndex": "22",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "40",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "62",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord1",
- "addressIndex": "64",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord2",
- "addressIndex": "66",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord3",
- "addressIndex": "68",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "70",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut2",
- "addressIndex": "72",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut3",
- "addressIndex": "74",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut4",
- "addressIndex": "76",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut5",
- "addressIndex": "78",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut6",
- "addressIndex": "80",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut7",
- "addressIndex": "82",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- }
- ]
-
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcLoad2.json b/ShangHaiMesParent/JsonFile/PlcLoad2.json
deleted file mode 100644
index 9b7feb1..0000000
--- a/ShangHaiMesParent/JsonFile/PlcLoad2.json
+++ /dev/null
@@ -1,134 +0,0 @@
-{
- "plcAddressBegin":"0000",
- "plcAddressLength":"50",
- "requestHead":"000100000006010300000032",
- "parameterInfo":[
- {
- "codeId": "plcRequest",
- "addressIndex": "2",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "4",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "10",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "12",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "20",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSendCount",
- "addressIndex": "22",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "40",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "62",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord1",
- "addressIndex": "64",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord2",
- "addressIndex": "66",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord3",
- "addressIndex": "68",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "70",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut2",
- "addressIndex": "72",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut3",
- "addressIndex": "74",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut4",
- "addressIndex": "76",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut5",
- "addressIndex": "78",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut6",
- "addressIndex": "80",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut7",
- "addressIndex": "82",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- }
- ]
-
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcMarking.json b/ShangHaiMesParent/JsonFile/PlcMarking.json
deleted file mode 100644
index 3436006..0000000
--- a/ShangHaiMesParent/JsonFile/PlcMarking.json
+++ /dev/null
@@ -1,318 +0,0 @@
-{
- "plcAddressBegin":"DB14.0",
- "plcAddressLenght":"1096",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLenght": "4",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby19",
- "addressIndex": "6",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby20",
- "addressIndex": "8",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby21",
- "addressIndex": "10",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "12",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "14",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby25",
- "addressIndex": "18",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby26",
- "addressIndex": "20",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby27",
- "addressIndex": "22",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "24",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
-
- {
- "codeId": "mesSendID",
- "addressIndex": "26",
- "addressLenght": "4",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "drawingMark",
- "addressIndex": "30",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "drawingMark2",
- "addressIndex": "258",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "drawingMark3",
- "addressIndex": "542",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "drawingMark4",
- "addressIndex": "798",
- "addressLenght": "236",
- "ratio": "1",
- "unit": ""
- },
-
- {
- "codeId": "isMark",
- "addressIndex": "1034",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "width(OutOfService)",
- "addressIndex": "1036",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "length(OutOfService)",
- "addressIndex": "1038",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "thickness(OutOfService)",
- "addressIndex": "1040",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "sumCount(OutOfService)",
- "addressIndex": "1042",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby34",
- "addressIndex": "1044",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "markingMode",
- "addressIndex": "1046",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby36",
- "addressIndex": "1048",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "1050",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID",
- "addressIndex": "1052",
- "addressLenght": "4",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby39",
- "addressIndex": "1056",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby40",
- "addressIndex": "1058",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby41",
- "addressIndex": "1060",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby42",
- "addressIndex": "1062",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby43",
- "addressIndex": "1064",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby44",
- "addressIndex": "1066",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "MesTaskStatus",
- "addressIndex": "1068",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby46",
- "addressIndex": "1070",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "1072",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmWord1",
- "addressIndex": "1074",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmWord2",
- "addressIndex": "1076",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmWord3",
- "addressIndex": "1078",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "alarmWord4",
- "addressIndex": "1080",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "1082",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "inputOrOut2",
- "addressIndex": "1084",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "inputOrOut3",
- "addressIndex": "1086",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "inputOrOut4",
- "addressIndex": "1088",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "inputOrOut5",
- "addressIndex": "1090",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- }
-
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcRotate.json b/ShangHaiMesParent/JsonFile/PlcRotate.json
deleted file mode 100644
index 19d1be1..0000000
--- a/ShangHaiMesParent/JsonFile/PlcRotate.json
+++ /dev/null
@@ -1,169 +0,0 @@
-{
- "plcAddressBegin":"DB100.0",
- "plcAddressLenght":"554",
- "dataType":"word",
- "parameteInfor":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcRequestType",
- "addressIndex": "258",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby20",
- "addressIndex": "260",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby21",
- "addressIndex": "262",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "264",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "266",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby25",
- "addressIndex": "268",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby26",
- "addressIndex": "270",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby27",
- "addressIndex": "272",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "274",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSendID",
- "addressIndex": "276",
- "addressLenght": "256",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "length",
- "addressIndex": "532",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "width",
- "addressIndex": "534",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "thickness",
- "addressIndex": "536",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "rotateType",
- "addressIndex": "538",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesSendType",
- "addressIndex": "540",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby30",
- "addressIndex": "542",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby31",
- "addressIndex": "544",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby32",
- "addressIndex": "546",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "548",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID",
- "addressIndex": "550",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- },
- {
- "codeId": "standby35",
- "addressIndex": "552",
- "addressLenght": "2",
- "ratio": "1",
- "unit": ""
- }
-
- ]
-}
diff --git a/ShangHaiMesParent/JsonFile/PlcSilkScreen.json b/ShangHaiMesParent/JsonFile/PlcSilkScreen.json
deleted file mode 100644
index 948f9ce..0000000
--- a/ShangHaiMesParent/JsonFile/PlcSilkScreen.json
+++ /dev/null
@@ -1,184 +0,0 @@
-{
- "plcAddressBegin":"0000",
- "plcAddressLength":"40",
- "requestHead":"000100000006010300000028",
- "parameterInfo":[
- {
- "codeId": "plcRequest",
- "addressIndex": "0",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcRequestID",
- "addressIndex": "2",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReport",
- "addressIndex": "10",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "plcReportID",
- "addressIndex": "12",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSend",
- "addressIndex": "20",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesSendID",
- "addressIndex": "22",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "length",
- "addressIndex": "24",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
-
- {
- "codeId": "width",
- "addressIndex": "26",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "thickness",
- "addressIndex": "28",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "X",
- "addressIndex": "30",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "Y",
- "addressIndex": "32",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "isSilkScreen",
- "addressIndex": "34",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirm",
- "addressIndex": "40",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "mesConfirmID",
- "addressIndex": "42",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmStatus",
- "addressIndex": "60",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord1",
- "addressIndex": "62",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord2",
- "addressIndex": "64",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "alarmWord3",
- "addressIndex": "66",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "machineStatusWord",
- "addressIndex": "68",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut2",
- "addressIndex": "70",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut3",
- "addressIndex": "72",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut4",
- "addressIndex": "74",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut5",
- "addressIndex": "76",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut6",
- "addressIndex": "78",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- },
- {
- "codeId": "inputOrOut7",
- "addressIndex": "80",
- "addressLength": "2",
- "type": "word",
- "unit": ""
- }
- ]
-
-}
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/AppRunnerConfig.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/AppRunnerConfig.java
index 026476d..9871115 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/AppRunnerConfig.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/AppRunnerConfig.java
@@ -34,15 +34,19 @@
//1.鏍规嵁鏁版嵁搴撹澶囪〃鍔犺浇鏁版嵁 寰楀埌鍏ㄩ儴 璁惧淇℃伅
List<Machine> listMachine = machineService.getMachineConfig();
//2.鏍规嵁璁惧閰嶇疆杩涜鍔犺浇澶氱嚎绋�
- for (int i = 1; i < listMachine.size(); i++)
- try {
- Machine machine = listMachine.get(i);
- Thread thread = new Thread(new MachineThread(machine, api));
- thread.start();
- thread.setName(machine.getName());
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("澶氱嚎绋嬪紓甯革紒锛�");
+ //2.鏍规嵁璁惧閰嶇疆杩涜鍔犺浇澶氱嚎绋�
+ for (int i = 0; i < listMachine.size(); i++){
+ if("ON".equals(listMachine.get(i).getOpen()) ){
+ try {
+ Machine machine = listMachine.get(i);
+ Thread thread = new Thread(new MachineThread(machine, api));
+ thread.start();
+ thread.setName(machine.getName());
+ } catch (Exception e) {
+ // TODO: handle exception
+ System.out.println("澶氱嚎绋嬪紓甯革紒锛�");
+ }
}
+ }
}
}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java
index f3cbc35..a4f50d2 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java
@@ -2,21 +2,24 @@
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
public class ReadFile {
// 璇诲彇Json鏂囦欢鍐呭
- public static JSONObject readJson(String fileName) throws IOException {
+ public static JSONObject readJson(String fileUrl) throws IOException {
// 璧勬簮璺緞锛堢浉瀵逛簬resources鏍圭洰褰曪級
- String resourcePath = "jsonFile/"+fileName;
+ //String resourcePath = "jsonFile/"+fileName;
+ //String resourcePath = System.getProperty("user.dir") + "/JsonFile/"+fileName;
+ String resourcePath = fileUrl;
// 鑾峰彇绫诲姞杞藉櫒
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ //ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// 璇诲彇璧勬簮
- try (InputStream inputStream = classLoader.getResourceAsStream(resourcePath)) {
+
+ try (InputStream inputStream = new FileInputStream(resourcePath)) {
+ //try (InputStream inputStream = classLoader.getResourceAsStream(resourcePath)) {
if (inputStream == null) {
throw new IOException("璧勬簮鏈壘鍒�: " + resourcePath);
}
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/Api.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/Api.java
index 609a592..61a9109 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/Api.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/Api.java
@@ -2,6 +2,11 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.dynamic.datasource.annotation.DS;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.mes.connect.entity.ApiConfig;
+import com.mes.connect.entity.LogicItem;
+import com.mes.connect.entity.PlcParameters;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -19,7 +24,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+@Slf4j
@Service
public class Api implements ApiService {
@@ -37,6 +44,47 @@
this.restTemplate = restTemplate;
this.jdbcTemplate = jdbcTemplate;
}
+
+ /**
+ * 鍙戦�佽皟鐢ㄦ帴鍙h姹� 锛屾牴鎹�昏緫閰嶇疆璋冪敤
+ *
+ * @param apiConfig 閫昏緫閰嶇疆鍙傛暟
+ * @param plcParameters plc鍙傛暟
+ * @return 鍝嶅簲鍐呭鎸夎鍒嗗壊鐨勬暟缁�
+ */
+ public List<String> callApi(ApiConfig apiConfig, PlcParameters plcParameters){
+ try{
+ List<String> result=new ArrayList<>();
+ String connectType=apiConfig.getType();
+ String connectAddress=apiConfig.getAddress();
+ Map<String,Object> map=new HashMap<String,Object>();
+ map.put("apiConfig",apiConfig);
+ map.put("plcParameter",plcParameters);
+ switch (connectType) {
+ case "Http":
+ result= this.httpApi(connectAddress,map);
+ break;
+ case "View": // 瑙嗗浘/琛�
+ result= this.viewApi(connectAddress,map);
+ break;
+ case "Procedure": // 瀛樺偍杩囩▼
+ result= this.procedureAPI(connectAddress,map);
+ break;
+ default:
+ log.warn("涓嶆敮鎸佺殑杩炴帴绫诲瀷: {}", connectType);
+ return null; // 涓嶆敮鎸佺殑鏂瑰紡
+ }
+ return result;
+ }catch (Exception e){
+ log.error("璋冪敤鎺ュ彛澶辫触: {}", e.getMessage(), e);
+ }
+ return null;
+ }
+
+
+
+
+
/**
* 鍙戦�丠TTP璇锋眰锛屾敮鎸丟ET鍜孭OST鏂规硶
*
@@ -52,8 +100,11 @@
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
// 澶勭悊鍝嶅簲
String responseBody;
- String method=data.get("method").toString();
- data.remove("method");
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, Object> apiConfig= mapper.convertValue(data.get("apiConfig"), Map.class);
+ Map<String, Object> parameters= mapper.convertValue(apiConfig.get("parameters"), Map.class);
+ String method=parameters.get("method").toString();
+ data.remove("parameters");
if ("GET".equals(method)) {
// GET璇锋眰锛氬皢鍙傛暟娣诲姞鍒癠RL鏌ヨ鍙傛暟涓�
if (data != null) {
@@ -97,12 +148,14 @@
}
@DS("mes_machine")
@Override
- public List<String> viewApi(String viewName, Map<String, Object> params) {
+ public List<String> viewApi(String viewName, Map<String, Object> parameters) {
// 楠岃瘉瑙嗗浘鍚嶆槸鍚﹀悎娉曪紝闃叉SQL娉ㄥ叆
if (!isValidViewName(viewName)) {
throw new IllegalArgumentException("鏃犳晥鐨勮鍥惧悕绉�");
}
-
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, Object> apiConfig= mapper.convertValue(parameters.get("apiConfig"), Map.class);
+ Map<String, Object> params= mapper.convertValue(apiConfig.get("parameters"), Map.class);
// 浣跨敤棰勭紪璇戣鍙ユ瀯寤烘煡璇�
StringBuilder sql = new StringBuilder("SELECT * FROM " + viewName);
MapSqlParameterSource paramSource = new MapSqlParameterSource();
@@ -130,66 +183,67 @@
}
@DS("jiumumes")
@Override
- public List<String> procedureAPI(String procedureName, Map<String, Object> params,Map<String, Object> outParams) {
+ public List<String> procedureAPI(String procedureName, Map<String, Object> params) {
try {
if (!isValidProcedureName(procedureName)) {
throw new IllegalArgumentException("鏃犳晥鐨勫瓨鍌ㄨ繃绋嬪悕绉�");
}
-
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, Object> apiConfig= mapper.convertValue(params.get("apiConfig"), Map.class);
+ Map<String, Object> parameters=mapper.convertValue(apiConfig.get("parameters"), Map.class);
+ Map<String, Object> inParams= mapper.convertValue(parameters.get("inParams"), Map.class);
+ Map<String, Object> outParams= mapper.convertValue(parameters.get("outParams"), Map.class);
+ // 鍒涘缓鏂扮殑 Map 骞跺悎骞�
+ Map<String, Object> mergedMap = new HashMap<>(inParams);
+ mergedMap.putAll(outParams);
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate)
.withProcedureName(procedureName)
.withoutProcedureColumnMetaDataAccess();
-
- if (params != null) {
- for (Map.Entry<String, Object> entry : params.entrySet()) {
- // 纭畾鍙傛暟绫诲瀷
- int sqlType = getSqlType(entry.getValue());
-
- // 妫�鏌ユ槸鍚︿负杈撳嚭鍙傛暟
- if (outParams != null && outParams.containsKey(entry.getKey())) {
- Object outParamInfo = outParams.get(entry.getKey());
- int outSqlType;
-
- // 浠庤緭鍑哄弬鏁颁俊鎭腑鑾峰彇SQL绫诲瀷
- if (outParamInfo instanceof Integer) {
- outSqlType = (Integer) outParamInfo;
- } else if (outParamInfo instanceof Map) {
- // 鍋囪Map涓寘鍚�"sqlType"閿�
- Map<String, Object> outParamMap = (Map<String, Object>) outParamInfo;
- outSqlType = (Integer) outParamMap.getOrDefault("sqlType", sqlType);
- } else {
- // 榛樿浣跨敤杈撳叆鍙傛暟鐨凷QL绫诲瀷
- outSqlType = sqlType;
- }
-
- // 浣跨敤鎸囧畾鐨凷QL绫诲瀷浣滀负杈撳嚭鍙傛暟
- jdbcCall.declareParameters(
- new SqlOutParameter(entry.getKey(), outSqlType)
- );
- } else {
- // 浣滀负杈撳叆鍙傛暟
- jdbcCall.declareParameters(
- new SqlParameter(entry.getKey(), sqlType)
- );
- }
- }
+ for (Map.Entry<String, Object> entry : inParams.entrySet()) {
+ int sqlType = getSqlType(entry.getValue());
+ // 浣滀负杈撳叆鍙傛暟
+ jdbcCall.declareParameters(
+ new SqlParameter(entry.getKey(), sqlType)
+ );
}
+ for (Map.Entry<String, Object> entry : outParams.entrySet()) {
+ int outSqlType=12;
+// int sqlType = getSqlType(entry.getValue());
+// Object outParamInfo = outParams.get(entry.getKey());
+// // 浠庤緭鍑哄弬鏁颁俊鎭腑鑾峰彇SQL绫诲瀷
+// if (outParamInfo instanceof Integer) {
+// outSqlType = (Integer) outParamInfo;
+// } else if (outParamInfo instanceof Map) {
+// // 鍋囪Map涓寘鍚�"sqlType"閿�
+// Map<String, Object> outParamMap = (Map<String, Object>) outParamInfo;
+// outSqlType = (Integer) outParamMap.getOrDefault("sqlType", sqlType);
+// } else {
+// // 榛樿浣跨敤杈撳叆鍙傛暟鐨凷QL绫诲瀷
+// outSqlType = sqlType;
+// }
+ // 浣跨敤鎸囧畾鐨凷QL绫诲瀷浣滀负杈撳嚭鍙傛暟
+ jdbcCall.declareParameters(
+ new SqlOutParameter(entry.getKey(), outSqlType)
+ );
+ }
// 鎵ц瀛樺偍杩囩▼骞惰幏鍙栫粨鏋�
- Map<String, Object> result = jdbcCall.execute(params);
+ Map<String, Object> result = jdbcCall.execute(mergedMap);
// 澶勭悊杈撳嚭鍙傛暟
if (outParams != null) {
for (String paramName : outParams.keySet()) {
if (result.containsKey(paramName)) {
// 灏嗚緭鍑哄弬鏁扮殑鍊兼斁鍥炲師鍙傛暟Map涓�
- params.put(paramName, result.get(paramName));
+ outParams.put(paramName, result.get(paramName));
}
}
}
-
+ List<String> outParamsValues = outParams.values().stream()
+ .map(value -> value != null ? value.toString() : "null")
+ .collect(Collectors.toList());
// 杩斿洖缁撴灉淇℃伅
- return null;
+ return outParamsValues;
} catch (Exception e) {
return null;
}
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/ApiService.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/ApiService.java
index dd6c553..d4cc63d 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/ApiService.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/IndustrialInterface/ApiService.java
@@ -35,10 +35,9 @@
/**
* 璋冪敤瀛樺偍杩囩▼
* @param procedureName 瀛樺偍杩囩▼鍚嶇О
- * @param params 杈撳叆鍙傛暟
- * @param outParams 杈撳嚭鍙傛暟
+ * @param params 鍙傛暟
* @return 瀛樺偍杩囩▼鎵ц缁撴灉
*/
- List<String> procedureAPI(String procedureName, Map<String, Object> params,Map<String, Object> outParams);
+ List<String> procedureAPI(String procedureName, Map<String, Object> params);
}
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/Thread/MachineThread.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/Thread/MachineThread.java
index aa1cdc0..b1da536 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/Thread/MachineThread.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/Thread/MachineThread.java
@@ -24,10 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@@ -55,6 +52,24 @@
this.api = api;
this.logicConfig = JsonConversion.jsonToObjectByJackson(ReadFile.readJson(machine.getLogicFile()).toString(), LogicConfig.class);
this.plcParameters = JsonConversion.jsonToObjectByJackson(ReadFile.readJson(machine.getMachineFile()).toString(), PlcParameters.class);
+ this.logicConfig.getLogics();
+ this.plcParameters.Initialization();
+ for (LogicItem logicItem : logicConfig.getLogics()) {
+ if (logicItem.getLogicInterval()==0){
+ //榛樿1000姣
+ logicItem.setLogicInterval(1000);
+ }
+ for (Logic logic : logicItem.getLogic()) {
+ logic.setAddress(this.plcParameters.getMap().get(logic.getCodeId()).getAddress());
+ logic.setPlcDataType(this.plcParameters.getMap().get(logic.getCodeId()).getPlcDataType());
+ }
+ for (ReturnValue returnValue : logicItem.getReturnValue()) {
+ returnValue.setAddress(this.plcParameters.getMap().get(returnValue.getCodeId()).getAddress());
+ returnValue.setPlcDataType(this.plcParameters.getMap().get(returnValue.getCodeId()).getPlcDataType());
+ }
+ }
+
+
switch (machine.getProtocolType().getName()) {
case "ModbusTcp":
client = new ModbusTcpClient(machine.getIp(), machine.getPort(), 1);
@@ -72,54 +87,23 @@
log.error("鏃犳晥鐨勫崗璁被鍨�: {}", protocolType);
throw new IllegalArgumentException("鏃犳晥鐨勫崗璁被鍨�: " + protocolType);
}
- if (client != null) {
- client.connect();
- boolean connected = client.isConnected();
- if (!connected) {
- log.error("杩炴帴PLC澶辫触: {}", machine.getIp());
- }
- }
}
@Override
public void run() {
- log.info("MachineThread鍚姩锛岃澶嘔P: {}", machine.getIp());
- if (client == null || !client.isConnected()) {
- log.error("PLC瀹㈡埛绔湭杩炴帴锛岀嚎绋嬮��鍑�");
- return;
- }
-
- plcParameters.Initialization();
-
- try {
- // 鍒濆鍖栬鍙朠LC鍙傛暟
- readPlcParameter();
- } catch (Exception e) {
- log.error("鍒濆鍖栬鍙朠LC鍙傛暟澶辫触: {}", e.getMessage(), e);
- return;
- }
- // 涓烘瘡涓�昏緫椤瑰垱寤哄苟鍚姩瀛愮嚎绋�
- //startLogicThread(logicConfig.getLogics().get(0));
- for (LogicItem logicItem : logicConfig.getLogics()) {
- startLogicThread(logicItem);
- //startLogicThread(logicConfig.getLogics().get(0));
- }
-
// 涓荤嚎绋嬫寔缁繍琛岋紝瀹氭湡璇诲彇PLC鍙傛暟骞剁洃鎺ц繛鎺ョ姸鎬�
while (running) {
try {
- // 璇诲彇PLC鍙傛暟锛屼负閫昏緫澶勭悊鎻愪緵鏈�鏂版暟鎹�
- readPlcParameter();
-
// 妫�鏌LC杩炴帴鐘舵��
if (!client.isConnected()) {
- log.warn("PLC杩炴帴鏂紑锛屽皾璇曢噸鏂拌繛鎺�");
+ log.info("PLC灏濊瘯杩炴帴... 璁惧IP: {}", machine.getIp());
tryReconnect();
}
-
- // 妫�鏌ラ�昏緫绾跨▼鐘舵�侊紝閲嶅惎宸茬粓姝㈢殑绾跨▼
+ // 璇诲彇PLC鍙傛暟锛屼负閫昏緫澶勭悊鎻愪緵鏈�鏂版暟鎹�
+ this.readPlcParameter();
+ plcParameters.Initialization();
+ // 妫�鏌ラ�昏緫绾跨▼鐘舵�侊紝寮�鍚�/閲嶅惎 绾跨▼
checkLogicThreadsStatus();
-
// 绛夊緟涓嬩竴涓墽琛屽懆鏈�
Thread.sleep(mainThreadInterval);
} catch (InterruptedException e) {
@@ -140,7 +124,6 @@
}
}
}
-
// 绾跨▼閫�鍑哄墠鍏抽棴鎵�鏈夎祫婧�
shutdown();
log.info("MachineThread宸查��鍑猴紝璁惧IP: {}", machine.getIp());
@@ -148,28 +131,22 @@
// 涓烘寚瀹氶�昏緫椤瑰垱寤哄苟鍚姩瀛愮嚎绋�
private void startLogicThread(LogicItem logicItem) {
- String logicId = logicItem.getName(); // 鍋囪姣忎釜LogicItem鏈夊敮涓�ID
+ String logicId = this.machine.getId()+" - "+this.machine.getName()+" - "+ logicItem.getName(); // 鍋囪姣忎釜LogicItem鏈夊敮涓�ID
if (logicThreads.containsKey(logicId) && logicThreads.get(logicId).isAlive()) {
- log.warn("閫昏緫椤圭嚎绋嬪凡鍦ㄨ繍琛�: {}", logicId);
return;
}
-
// 璁剧疆杩愯鏍囧織
logicRunningFlags.put(logicId, true);
-
// 鍒涘缓骞跺惎鍔ㄧ嚎绋�
Thread thread = new Thread(() -> {
log.info("閫昏緫椤圭嚎绋嬪惎鍔�: {}", logicId);
-
// 閫昏緫椤瑰瓙绾跨▼鎸佺画杩愯鐨勫惊鐜�
while (logicRunningFlags.getOrDefault(logicId, false)) {
try {
// 鎵ц瀹為檯涓氬姟閫昏緫
basicsLogic(logicItem);
-
// 鏍规嵁閫昏緫椤圭殑鎵ц棰戠巼璁剧疆绛夊緟鏃堕棿锛岄粯璁�1000ms
- int logicInterval = 1000;
- Thread.sleep(logicInterval);
+ Thread.sleep(logicItem.getLogicInterval());
} catch (InterruptedException e) {
log.info("閫昏緫椤圭嚎绋嬭涓柇锛屽噯澶囬��鍑�: {}", logicId);
logicRunningFlags.put(logicId, false);
@@ -186,31 +163,23 @@
}
}
}
-
- log.info("閫昏緫椤圭嚎绋嬪凡閫�鍑�: {}", logicId);
});
-
// 璁剧疆绾跨▼鍚嶇О
- thread.setName("Logic-" + logicId);
-
+ thread.setName(logicId);
// 瀛樺偍绾跨▼寮曠敤
logicThreads.put(logicId, thread);
-
// 鍚姩绾跨▼
thread.start();
- log.info("宸插惎鍔ㄩ�昏緫椤圭嚎绋�: {}", logicId);
+ //log.info("宸插惎鍔ㄩ�昏緫椤圭嚎绋�: {}", logicId);
}
// 妫�鏌ラ�昏緫绾跨▼鐘舵�侊紝閲嶅惎宸茬粓姝㈢殑绾跨▼
private void checkLogicThreadsStatus() {
for (LogicItem logicItem : logicConfig.getLogics()) {
- String logicId = logicItem.getName();
+ String logicId = this.machine.getId()+" - "+this.machine.getName()+" - "+ logicItem.getName();
Thread thread = logicThreads.get(logicId);
-
// 濡傛灉绾跨▼涓嶅瓨鍦ㄦ垨宸茬粓姝笖杩愯鏍囧織涓簍rue锛屽垯閲嶅惎绾跨▼
- if ((thread == null || !thread.isAlive()) &&
- logicRunningFlags.getOrDefault(logicId, false)) {
- log.warn("閫昏緫椤圭嚎绋嬪凡缁堟锛屽噯澶囬噸鍚�: {}", logicId);
+ if ((thread == null || !thread.isAlive()) &&!logicRunningFlags.getOrDefault(logicId, false)) {
startLogicThread(logicItem);
}
}
@@ -220,9 +189,9 @@
private void tryReconnect() {
if (client != null) {
try {
- log.info("灏濊瘯閲嶆柊杩炴帴PLC: {}", machine.getIp());
client.disconnect();
Thread.sleep(2000);
+ client.connect();
boolean reconnected = client.isConnected();
if (reconnected) {
log.info("PLC閲嶆柊杩炴帴鎴愬姛: {}", machine.getIp());
@@ -238,7 +207,6 @@
// 鍏抽棴绾跨▼鍓嶇殑娓呯悊宸ヤ綔
public void shutdown() {
running = false;
-
// 鍋滄鎵�鏈夐�昏緫绾跨▼
for (String logicId : logicRunningFlags.keySet()) {
logicRunningFlags.put(logicId, false);
@@ -247,7 +215,6 @@
thread.interrupt();
}
}
-
// 绛夊緟鎵�鏈夐�昏緫绾跨▼缁撴潫
for (String logicId : logicThreads.keySet()) {
Thread thread = logicThreads.get(logicId);
@@ -292,37 +259,24 @@
}
}
if (isEqual){
- List<String> result=new ArrayList<>();
+ log.info("婊¤冻鏉′欢:{}",logicItem.getName());
//3.鏌ヨ姝ら�昏緫涓嬮渶瑕佽繑鍥炵粰PLC鐨勬暟鎹� result鍙帴鏀� HTTP鎺ュ彛,瑙嗗浘,瀛樺偍杩囩▼ 绛� 濡備笅
- try{
- String connectType=logicItem.getConnectType();
- String connectAddress=logicItem.getConnectAddress();
- Map map=new HashMap();
- switch (connectType) {
- case "Http":
- map.put("method","POST");
- map.put("plcParameter",plcParameters);
- result= api.httpApi(connectAddress,map);
- log.info("鎺ュ彛杩斿洖鍐呭锛歿}",result);
- break;
- case "View": // 瑙嗗浘/琛�
- result= api.viewApi(connectAddress,map);
- break;
- case "Procedure": // 瀛樺偍杩囩▼
- //result= api.procedureAPI(connectAddress,plcParameter);
- break;
- default:
- log.warn("涓嶆敮鎸佺殑杩炴帴绫诲瀷: {}", connectType);
- return; // 涓嶆敮鎸佺殑鏂瑰紡
+ List<String> resultWrite=null;
+ if (logicItem.getApiConfigBefore()!=null){
+ ApiConfig apiConfig=logicItem.getApiConfigBefore();
+ resultWrite=api.callApi(apiConfig,plcParameters);
+ log.info("ApiConfigBefore 澶栫疆鎺ュ彛[{}:{}]杩斿洖鐨勫唴瀹�:{}",apiConfig.getType(),apiConfig.getAddress(),resultWrite);
+ }
+ //鍐欏叆PLC杩斿洖鍊兼垚鍔熸椂璋冪敤鎺ュ彛
+ if (basicsResult(resultWrite,logicItem.getReturnValue())){
+ ApiConfig apiConfig=logicItem.getApiConfigAfter();
+ if (logicItem.getApiConfigAfter()!=null){
+ List<String> result=api.callApi(apiConfig,plcParameters);
+ log.info("ApiConfigAfter 澶栫疆鎺ュ彛[{}:{}]杩斿洖鐨勫唴瀹�:{}",apiConfig.getType(),apiConfig.getAddress(),result);
}
+ }
- }catch (Exception e){
- log.error("璋冪敤鎺ュ彛澶辫触: {}", e.getMessage(), e);
- }
- //4.杩斿洖PLC鍐呭
- if (result != null&&!result.isEmpty()) {
- basicsResult(result,logicItem.getReturnValue());
- }
+
}
} catch (Exception e) {
log.error("鎵цbasicsLogic澶辫触: {}", e.getMessage(), e);
@@ -344,20 +298,22 @@
if (values!=null && !values.equals("")){
//杩橀渶澧炴坊 涓嶅悓绫诲瀷璋冪敤涓嶅悓鏂规硶
switch (itemReturnValue.getPlcDataType()) {
- case "int":
+ case "Word":
client.writeRegister(itemReturnValue.getAddress(),(int)Double.parseDouble(values));
break;
- case "string":
+ case "String":
client.writeString(itemReturnValue.getAddress(),values);
break;
- case "float":
+ case "Float":
client.writeFloat(itemReturnValue.getAddress(),Float.valueOf(values));
+ break;
+ case "bit":
+ client.writeBit(itemReturnValue.getAddress(),Boolean.valueOf(values));
break;
default:
log.error("涓嶆敮鎸佺殑鏁版嵁绫诲瀷: {}", itemReturnValue.getPlcDataType());
return false;
}
-
}
}
return true;
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/ApiConfig.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/ApiConfig.java
new file mode 100644
index 0000000..3532344
--- /dev/null
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/ApiConfig.java
@@ -0,0 +1,17 @@
+package com.mes.connect.entity;
+
+
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class ApiConfig {
+ private String codeId;
+ private String type;
+ private String address;
+ private Map<String,Object> parameters;
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/LogicItem.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/LogicItem.java
index 7b82092..66796a4 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/LogicItem.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/connect/entity/LogicItem.java
@@ -11,9 +11,9 @@
public class LogicItem {
private String name;
private String sequence;
- private String connectType;
- private String method;
- private String connectAddress;
+ private int logicInterval;
+ private ApiConfig apiConfigBefore;
+ private ApiConfig apiConfigAfter;
private List<Logic> logic;
private List<ReturnValue> returnValue;
@Getter
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/model/entity/Machine.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/model/entity/Machine.java
index 267d49c..af481a5 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/model/entity/Machine.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/model/entity/Machine.java
@@ -61,14 +61,29 @@
private int port;
/**
- * 绔彛
+ * 鍙傛暟鏂囦欢璺緞
+ */
+ private String fileUrl;
+ /**
+ * 鍙傛暟鏂囦欢
*/
private String machineFile;
/**
- * 绔彛
+ * 閫昏緫鏂囦欢
*/
private String logicFile;
+ /**
+ * 寮�鍏�
+ */
+ private String open;
+
+ public String getMachineFile(){
+ return this.fileUrl+"\\"+this.machineFile;
+ }
+ public String getLogicFile(){
+ return this.fileUrl+"\\"+this.logicFile;
+ }
}
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/Edg.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/Edg.json
new file mode 100644
index 0000000..01c0091
--- /dev/null
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/Edg.json
@@ -0,0 +1,52 @@
+{
+ "parameters": [
+ {
+ "serialNumber": 0,
+ "content": "PLC璇锋眰",
+ "codeId": "plcRequest",
+ "plcDataType": "Word",
+ "fontLocation": 0,
+ "length": 2,
+ "ratio": 1,
+ "scale": 10,
+ "address": "S7.DB8.DBW0",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 1,
+ "content": "Mes鍙戦�佸瓧",
+ "codeId": "mesSend",
+ "plcDataType": "Word",
+ "fontLocation": 18,
+ "length": 2,
+ "ratio": 1,
+ "scale": 10,
+ "address": "S7.DB8.DBW2",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 2,
+ "content": "MES鍙戦�侀暱",
+ "codeId": "width",
+ "plcDataType": "Word",
+ "fontLocation": 20,
+ "length": 2,
+ "ratio": 11,
+ "scale": 11,
+ "address": "S7.DB8.DBW4",
+ "remarks": ""
+ },
+ {
+ "serialNumber": 11,
+ "content": "MES鍙戦�佸",
+ "codeId": "height",
+ "plcDataType": "Word",
+ "fontLocation": 22,
+ "length": 2,
+ "ratio": 12,
+ "scale": 12,
+ "address":"S7.DB8.DBW6",
+ "remarks": ""
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicHttp.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicHttp.json
new file mode 100644
index 0000000..e79c601
--- /dev/null
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicHttp.json
@@ -0,0 +1,141 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "loadSelect",
+ "type": "Http",
+ "address": "http://localhost:8082/account/testApi",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 1
+ },
+ {
+ "codeId": "width",
+ "fixed": false,
+ "value": 1
+ }
+ ,
+ {
+ "codeId": "height",
+ "fixed": false,
+ "value": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "apiConfigBefore": {
+ "codeId": "",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ },
+ {
+ "name":"瀹屾垚閫昏緫",
+ "sequence":"3",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcComplete",
+ "value": [1]
+ },
+ {
+ "codeId": "mesComplete",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesComplete",
+ "fixed": true,
+ "value": 1
+ }
+ ]
+ },
+ {
+ "name":"瀹屾垚娓呯┖",
+ "sequence":"4",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcComplete",
+ "value": [0]
+ },
+ {
+ "codeId": "mesComplete",
+ "value": [1,2,3]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesComplete",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicProcedure.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicProcedure.json
new file mode 100644
index 0000000..31cdd26
--- /dev/null
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicProcedure.json
@@ -0,0 +1,92 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "Procedure",
+ "address": "testProcedure",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "address": "S7.DB8.DBW2",
+ "fixed": true,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ },
+ {
+ "codeId": "width",
+ "address": "S7.DB8.DBW4",
+ "fixed": false,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ,
+ {
+ "codeId": "height",
+ "address": "S7.DB8.DBW6",
+ "fixed": false,
+ "value": 2,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicView.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicView.json
new file mode 100644
index 0000000..9cd2552
--- /dev/null
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/EdgLogicView.json
@@ -0,0 +1,89 @@
+{
+ "logics": [
+ {
+ "name":"璇锋眰閫昏緫",
+ "sequence":"1",
+ "apiConfigBefore": {
+ "codeId": "edgSelect",
+ "type": "View",
+ "address": "viewname"
+ },
+ "apiConfigAfter": {
+ "codeId": "edgSelect",
+ "type": "Http",
+ "address": "http://localhost:8082/account/testApi",
+ "parameters": {
+ "method": "POST"
+ }
+ },
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [1]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [0]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "address": "S7.DB8.DBW2",
+ "fixed": true,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ },
+ {
+ "codeId": "width",
+ "address": "S7.DB8.DBW4",
+ "fixed": false,
+ "value": 1,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ,
+ {
+ "codeId": "height",
+ "address": "S7.DB8.DBW6",
+ "fixed": false,
+ "value": 2,
+ "plcDataType": "int",
+ "length": 2
+ }
+ ]
+ },
+ {
+ "name":"璇锋眰娓呯┖",
+ "sequence":"2",
+ "logic":[
+ {
+ "codeId": "plcRequest",
+ "value": [0]
+ },
+ {
+ "codeId": "mesSend",
+ "value": [1]
+ }
+ ],
+ "returnValue": [
+ {
+ "codeId": "mesSend",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "width",
+ "fixed": true,
+ "value": 0
+ },
+ {
+ "codeId": "height",
+ "fixed": true,
+ "value": 0
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelf.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfModbusTcp.json
similarity index 100%
rename from ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelf.json
rename to ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfModbusTcp.json
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfS7.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfS7.json
similarity index 100%
rename from ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfS7.json
rename to ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/ShelfS7.json
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic.json
deleted file mode 100644
index bba83fa..0000000
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic.json
+++ /dev/null
@@ -1,165 +0,0 @@
-{
- "logics": [
- {
- "name":"璇锋眰閫昏緫",
- "sequence":"1",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "MB.4x0001",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "MB.4x0011",
- "fixed": false,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ,
- {
- "codeId": "height",
- "address": "MB.4x0012",
- "fixed": false,
- "value": 2,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"璇锋眰娓呯┖",
- "sequence":"2",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "MB.4x0001",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "MB.4x0011",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "height",
- "address": "MB.4x0012",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚閫昏緫",
- "sequence":"3",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "MB.4x0005",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚娓呯┖",
- "sequence":"4",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "MB.4x0005",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "value": [1,2,3],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic2.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic2.json
deleted file mode 100644
index 0e5903d..0000000
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogic2.json
+++ /dev/null
@@ -1,165 +0,0 @@
-{
- "logics": [
- {
- "name":"璇锋眰閫昏緫",
- "sequence":"1",
- "connectType":"Http",
- "connectAddress": "http://localhost:8082/account/testApi",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "MB.4x0001",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "MB.4x0011",
- "fixed": false,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ,
- {
- "codeId": "height",
- "address": "MB.4x0012",
- "fixed": false,
- "value": 2,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"璇锋眰娓呯┖",
- "sequence":"2",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "MB.4x0001",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "MB.4x0011",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "height",
- "address": "MB.4x0012",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚閫昏緫",
- "sequence":"3",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "MB.4x0005",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚娓呯┖",
- "sequence":"4",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "MB.4x0005",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "value": [1,2,3],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "MB.4x0020",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogicS7.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogicS7.json
deleted file mode 100644
index 9c9699b..0000000
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/loadLogicS7.json
+++ /dev/null
@@ -1,165 +0,0 @@
-{
- "logics": [
- {
- "name":"璇锋眰閫昏緫",
- "sequence":"1",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "S7.DB8.DBW0",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "S7.DB8.DBW20",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "S7.DB8.DBW20",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "S7.DB8.DBW22",
- "fixed": false,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ,
- {
- "codeId": "height",
- "address": "S7.DB8.DBW24",
- "fixed": false,
- "value": 2,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"璇锋眰娓呯┖",
- "sequence":"2",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "S7.DB8.DBW0",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "S7.DB8.DBW20",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "S7.DB8.DBW20",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "S7.DB8.DBW22",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "height",
- "address": "S7.DB8.DBW24",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚閫昏緫",
- "sequence":"3",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "S7.DB8.DBW10",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "S7.DB8.DBW40",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "S7.DB8.DBW40",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚娓呯┖",
- "sequence":"4",
- "connectType":"View",
- "connectAddress": "viewname",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "S7.DB8.DBW10",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "S7.DB8.DBW40",
- "value": [1,2,3],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "S7.DB8.DBW40",
- "fixed": true,
- "value": 0,
- "plcDataType": "int",
- "length": 2
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/logicalRelationship.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/logicalRelationship.json
deleted file mode 100644
index c60bf22..0000000
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/logicalRelationship.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "璇锋眰閫昏緫":{
- "name":"璇锋眰閫昏緫",
- "connectType":"HTTP",
- "connectAddress": "http://39.105.110.179:5000/Request"
- },
- "璇锋眰娓呯┖":{
- "name":"璇锋眰娓呯┖",
- "connectType":"Procedure",
- "connectAddress": "瀛樺偍杩囩▼鍚嶇О"
- },
- "瀹屾垚閫昏緫":{
- "name":"瀹屾垚閫昏緫",
- "connectType":"View",
- "connectAddress": "瑙嗗浘鍚嶇О"
- }
-}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfLogic.json b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfLogic.json
deleted file mode 100644
index 8daa381..0000000
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/JsonFile/shelfLogic.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "logics": [
- {
- "name":"璇锋眰閫昏緫",
- "sequence":"1",
- "connectType":"Http",
- "connectAddress": "http://localhost:8082/account/testApi",
- "logic":[
- {
- "codeId": "plcRequest",
- "address": "MB.4x0001",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesSend",
- "address": "MB.4x0010",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "width",
- "address": "MB.4x0011",
- "fixed": false,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ,
- {
- "codeId": "height",
- "address": "MB.4x0012",
- "fixed": false,
- "value": 2,
- "plcDataType": "int",
- "length": 2
- }
- ]
- },
- {
- "name":"瀹屾垚閫昏緫",
- "sequence":"2",
- "connectType":"Procedure",
- "connectAddress": "瀛樺偍杩囩▼鍚嶇О",
- "logic":[
- {
- "codeId": "plcComplete",
- "address": "MB.0x0000",
- "value": [1],
- "plcDataType": "int",
- "length": 2
- },
- {
- "codeId": "mesComplete",
- "address": "MB.0x0010",
- "value": [0],
- "plcDataType": "int",
- "length": 2
- }
- ],
- "returnValue": [
- {
- "codeId": "mesComplete",
- "address": "MB.0x0010",
- "fixed": true,
- "value": 1,
- "plcDataType": "int",
- "length": 2
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application-prod.yml b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application-prod.yml
index 358eaaf..4fa800d 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application-prod.yml
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application-prod.yml
@@ -9,11 +9,11 @@
username: root
password: beibo.123/
driver-class-name: com.mysql.cj.jdbc.Driver
- salve_JomooKBB:
- url: jdbc:sqlserver://localhost:1433;databasename=JomooKBB
- username: sa
- password: beibo.123/
- driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
+# salve_JomooKBB:
+# url: jdbc:sqlserver://localhost:1433;databasename=JomooKBB
+# username: sa
+# password: beibo.123/
+# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# salve_JomooKBB:
# url: jdbc:sqlserver://172.18.19.85:1433;databasename=JomooKBB
# username: thok
@@ -22,9 +22,9 @@
cloud:
nacos:
discovery:
- server-addr: localhost:8848
+ server-addr: localhost:8849
application:
- name: deviceInteraction
+ name: plcConnect
redis:
database: 0
host: localhost
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application.yml b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application.yml
index 91d3f80..385a455 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application.yml
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/main/resources/application.yml
@@ -1,5 +1,5 @@
server:
- port: 8081
+ port: 8001
tomcat:
uri-encoding: UTF-8
max-threads: 800 #鏈�澶у伐浣滅嚎绋嬫暟閲�
@@ -15,19 +15,4 @@
mapper-locations: classpath*:mapper/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-mes:
- threshold: 3
- ratio: 10
- max: # 绗簩鏉$嚎鐨勬渶澶у昂瀵镐俊鎭�
- firstLength: 3500
- secondLength: 2500
- min:
- one: #绗竴鏉$(杈圭嚎鐨勬渶灏忓昂瀵镐俊鎭�
- firstLength: 600
- secondLength: 350
- two: #绗簩鏉$(杈圭嚎鐨勬渶灏忓昂瀵镐俊鎭�
- firstLength: 400
- secondLength: 300
- sequence:
- order: false
diff --git a/ShangHaiMesParent/moduleService/plcConnectModule/src/test/java/com/mes/plcConnectModuleApplicationTest.java b/ShangHaiMesParent/moduleService/plcConnectModule/src/test/java/com/mes/plcConnectModuleApplicationTest.java
index 2819180..7eeaf0b 100644
--- a/ShangHaiMesParent/moduleService/plcConnectModule/src/test/java/com/mes/plcConnectModuleApplicationTest.java
+++ b/ShangHaiMesParent/moduleService/plcConnectModule/src/test/java/com/mes/plcConnectModuleApplicationTest.java
@@ -43,16 +43,7 @@
String s="鐧界幓";
log.info(s);
}
- @Test
- public void testReadJson() {
- try {
- LogicConfig logicConfig=JsonConversion.jsonToObjectByJackson(ReadFile.readJson("shelfLogic.json").toString(), LogicConfig.class);
- PlcParameters plcParameters=JsonConversion.jsonToObjectByJackson(ReadFile.readJson("shelf.json").toString(), PlcParameters.class);
- log.info("{},{}",logicConfig,plcParameters);
- }catch (Exception e) {
- }
- }
@Test
public void testReadS7Old() throws IOException {
S7PLC s7PLC = new S7PLC(EPlcType.S1500, "10.153.19.191", 102, 0, 0);
@@ -135,13 +126,17 @@
// log.info("{}",resultView);
// 绀轰緥 璋冪敤testProcedure瀛樺偍杩囩▼
-// Map<String, Object> params = new HashMap<>();
-// params.put("dataParmars", "娴嬭瘯鏁版嵁"); // 杈撳叆鍙傛暟锛屽搴斿瓨鍌ㄨ繃绋嬩腑鐨処N鍙傛暟
-// Map<String, Object> outParams = new HashMap<>();
-// outParams.put("messagedate", Types.VARCHAR); // 杈撳嚭鍙傛暟锛屽搴斿瓨鍌ㄨ繃绋嬩腑鐨凮UT鍙傛暟
-// String[] resultProcedure = api.procedureAPI("testProcedure", params, outParams);
-// // 鎵撳嵃鎵ц缁撴灉
-// log.info("{}瀛樺偍杩囩▼鎵ц缁撴灉:{}",params,resultProcedure);
+ Map<String, Object> params = new HashMap<>();// 鍙傛暟
+ Map<String, Object> inParams = new HashMap<>();// 杈撳叆鍙傛暟
+ Map<String, Object> outParams = new HashMap<>();// 杈撳嚭鍙傛暟
+ inParams.put("dataParsers", "娴嬭瘯鏁版嵁");
+ outParams.put("messageDate", Types.VARCHAR);
+ outParams.put("messageDate2", Types.VARCHAR);
+ params.put("inParams", inParams);
+ params.put("outParams", outParams);
+ List<String> resultProcedure = api.procedureAPI("testProcedure", params);
+ // 鎵撳嵃鎵ц缁撴灉
+ log.info("{}瀛樺偍杩囩▼鎵ц缁撴灉:{}",params,resultProcedure);
}
@Test
public void testMainThread() {
--
Gitblit v1.8.0