Wl1k.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. 监测实体类====================================================================
  2. //万里一矿主扇 2024-07-11
  3. @Data
  4. public class FanMainWl1kVo extends RelationVo {
  5. @JsonProperty(value = "f1MainMotorOperation")
  6. private Boolean f1MainMotorOperation; //F1_主电机_运行
  7. @JsonProperty(value = "f2MainMotorOperation")
  8. private Boolean f2MainMotorOperation; //F2_主电机_运行
  9. }
  10. 控制实体类====================================================================
  11. //万里一矿主扇 2024-07-11
  12. @Data
  13. public class FanMainWl1kFrom{
  14. }
  15. 枚举=========================================================================
  16. //万里一矿主扇 2024-07-11
  17. public enum FanMainWl1kEnum {
  18. FAN_MAIN_WL1K_ENUM_F1MAINMOTOROPERATION("f1MainMotorOperation", "F1_主电机_运行", "M1085.0"),
  19. FAN_MAIN_WL1K_ENUM_F2MAINMOTOROPERATION("f2MainMotorOperation", "F2_主电机_运行", "M2085.0");
  20. private String name; //状态位/控制位
  21. private String message; //指令描述
  22. private String point;
  23. FanMainWl1kEnum(String name, String message,String point) {
  24. this.name = name;
  25. this.message = message;
  26. this.point = point;
  27. }
  28. public String getName() {
  29. return name;
  30. }
  31. public String getMessage() {
  32. return message;
  33. }
  34. public String getPoint(){return point;}
  35. }
  36. 业务实现类=====================================================================
  37. import com.ventanaly.tool.enums.PLCDevice2Enum;
  38. import com.ventanaly.tool.froms.FanMainFrom;
  39. import com.ventanaly.tool.page.FanMainPage;
  40. import com.ventanaly.tool.utils.Constants;
  41. import com.ventanaly.tool.page.DeviceRelationPage;
  42. import com.ventanaly.tool.page.SubStationPage;
  43. import com.ventanaly.tool.utils.SensorNet;
  44. import org.slf4j.Logger;
  45. import org.slf4j.LoggerFactory;
  46. import org.springframework.stereotype.Component;
  47. import java.util.Map;
  48. //万里一矿主扇 2024-07-11
  49. @Component
  50. public class FanMainWl1kFacility {
  51. private final Logger logger = LoggerFactory.getLogger(getClass());
  52. public static final String TYPE = "fan_main_wl1k";
  53. public static final String TYPE_NAME = "万里一矿主扇";
  54. private static boolean control = true;
  55. public FanMainWl1kVo fanMainWl1kStatus(DeviceRelationPage dr, Map<String, String> tableMeta, FanMainPage page) {
  56. FanMainWl1kVo vo = new FanMainWl1kVo();
  57. vo.setDeviceType(Constants.DEVICE_TYPE_FAN_MAIN);
  58. vo.setSmallType(TYPE);
  59. vo.setDeviceId(dr.getDevice_id());
  60. vo.setId(dr.getId());
  61. SubStationPage sp = dr.getSubStationPage();
  62. if (null == sp) {
  63. return vo;
  64. }
  65. SensorNet net = sp.getSensorNet();
  66. vo.setNetStatus(net.isLinkState() ? 1 : 0);
  67. if (1 == vo.getNetStatus()) {
  68. String address;
  69. String tName;
  70. vo.setUrl(net.getIp());
  71. tName = PLCDevice2Enum.FanMainWl1kEnum.FAN_MAIN_WL1K_ENUM_F1MAINMOTOROPERATION.getName();
  72. address = tableMeta.get(tName);
  73. Boolean f1MainMotorOperation = net.getSensorBoolean(address);
  74. logger.debug("F1_主电机_运行-ID:{}-点位名称:{},address:{},Val:{}", dr.getId(), tName, address, f1MainMotorOperation);
  75. vo.setF1MainMotorOperation(f1MainMotorOperation);
  76. tName = PLCDevice2Enum.FanMainWl1kEnum.FAN_MAIN_WL1K_ENUM_F2MAINMOTOROPERATION.getName();
  77. address = tableMeta.get(tName);
  78. Boolean f2MainMotorOperation = net.getSensorBoolean(address);
  79. logger.debug("F2_主电机_运行-ID:{}-点位名称:{},address:{},Val:{}", dr.getId(), tName, address, f2MainMotorOperation);
  80. vo.setF2MainMotorOperation(f2MainMotorOperation);
  81. }
  82. dr.setObjVo(vo);
  83. return vo;
  84. }
  85. }
  86. 控制方法实现====================================================================
  87. //万里一矿主扇 2024-07-11
  88. public boolean controlFanMainWl1k(FanMainFrom from, Json json, FanMainPage fm, UserLogPage ulPage) {
  89. boolean r = false;
  90. ulPage.setDeviceType(4);
  91. DeviceRelationPage dr = SubStationStatic.DRMap.get(from.getId());
  92. if (null == dr) {
  93. throw new ServiceException("不存在的分站");
  94. }
  95. SubStationPage page = dr.getSubStationPage();
  96. try {
  97. RelationVo g = (RelationVo) dr.getObjVo();
  98. from.setStrInstallPos(g.getStrInstallPos());
  99. } catch (Exception e) {
  100. e.printStackTrace();
  101. }
  102. Map<String, String> tableMeta = SubStationStatic.tableMetas.get(dr.getPLC_table());
  103. json.setMsg("无任何操作");
  104. if (dr.getDevice_id() != fm.getNFanID()) {
  105. throw new ServiceException("输入密码不正确");
  106. }
  107. SensorNet net = page.getSensorNet();
  108. if (!dr.getIsFake()) {
  109. if (!net.getState()) {
  110. json.setMsg("无任何操作");
  111. throw new ServiceException("无法与设备建立链接");
  112. }
  113. }
  114. return r;
  115. }
  116. 监测方法片段====================================================================
  117. //万里一矿主扇 2024-07-11
  118. case FanMainWl1kFacility.TYPE:
  119. vo = fanMainWl1kFacility.status(dr,tableMeta,page);
  120. break;
  121. 点表配置json====================================================================
  122. {"f1MainMotorOperation":"M1085.0","f2MainMotorOperation":"M2085.0"}
  123. 点位解释json====================================================================
  124. {
  125. "f1MainMotorOperation":"F1_主电机_运行",
  126. "f2MainMotorOperation":"F2_主电机_运行"
  127. }
  128. 控制请求表格====================================================================
  129. |参数名|必选|类型|说明|
  130. |:---- |:---|:----- |----- |