From d3553d8dd6fc00634ac32228e5b8e4d0624eda11 Mon Sep 17 00:00:00 2001 From: CZT <czt18638530771@163.com> Date: 星期三, 30 八月 2023 11:10:51 +0800 Subject: [PATCH] 调整Modbus配置-解决轴流风机与轴流窗不在同一个分机配置的问题 --- igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java | 5 +++++ igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java | 13 +++++++++++-- igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteGasServiceImpl.java | 4 ++-- igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbus.view.xml | 26 +++++++++++++++++++------- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbus.view.xml b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbus.view.xml index 1c4353f..bba19cc 100644 --- a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbus.view.xml +++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbus.view.xml @@ -104,6 +104,15 @@ <Property name="valueProperty">name</Property> </Property> </PropertyDef> + <PropertyDef name="serId"> + <Property/> + <Property name="label">鎵�灞炲垎鏈�</Property> + <Property name="mapping"> + <Property name="mapValues">${dorado.getDataProvider("deviceSerPR#getAllSerCache").getResult()}</Property> + <Property name="keyProperty">id</Property> + <Property name="valueProperty">name</Property> + </Property> + </PropertyDef> </DataType> </Model> <View layout="padding:5;regionPadding:5"> @@ -170,12 +179,15 @@ <DataColumn name="deviceCode"> <Property name="property">deviceCode</Property> </DataColumn> + <DataColumn name="serId"> + <Property name="property">serId</Property> + </DataColumn> <ColumnGroup> <Property name="caption">寮�鎿嶄綔</Property> <DataColumn name="open"> <Property name="property">open</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="openFun"> <Property name="property">openFun</Property> @@ -189,7 +201,7 @@ <DataColumn name="close"> <Property name="property">close</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="closeFun"> <Property name="property">closeFun</Property> @@ -203,7 +215,7 @@ <DataColumn name="stop"> <Property name="property">stop</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="stopFun"> <Property name="property">stopFun</Property> @@ -217,7 +229,7 @@ <DataColumn name="openEnd"> <Property name="property">openEnd</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="openEndFun"> <Property name="property">openEndFun</Property> @@ -231,7 +243,7 @@ <DataColumn name="closeEnd"> <Property name="property">closeEnd</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="closeEndFun"> <Property name="property">closeEndFun</Property> @@ -245,7 +257,7 @@ <DataColumn name="openError"> <Property name="property">openError</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="openErrorFun"> <Property name="property">openErrorFun</Property> @@ -259,7 +271,7 @@ <DataColumn name="closeError"> <Property name="property">closeError</Property> <Property name="caption">鍦板潃</Property> - <Property name="width">100</Property> + <Property name="width">80</Property> </DataColumn> <DataColumn name="closeErrorFun"> <Property name="property">closeErrorFun</Property> diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java b/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java index ae17d8d..654ac0f 100644 --- a/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java +++ b/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java @@ -89,6 +89,11 @@ @PropertyDef(label = "鍔熻兘鍙�") private String closeErrorFun = "99"; + //杞存祦椋庢満鍜岃酱娴佺獥鍙兘涓嶅湪涓�涓垎鏈轰笂锛孖P涓嶅悓 + @Column(name = "SER_ID_", length = 10) + @PropertyDef(label = "鎵�灞炲垎鏈�") + private String serId; + @Transient private List<GasModbus> listGas; diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java index 6616ee3..b6c25d7 100644 --- a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java +++ b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java @@ -1,6 +1,7 @@ package com.ld.igds.protocol.modbus.command; import com.ld.igds.common.CoreDeviceService; +import com.ld.igds.common.CoreSerService; import com.ld.igds.constant.Constant; import com.ld.igds.constant.DeviceStatus; import com.ld.igds.io.RemoteControlService; @@ -14,6 +15,7 @@ import com.ld.igds.modbus.service.HModbusService; import com.ld.igds.models.Device; import com.ld.igds.models.DeviceModbus; +import com.ld.igds.models.DeviceSer; import com.ld.igds.protocol.modbus.ModbusUtil2; import com.ld.igds.protocol.modbus.ServerUtil; import com.ld.igds.protocol.modbus.data.ModbusTcp; @@ -43,6 +45,8 @@ private HModbusService deviceModbusService; @Resource private AnalysisService analysisService; + @Resource + private CoreSerService coreSerService; @Override @@ -114,7 +118,12 @@ modbusTcpLink.setBizCode(exeDevice.getLink()); modbusTcpLink.setSerId(request.getSerId()); modbusTcpLink.setCompanyId(request.getCompanyId()); - + if(StringUtils.isNotEmpty(deviceModbus.getSerId())){ + //鑻odbus璁惧閰嶇疆鍒嗘満锛屽垯浣跨敤鎵�閰嶇疆鍒嗘満鐨処P銆佺鍙� + DeviceSer deviceSer = coreSerService.getCacheSer(request.getCompanyId(), deviceModbus.getSerId()); + modbusTcpLink.setIp(deviceSer.getIp()); + modbusTcpLink.setPort(deviceSer.getPort()); + } //濡傛灉鏄紑椋庢満 if (DeviceStatus.F_OPEN.getCode().equals(exeDevice.getTargetStatus())) { @@ -163,7 +172,7 @@ Thread.sleep(300); //鍦ㄥ叧绐楁埛 - temp = modbusTcp.getDeviceModbus().getOpen(); + temp = modbusTcp.getDeviceModbus().getClose(); modbusTcp.setAddrExe(ServerUtil.getAddrExe(temp)); doWriteExe(modbusTcp, DeviceStatus.CLOSE.getCode()); diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteGasServiceImpl.java b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteGasServiceImpl.java index 2516fe1..a3c690c 100644 --- a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteGasServiceImpl.java +++ b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteGasServiceImpl.java @@ -75,7 +75,7 @@ boolean exeResult = ModbusUtil2.writeCoilStatus(modbusTcp.getIp(), modbusTcp.getPort(), modbusTcp.getAddrExe(), true); if (exeResult) { - + ModbusUtil2.writeCoilStatus(modbusTcp.getIp(), modbusTcp.getPort(), modbusTcp.getAddrExe(), false); addRun(request); //璋冪敤寮傛鑾峰彇缁撴灉 progressGasResult(request, modbusTcp); @@ -130,7 +130,7 @@ } //鏍规嵁閫氶亾鏁伴噺绾跨▼绛夊緟锛屾瘡涓�氶亾绛夊緟60绉� - Thread.sleep(list.size() * 60 * 1000); + Thread.sleep(list.size() * 50 * 1000); log.debug("--------------绛夊緟鏃堕棿瀹屾垚锛屽紑濮嬭幏鍙栨娴嬬粨鏋�-------------{}", modbusTcp.getBizCode()); boolean isRun = isRun(request); -- Gitblit v1.9.3