diff --git a/zfipc-server/zfipc-admin/src/main/resources/application-druid.yml b/zfipc-server/zfipc-admin/src/main/resources/application-druid.yml index 8924ebc..a9d8d9e 100644 --- a/zfipc-server/zfipc-admin/src/main/resources/application-druid.yml +++ b/zfipc-server/zfipc-admin/src/main/resources/application-druid.yml @@ -9,7 +9,7 @@ spring: # url: jdbc:mysql://117.73.8.43:3306/phm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # username: phm # password: Y123456a - url: jdbc:mysql://117.73.2.117:3306/zfipc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://localhost:3306/zfipc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: zfipc password: Y123456a # 从库数据源 diff --git a/zfipc-server/zfipc-admin/src/main/resources/application.yml b/zfipc-server/zfipc-admin/src/main/resources/application.yml index 0815a33..ce594b4 100644 --- a/zfipc-server/zfipc-admin/src/main/resources/application.yml +++ b/zfipc-server/zfipc-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ zfipc: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/inspur/uploadPath,Linux配置 /home/inspur/uploadPath) - profile: D:/inspur/uploadPath + profile: E:/inspur/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 @@ -144,10 +144,10 @@ datasyn: keepAlive: 20 Qos: 1 modbus: - host: 192.168.1.88 + host: 10.124.7.12 port: 502 influxdb: - url: http://117.73.2.117:8086 + url: http://localhost:8086 userName: zfipc password: Y123456a database: zfipc diff --git a/zfipc-server/zfipc-admin/src/main/resources/logback.xml b/zfipc-server/zfipc-admin/src/main/resources/logback.xml index 0f89517..76bf9d7 100644 --- a/zfipc-server/zfipc-admin/src/main/resources/logback.xml +++ b/zfipc-server/zfipc-admin/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java index b0253d2..c9b8093 100644 --- a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java +++ b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java @@ -64,17 +64,17 @@ public class IPCDataSyncTask implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { if ("client".equals(model)) { -// IpParameters params = new IpParameters(); -// params.setHost(host); -// params.setPort(Integer.parseInt(port)); -// ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议 -// master.init(); + IpParameters params = new IpParameters(); + params.setHost(host); + params.setPort(Integer.parseInt(port)); + ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议 + master.init(); final Timer timer1 = new Timer(); timer1.schedule(new TimerTask() { @Override public void run() { - threadPoolTaskExecutor.execute(new IpcDataProcess(null)); + threadPoolTaskExecutor.execute(new IpcDataProcess(master)); } }, 1000, 1000); // diff --git a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java index cb25988..7e3ed3c 100644 --- a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java +++ b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java @@ -14,8 +14,13 @@ import com.inspur.industrial.service.IIpcSysStatusService; import com.inspur.industrial.utils.Constant; import com.inspur.industrial.utils.IpcUtil; import com.inspur.system.service.influx.InfluxDBService; +import com.serotonin.modbus4j.BatchRead; import com.serotonin.modbus4j.BatchResults; import com.serotonin.modbus4j.ModbusMaster; +import com.serotonin.modbus4j.code.DataType; +import com.serotonin.modbus4j.locator.BaseLocator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -33,6 +38,8 @@ import java.util.stream.Collectors; */ public class IpcDataProcess implements Runnable { + private static final Logger logger = LoggerFactory.getLogger(IPCDataSyncThread.class); + private ModbusMaster master; public IpcDataProcess(ModbusMaster master) { @@ -56,15 +63,186 @@ public class IpcDataProcess implements Runnable { // 1.modbus接收数据 try { -// BatchRead batch = new BatchRead(); + BatchRead batch = new BatchRead(); // -// batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油压力,float -// batch.addLocator(1, BaseLocator.holdingRegister(1, 2, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油油液温度,float -// batch.addLocator(2, BaseLocator.holdingRegister(1, 4, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 回油油液温度,float -// batch.addLocator(3, BaseLocator.holdingRegister(1, 6, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油水监测,float -// batch.addLocator(4, BaseLocator.holdingRegister(1, 8, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油液粘度,float -// batch.addLocator(5, BaseLocator.holdingRegister(1, 10, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 力传感器,float -// batch.addLocator(6, BaseLocator.holdingRegister(1, 12, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 速度传感器,float + batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油压力,float + batch.addLocator(1, BaseLocator.holdingRegister(1, 20, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油油液温度,float + batch.addLocator(2, BaseLocator.holdingRegister(1, 22, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 回油油液温度,float + batch.addLocator(3, BaseLocator.holdingRegister(1, 24, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油水监测,float + batch.addLocator(4, BaseLocator.holdingRegister(1, 26, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油液粘度,float + batch.addLocator(5, BaseLocator.holdingRegister(1, 28, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 力传感器,float + + + try{ + batch.addLocator(6, BaseLocator.holdingRegister(1, 300, DataType.BINARY));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(7, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(8, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(9, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(10, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(11, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(12, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(13, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(14, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(15, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(16, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(17, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(18, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(19, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED_INVERTED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(20, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(21, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(22, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(23, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(24, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(25, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(26, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_BCD));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(27, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(28, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(29, BaseLocator.holdingRegister(1, 300, DataType.CHAR));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(30, BaseLocator.holdingRegister(1, 300, DataType.VARCHAR));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(31, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(32, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(33, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(34, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(35, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(36, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K_SWAPPED));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(37, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_LOWER));// 速度传感器,float + }catch (Exception e){ + + } + try{ + batch.addLocator(38, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_UPPER));// 速度传感器,float + }catch (Exception e){ + + } + + + + + // batch.addLocator(7, BaseLocator.holdingRegister(1, 14, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X1轴位置传感器一,float // batch.addLocator(8, BaseLocator.holdingRegister(1, 16, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X2轴位置传感器二,float // batch.addLocator(9, BaseLocator.holdingRegister(1, 18, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Y1轴位置传感器三,float @@ -75,29 +253,73 @@ public class IpcDataProcess implements Runnable { // batch.addLocator(14, BaseLocator.holdingRegister(1, 27, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度6um,int // batch.addLocator(15, BaseLocator.holdingRegister(1, 28, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度14um,int // batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int -// batch.setContiguousRequests(false); -// BatchResults results = master.send(batch); + batch.setContiguousRequests(false); + BatchResults results = master.send(batch); - String topScollerMeasurement = "zfipc_industrial_monitor_data2"; - String bottomScollerMeasurement = "zfipc_industrial_monitor_data3"; - List equipList = equipInfoService.selectIpcEquipInfoList(null); - if (equipList != null && equipList.size() > 0) { - String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId(); - String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId(); - String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId(); - saveRunningStatus("1"); - bottomCylinderDataProcess(null, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService); - scollerDataProcess(null, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); - scollerDataProcess(null, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); + + + + logger.info("#######################0:"+results.getValue(0)); + logger.info("#######################1:"+results.getValue(1)); + logger.info("#######################2:"+results.getValue(2)); + logger.info("#######################3:"+results.getValue(3)); + logger.info("#######################4:"+results.getValue(4)); + logger.info("#######################5:"+results.getValue(5)); + logger.info("#######################6:"+results.getValue(6)); + logger.info("#######################6:"+results.getValue(7)); + logger.info("#######################6:"+results.getValue(8)); + logger.info("#######################6:"+results.getValue(9)); + logger.info("#######################6:"+results.getValue(10)); + logger.info("#######################6:"+results.getValue(11)); + logger.info("#######################6:"+results.getValue(12)); + logger.info("#######################6:"+results.getValue(13)); + logger.info("#######################6:"+results.getValue(14)); + logger.info("#######################6:"+results.getValue(15)); + logger.info("#######################6:"+results.getValue(16)); + logger.info("#######################6:"+results.getValue(17)); + logger.info("#######################6:"+results.getValue(18)); + logger.info("#######################19:"+results.getValue(19)); + logger.info("#######################6:"+results.getValue(20)); + logger.info("#######################6:"+results.getValue(21)); + logger.info("#######################6:"+results.getValue(22)); + logger.info("#######################6:"+results.getValue(23)); + logger.info("#######################6:"+results.getValue(24)); + logger.info("#######################6:"+results.getValue(25)); + logger.info("#######################6:"+results.getValue(26)); + logger.info("#######################6:"+results.getValue(27)); + logger.info("#######################6:"+results.getValue(28)); + logger.info("#######################6:"+results.getValue(29)); + logger.info("#######################6:"+results.getValue(30)); + logger.info("#######################6:"+results.getValue(31)); + logger.info("#######################6:"+results.getValue(32)); + logger.info("#######################6:"+results.getValue(33)); + logger.info("#######################6:"+results.getValue(34)); + logger.info("#######################6:"+results.getValue(35)); + logger.info("#######################6:"+results.getValue(36)); + logger.info("#######################6:"+results.getValue(37)); + logger.info("#######################38:"+results.getValue(38)); + +// String topScollerMeasurement = "zfipc_industrial_monitor_data2"; +// String bottomScollerMeasurement = "zfipc_industrial_monitor_data3"; +// List equipList = equipInfoService.selectIpcEquipInfoList(null); +// if (equipList != null && equipList.size() > 0) { +// String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId(); +// String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId(); +// String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId(); +// saveRunningStatus("1"); +// bottomCylinderDataProcess(null, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService); +// scollerDataProcess(null, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); +// scollerDataProcess(null, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); //TODO 需要统一处理系统状态,停机运维、待机、试运行、正常生产 //TODO 状态切换时候需要存储状态切换时间 //TODO 更新系统数据,停机运维、待机、试运行、正常生产时间 - } +// } } catch(Exception e){ + logger.error(e.getMessage()); e.printStackTrace(); }