取数测试

This commit is contained in:
liuyusheng 2024-05-29 09:10:30 +08:00
parent 47286e93c3
commit a2fddcc2d5
5 changed files with 255 additions and 33 deletions

View File

@ -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 # url: jdbc:mysql://117.73.8.43:3306/phm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: phm # username: phm
# password: Y123456a # 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 username: zfipc
password: Y123456a password: Y123456a
# 从库数据源 # 从库数据源

View File

@ -9,7 +9,7 @@ zfipc:
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/inspur/uploadPathLinux配置 /home/inspur/uploadPath # 文件路径 示例( Windows配置D:/inspur/uploadPathLinux配置 /home/inspur/uploadPath
profile: D:/inspur/uploadPath profile: E:/inspur/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证
@ -144,10 +144,10 @@ datasyn:
keepAlive: 20 keepAlive: 20
Qos: 1 Qos: 1
modbus: modbus:
host: 192.168.1.88 host: 10.124.7.12
port: 502 port: 502
influxdb: influxdb:
url: http://117.73.2.117:8086 url: http://localhost:8086
userName: zfipc userName: zfipc
password: Y123456a password: Y123456a
database: zfipc database: zfipc

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="D:/home/zfipc/logs" /> <property name="log.path" value="E:/home/zfipc/logs" />
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

View File

@ -64,17 +64,17 @@ public class IPCDataSyncTask implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
if ("client".equals(model)) { if ("client".equals(model)) {
// IpParameters params = new IpParameters(); IpParameters params = new IpParameters();
// params.setHost(host); params.setHost(host);
// params.setPort(Integer.parseInt(port)); params.setPort(Integer.parseInt(port));
// ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议 ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议
// master.init(); master.init();
final Timer timer1 = new Timer(); final Timer timer1 = new Timer();
timer1.schedule(new TimerTask() { timer1.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
threadPoolTaskExecutor.execute(new IpcDataProcess(null)); threadPoolTaskExecutor.execute(new IpcDataProcess(master));
} }
}, 1000, 1000); }, 1000, 1000);
// //

View File

@ -14,8 +14,13 @@ import com.inspur.industrial.service.IIpcSysStatusService;
import com.inspur.industrial.utils.Constant; import com.inspur.industrial.utils.Constant;
import com.inspur.industrial.utils.IpcUtil; import com.inspur.industrial.utils.IpcUtil;
import com.inspur.system.service.influx.InfluxDBService; import com.inspur.system.service.influx.InfluxDBService;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults; import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.ModbusMaster; 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.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -33,6 +38,8 @@ import java.util.stream.Collectors;
*/ */
public class IpcDataProcess implements Runnable { public class IpcDataProcess implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(IPCDataSyncThread.class);
private ModbusMaster master; private ModbusMaster master;
public IpcDataProcess(ModbusMaster master) { public IpcDataProcess(ModbusMaster master) {
@ -56,15 +63,186 @@ public class IpcDataProcess implements Runnable {
// 1.modbus接收数据 // 1.modbus接收数据
try { try {
// BatchRead<Integer> batch = new BatchRead<Integer>(); BatchRead<Integer> batch = new BatchRead<Integer>();
// //
// batch.addLocator(0, BaseLocator.holdingRegister(1, 0, 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, 2, 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, 4, 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, 6, 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, 8, 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, 10, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 力传感器,float batch.addLocator(5, BaseLocator.holdingRegister(1, 28, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 力传感器,float
// batch.addLocator(6, BaseLocator.holdingRegister(1, 12, 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(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(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 // 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(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(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.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
// batch.setContiguousRequests(false); batch.setContiguousRequests(false);
// BatchResults<Integer> results = master.send(batch); BatchResults<Integer> results = master.send(batch);
String topScollerMeasurement = "zfipc_industrial_monitor_data2";
String bottomScollerMeasurement = "zfipc_industrial_monitor_data3";
List<IpcEquipInfo> equipList = equipInfoService.selectIpcEquipInfoList(null);
if (equipList != null && equipList.size() > 0) { logger.info("#######################0:"+results.getValue(0));
String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId(); logger.info("#######################1:"+results.getValue(1));
String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId(); logger.info("#######################2:"+results.getValue(2));
String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId(); logger.info("#######################3:"+results.getValue(3));
saveRunningStatus("1"); logger.info("#######################4:"+results.getValue(4));
bottomCylinderDataProcess(null, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService); logger.info("#######################5:"+results.getValue(5));
scollerDataProcess(null, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); logger.info("#######################6:"+results.getValue(6));
scollerDataProcess(null, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); 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<IpcEquipInfo> 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 状态切换时候需要存储状态切换时间 //TODO 状态切换时候需要存储状态切换时间
//TODO 更新系统数据停机运维待机试运行正常生产时间 //TODO 更新系统数据停机运维待机试运行正常生产时间
} // }
} }
catch(Exception e){ catch(Exception e){
logger.error(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }