24282 2 år sedan
förälder
incheckning
885187135d
3 ändrade filer med 169 tillägg och 27 borttagningar
  1. 102 24
      config
  2. 63 0
      configBack
  3. 4 3
      src/main/java/com/fjhx/equipment/EquipmentAbstract.java

+ 102 - 24
config

@@ -9,9 +9,8 @@
 #   type            设备类型
 #       -> 1 注塑机
 #       -> 2 滚印机
-#       -> 3 组装机
-#       -> 4 螺纹头
-#       -> 5 注射针
+#       -> 3 注射器组装机
+#       -> 4 螺纹头组装机
 #   other {         其他配置:每种协议特有配置统一放这
 #       如:
 #       type为 2、3、4、5 时,走modBusTcp协议:可配置以下信息,不配置则为默认值
@@ -35,28 +34,107 @@
     "secret": "fjhx2012",
 
     "connectConfigList": [
-#        {
-#            "equipmentNo": "test1",
-#            "ipAddress": "192.168.0.140",
-#            "port": 502,
-#            "type": 2
-#        },
-        {
-             "equipmentNo": "test1",
-             "ipAddress": "192.168.1.174",
+        {
+             "equipmentNo": "zsj01",
+             "ipAddress": "192.168.157.20",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj02",
+             "ipAddress": "192.168.157.21",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj03",
+             "ipAddress": "192.168.157.22",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj04",
+             "ipAddress": "192.168.157.23",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj05",
+             "ipAddress": "192.168.157.24",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj06",
+             "ipAddress": "192.168.157.25",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj07",
+             "ipAddress": "192.168.157.26",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj08",
+             "ipAddress": "192.168.157.27",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj09",
+             "ipAddress": "192.168.157.28",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj10",
+             "ipAddress": "192.168.157.29",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "zsj11",
+             "ipAddress": "192.168.157.30",
+             "port": 16664,
+             "type": 1
+        },
+        {
+             "equipmentNo": "gyj01",
+             "ipAddress": "192.168.157.40",
+             "port": 502,
+             "type": 2
+        },
+        {
+             "equipmentNo": "gyj02",
+             "ipAddress": "192.168.157.41",
+             "port": 502,
+             "type": 2
+        },
+        {
+             "equipmentNo": "zzj01",
+             "ipAddress": "192.168.157.60",
+             "port": 502,
+             "type": 3
+        },
+        {
+             "equipmentNo": "zzj02",
+             "ipAddress": "192.168.157.61",
+             "port": 502,
+             "type": 3
+        },
+        {
+             "equipmentNo": "lwt01",
+             "ipAddress": "192.168.157.110",
+             "port": 502,
+             "type": 4
+        },
+        {
+             "equipmentNo": "lwt02",
+             "ipAddress": "192.168.157.111",
              "port": 502,
-             "type": 2,
-             "other": {
-                "slavedId": 1,
-                "coilsOffSet": 0,
-                "coilsQuantity": 17,
-                "discreteInputsOffSet": 0,
-                "discreteInputsQuantity": 21,
-                "inputRegistersOffSet": 0,
-                "inputRegistersQuantity": 0,
-                "holdingRegistersOffSet": 0,
-                "holdingRegistersQuantity": 4
-             }
+             "type": 4
         }
     ]
 

+ 63 - 0
configBack

@@ -0,0 +1,63 @@
+# debug     调试模式
+# serverIp  服务ip
+# deviceId  华为云配置deviceId
+# secret    华为云配置secret
+# connectConfigList 设备配置 {[
+#   equipmentNo     设备编号
+#   ipAddress       设备ip地址
+#   port            设备ip端口号
+#   type            设备类型
+#       -> 1 注塑机
+#       -> 2 滚印机
+#       -> 3 注射器组装机
+#       -> 4 螺纹头组装机
+#       -> 5 注射针
+#   other {         其他配置:每种协议特有配置统一放这
+#       如:
+#       type为 2、3、4、5 时,走modBusTcp协议:可配置以下信息,不配置则为默认值
+#           slavedId                        从机地址 默认 1
+#           coilsOffSet                     0x开始读取地址 默认:0
+#           coilsQuantity                   0x读取位数 默认:100
+#           discreteInputsOffSet            1x开始读取地址 默认:0
+#           discreteInputsQuantity          1x读取位数 默认:100
+#           inputRegistersOffSet            3x开始读取地址 默认:0
+#           inputRegistersQuantity          3x读取位数 默认:100
+#           holdingRegistersOffSet          4x开始读取地址 默认:0
+#           holdingRegistersQuantity        4x读取位数 默认:100
+#   }
+# ]}
+
+
+{
+    "debug": true,
+    "serverIp": "a1625d5cc8.iot-mqtts.cn-north-4.myhuaweicloud.com",
+    "deviceId": "62d4ff516b9813541d51f893_test_node_01",
+    "secret": "fjhx2012",
+
+    "connectConfigList": [
+#        {
+#            "equipmentNo": "test1",
+#            "ipAddress": "192.168.0.140",
+#            "port": 502,
+#            "type": 2
+#        },
+        {
+             "equipmentNo": "test1",
+             "ipAddress": "192.168.1.174",
+             "port": 502,
+             "type": 2,
+             "other": {
+                "slavedId": 1,
+                "coilsOffSet": 0,
+                "coilsQuantity": 17,
+                "discreteInputsOffSet": 0,
+                "discreteInputsQuantity": 21,
+                "inputRegistersOffSet": 0,
+                "inputRegistersQuantity": 0,
+                "holdingRegistersOffSet": 0,
+                "holdingRegistersQuantity": 4
+             }
+        }
+    ]
+
+}

+ 4 - 3
src/main/java/com/fjhx/equipment/EquipmentAbstract.java

@@ -19,13 +19,14 @@ public abstract class EquipmentAbstract {
     // 初始化华为IoTDA监听
     protected static MqttClient mqttClient = new MqttClient();
 
-    protected ConnectConfig connectConfig;
-    protected ClientAbstract client;
-
     static {
         mqttClient.connect();
     }
 
+    protected ConnectConfig connectConfig;
+    protected ClientAbstract client;
+
+
     /**
      * 初始化
      *