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 7e3ed3c..cf97546 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 @@ -65,179 +65,187 @@ public class IpcDataProcess implements Runnable { try { BatchRead batch = new BatchRead(); // - 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(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));// 4um油液颗粒度,float + for(int id=0,addr=0; id <= 100; id++,addr+=2){ + batch.addLocator(id, BaseLocator.holdingRegister(1, addr, DataType.FOUR_BYTE_FLOAT_SWAPPED)); } + //状态值 + batch.addLocator(101, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED)); + batch.addLocator(102, BaseLocator.holdingRegister(1, 301, DataType.TWO_BYTE_INT_UNSIGNED)); + batch.addLocator(103, BaseLocator.holdingRegister(1, 302, DataType.TWO_BYTE_INT_UNSIGNED)); +// +// 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){ +// +// } @@ -255,68 +263,69 @@ public class IpcDataProcess implements Runnable { // batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int batch.setContiguousRequests(false); BatchResults results = master.send(batch); +// for(int m=0; m<=103; m++){ +// logger.info("#######################"+m+":"+results.getValue(m)); +// } +// 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)); - - 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); + 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(results, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService); + topScollerDataProcess(results, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); + bottomScollerDataProcess(results, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); //TODO 需要统一处理系统状态,停机运维、待机、试运行、正常生产 //TODO 状态切换时候需要存储状态切换时间 //TODO 更新系统数据,停机运维、待机、试运行、正常生产时间 -// } + } } catch(Exception e){ logger.error(e.getMessage()); @@ -330,7 +339,7 @@ public class IpcDataProcess implements Runnable { */ private void bottomCylinderDataProcess(BatchResults results, String equipId, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { - String measurement = "zfipc_industrial_monitor_data1"; + String measurement = "zfipc_industrial_monitor_data1"; List alarmRecordList = new ArrayList<>(); @@ -340,73 +349,75 @@ public class IpcDataProcess implements Runnable { //TODO 停机运维状态数据不储存 tags.put("status", "1");//正常运行 0:停机 1:正常运行 2:待机 3:试运行 - // 系统电流 - fields.put("sys_cur", (float) 0 + Math.random()); + fields.put("sys_cur", results.getValue(0)); // 系统流量 - fields.put("sys_flw", (float) 0 + Math.random()); + fields.put("sys_flw", results.getValue(1)); // 系统压力 - fields.put("sys_press", (float) 0 + Math.random()); + fields.put("sys_press", results.getValue(15)); // 系统液位 - fields.put("sys_level", (float) 0 + Math.random()); + fields.put("sys_level", results.getValue(24)); //液位最小和最大值通过报警参数设置获取 IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 //正式需要放开 - fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); - fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); + fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue()); + fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue()); // 系统温度 - fields.put("sys_temp", (float) 0 + Math.random()); + fields.put("sys_temp", results.getValue(25)); // 油液颗粒度 - fields.put("gran4", (float) 0 + Math.random()); - fields.put("gran6", (float) 0 + Math.random()); - fields.put("gran14", (float) 0 + Math.random()); - fields.put("gran21", (float) 0 + Math.random()); + fields.put("gran4", results.getValue(6)); + fields.put("gran6", results.getValue(7)); + fields.put("gran14", results.getValue(8)); + fields.put("gran21", results.getValue(9)); // 油水检测 - fields.put("oil_water", (float) 0 + Math.random()); + fields.put("oil_water", results.getValue(10)); // 油品粘度 - fields.put("visc", (float) 0 + Math.random()); + fields.put("visc", results.getValue(11)); + fields.put("visc_den", results.getValue(12));//密度 + fields.put("visc_dc", results.getValue(13));//介电常数 + fields.put("visc_temp", results.getValue(14));//温度 // 操作侧软辊流量 - fields.put("opr_soft_flw", (float) 0 + Math.random()); + fields.put("opr_soft_flw", results.getValue(4)); // 操作侧热辊流量 - fields.put("opr_hot_flw", (float) 0 + Math.random()); + fields.put("opr_hot_flw", results.getValue(5)); // 传动侧软辊流量 - fields.put("driven_soft_flw", (float) 0 + Math.random()); + fields.put("driven_soft_flw", results.getValue(2)); // 传动侧热辊流量 - fields.put("driven_hot_flw", (float) 0 + Math.random()); + fields.put("driven_hot_flw", results.getValue(3)); //操作侧底缸比例换向阀 - fields.put("opr_servo", (float) 0 + Math.random()); + fields.put("opr_servo", results.getValue(16)); //传动侧比例换向阀 - fields.put("driven_servo", (float) 0 + Math.random()); + fields.put("driven_servo", results.getValue(17)); //操作侧底缸压力 - fields.put("opr_bottom_press", (float) 0 + Math.random()); + fields.put("opr_bottom_press", results.getValue(18)); //传动侧底缸压力 - fields.put("driven_bottom_press", (float) 0 + Math.random()); + fields.put("driven_bottom_press", results.getValue(19)); //操作侧底缸设定压力 - fields.put("opr_bottom_set_press", (float) 0 + Math.random()); + fields.put("opr_bottom_set_press", (float)0.0);//TODO //传动侧底缸设定压力 - fields.put("driven_bottom_set_press", (float) 0 + Math.random()); + fields.put("driven_bottom_set_press", (float)0.0);//TODO //操作侧软辊压力 - fields.put("opr_soft_real_press", (float) 0 + Math.random());//实际压力 - fields.put("opr_soft_bond_press", (float) 0 + Math.random());//合辊压力 - fields.put("opr_soft_act_press", (float) 0 + Math.random());//加压压力 + fields.put("opr_soft_real_press", results.getValue(20));//实际压力 + fields.put("opr_soft_bond_press", (float)0.0);//TODO 合辊压力 + fields.put("opr_soft_act_press", (float)0.0);//TODO 加压压力 //操作侧热辊压力 - fields.put("opr_hot_real_press", (float) 0 + Math.random()); - fields.put("opr_hot_bond_press", (float) 0 + Math.random()); - fields.put("opr_hot_act_press", (float) 0 + Math.random()); + fields.put("opr_hot_real_press", results.getValue(21)); + fields.put("opr_hot_bond_press", (float)0.0);//TODO + fields.put("opr_hot_act_press", (float)0.0);//TODO //传动侧软辊压力 - fields.put("driven_soft_real_press", (float) 0 + Math.random());//实际 - fields.put("driven_soft_bond_press", (float) 0 + Math.random());//合辊 - fields.put("driven_soft_act_press", (float) 0 + Math.random());//加压 + fields.put("driven_soft_real_press", results.getValue(22));//实际 + fields.put("driven_soft_bond_press", (float)0.0);//TODO 合辊 + fields.put("driven_soft_act_press", (float)0.0);//TODO 加压 //传动侧热辊压力 - fields.put("driven_hot_real_press", (float) 0 + Math.random()); - fields.put("driven_hot_bond_press", (float) 0 + Math.random()); - fields.put("driven_hot_act_press", (float) 0 + Math.random()); + fields.put("driven_hot_real_press", results.getValue(23)); + fields.put("driven_hot_bond_press", (float) 0.0);//TODO + fields.put("driven_hot_act_press", (float) 0.0);//TODO //操作侧底缸位移 - fields.put("opr_bottom_dis", (float) 0 + Math.random()); + fields.put("opr_bottom_dis", results.getValue(26)); //传动侧底缸位移 - fields.put("driven_bottom_dis", (float) 0 + Math.random()); + fields.put("driven_bottom_dis", results.getValue(27)); //报警处理 List rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 @@ -420,7 +431,7 @@ public class IpcDataProcess implements Runnable { /** * 中高顶辊 */ - private void scollerDataProcess(BatchResults results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { + private void topScollerDataProcess(BatchResults results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { Map tags = new TreeMap(); tags.put("equ_id", equipId); Map fields = new TreeMap(); @@ -430,79 +441,181 @@ public class IpcDataProcess implements Runnable { tags.put("status", "1");//正常运行 0:停机 1:正常运行 2:待机 3:试运行 // 系统电流 - fields.put("sys_cur", (float) 0 + Math.random()); + fields.put("sys_cur", results.getValue(32)); // 系统流量 - fields.put("sys_flw", (float) 0 + Math.random()); + fields.put("sys_flw", results.getValue(33)); // 系统压力 - fields.put("sys_press", (float) 0 + Math.random()); + fields.put("sys_press", results.getValue(42)); // 系统液位 - fields.put("sys_level", (float) 0 + Math.random()); + fields.put("sys_level", results.getValue(40)); // fields.put("ywcsz",0.5); // fields.put("ywmin",0.3); // fields.put("ywmax",1); //液位最小和最大值通过报警参数设置获取 IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 //正式需要放开 - fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); - fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); + fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue()); + fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue()); // 系统温度 - fields.put("sys_temp", (float) 0 + Math.random()); + fields.put("sys_temp", results.getValue(41)); // 油液颗粒度 - fields.put("gran4", (float) 0 + Math.random()); - fields.put("gran6", (float) 0 + Math.random()); - fields.put("gran14", (float) 0 + Math.random()); - fields.put("gran21", (float) 0 + Math.random()); + fields.put("gran4", results.getValue(28)); + fields.put("gran6", results.getValue(29)); + fields.put("gran14", results.getValue(30)); + fields.put("gran21", results.getValue(31)); //产线车速 - fields.put("line_speed", (float) 0 + Math.random()); + fields.put("line_speed", results.getValue(39)); // 油水检测 - fields.put("oil_water", (float) 0 + Math.random()); + fields.put("oil_water", results.getValue(34)); // 油品粘度 - fields.put("visc", (float) 0 + Math.random()); + fields.put("visc", results.getValue(35)); + fields.put("visc_den", results.getValue(36));//密度 + fields.put("visc_dc", results.getValue(37));//介电常数 + fields.put("visc_temp", results.getValue(38));//温度 // 一压区比例减压阀 - fields.put("press1", (float) 0 + Math.random()); + fields.put("press1", results.getValue(54)); // 二压区比例减压阀 - fields.put("press2", (float) 0 + Math.random()); + fields.put("press2", results.getValue(55)); // 三压区比例减压阀 - fields.put("press3", (float) 0 + Math.random()); + fields.put("press3", results.getValue(56)); // 四压区比例减压阀 - fields.put("press4", (float) 0 + Math.random()); + fields.put("press4", results.getValue(57)); // 五压区比例减乐阀 - fields.put("press5", (float) 0 + Math.random()); + fields.put("press5", results.getValue(58)); // 六压区比例减压阀 - fields.put("press6", (float) 0 + Math.random()); + fields.put("press6", results.getValue(59)); // 七压区比例减压阀 - fields.put("press7", (float) 0 + Math.random()); + fields.put("press7", results.getValue(60)); // 八压区比例减压阀 - fields.put("press8", (float) 0 + Math.random()); + fields.put("press8", results.getValue(61)); // 九压区比例减压阀 - fields.put("press9", (float) 0 + Math.random()); + fields.put("press9", results.getValue(62)); // 十压区比例减乐阀 - fields.put("press10", (float) 0 + Math.random()); + fields.put("press10", results.getValue(63)); // 十一压区比例减压阀 - fields.put("press11", (float) 0 + Math.random()); + fields.put("press11", results.getValue(64)); // 一压区流量 - fields.put("flw1", (float) 0 + Math.random()); + fields.put("flw1", results.getValue(43)); // 二压区流量 - fields.put("flw2", (float) 0 + Math.random()); + fields.put("flw2", results.getValue(44)); // 三压区流量 - fields.put("flw3", (float) 0 + Math.random()); + fields.put("flw3", results.getValue(45)); // 四压区流量 - fields.put("flw4", (float) 0 + Math.random()); + fields.put("flw4", results.getValue(46)); // 五压区流量 - fields.put("flw5", (float) 0 + Math.random()); + fields.put("flw5", results.getValue(47)); // 六压区流量 - fields.put("flw6", (float) 0 + Math.random()); + fields.put("flw6", results.getValue(48)); // 七压区流量 - fields.put("flw7", (float) 0 + Math.random()); + fields.put("flw7", results.getValue(49)); // 八压区流量 - fields.put("flw8", (float) 0 + Math.random()); + fields.put("flw8", results.getValue(50)); // 九压区流量 - fields.put("flw9", (float) 0 + Math.random()); + fields.put("flw9", results.getValue(51)); // 十压区流量 - fields.put("flw10", (float) 0 + Math.random()); + fields.put("flw10", results.getValue(52)); // 十一压区流量 - fields.put("flw11", (float) 0 + Math.random()); + fields.put("flw11", results.getValue(53)); + + //报警处理 + List rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); + alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 + if (!alarmRecordList.isEmpty()) {//运行需放开 + // alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); + } + i.insert(measurement, tags, fields); + } + + /** + * 中高顶辊 + */ + private void bottomScollerDataProcess(BatchResults results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { + Map tags = new TreeMap(); + tags.put("equ_id", equipId); + Map fields = new TreeMap(); + + List alarmRecordList = new ArrayList<>(); + //TODO 停机运维状态数据不储存 + + tags.put("status", "1");//正常运行 0:停机 1:正常运行 2:待机 3:试运行 + // 系统电流 + fields.put("sys_cur", results.getValue(69)); + // 系统流量 + fields.put("sys_flw", results.getValue(70)); + // 系统压力 + fields.put("sys_press", results.getValue(78)); + // 系统液位 + fields.put("sys_level", results.getValue(76)); +// fields.put("ywcsz",0.5); +// fields.put("ywmin",0.3); +// fields.put("ywmax",1); + //液位最小和最大值通过报警参数设置获取 + IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 + //正式需要放开 + fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue()); + fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue()); + + // 系统温度 + fields.put("sys_temp", results.getValue(77)); + // 油液颗粒度 + fields.put("gran4", results.getValue(65)); + fields.put("gran6", results.getValue(66)); + fields.put("gran14", results.getValue(67)); + fields.put("gran21", results.getValue(68)); + //产线车速 + fields.put("line_speed", results.getValue(39)); + // 油水检测 + fields.put("oil_water", results.getValue(71)); + // 油品粘度 + fields.put("visc", results.getValue(72)); + fields.put("visc_den", results.getValue(73));//密度 + fields.put("visc_dc", results.getValue(74));//介电常数 + fields.put("visc_temp", results.getValue(75));//温度 + // 一压区比例减压阀 + fields.put("press1", results.getValue(90)); + // 二压区比例减压阀 + fields.put("press2", results.getValue(91)); + // 三压区比例减压阀 + fields.put("press3", results.getValue(92)); + // 四压区比例减压阀 + fields.put("press4", results.getValue(93)); + // 五压区比例减乐阀 + fields.put("press5", results.getValue(94)); + // 六压区比例减压阀 + fields.put("press6", results.getValue(95)); + // 七压区比例减压阀 + fields.put("press7", results.getValue(96)); + // 八压区比例减压阀 + fields.put("press8", results.getValue(97)); + // 九压区比例减压阀 + fields.put("press9", results.getValue(98)); + // 十压区比例减乐阀 + fields.put("press10", results.getValue(99)); + // 十一压区比例减压阀 + fields.put("press11", results.getValue(100)); + // 一压区流量 + fields.put("flw1", results.getValue(79)); + // 二压区流量 + fields.put("flw2", results.getValue(80)); + // 三压区流量 + fields.put("flw3", results.getValue(81)); + // 四压区流量 + fields.put("flw4", results.getValue(82)); + // 五压区流量 + fields.put("flw5", results.getValue(83)); + // 六压区流量 + fields.put("flw6", results.getValue(84)); + // 七压区流量 + fields.put("flw7", results.getValue(85)); + // 八压区流量 + fields.put("flw8", results.getValue(86)); + // 九压区流量 + fields.put("flw9", results.getValue(87)); + // 十压区流量 + fields.put("flw10", results.getValue(88)); + // 十一压区流量 + fields.put("flw11", results.getValue(89)); //报警处理 List rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java index afc1b25..8376422 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java @@ -134,7 +134,7 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService int num = ipcAlarmRulesMapper.updateIpcAlarmRules(ipcAlarmRules); if (num > 0){ List rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); - redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(),rules); + redisCache.setCacheList(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(),rules); } return num; } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java index 9dccc25..fc15349 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java @@ -79,7 +79,7 @@ public class IpcUtil { ipcAlarmRecord.setEquipId(rule.getEquipId()); ipcAlarmRecord.setSensorId(rule.getSensorId()); String name = rule.getAlarmNameKey(); - double value = (double) map.get(name); + float value = (float)map.get(name); ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf(value)); ipcAlarmRecord.setNameKey(name); ipcAlarmRecord.setContent(type == 0 ? "(开机监测)" + rule.getReferenceName() : rule.getReferenceName());