监测实体类==================================================================== //万里一矿主扇 2024-07-11 @Data public class FanMainWl1kVo extends RelationVo { @JsonProperty(value = "f1MainMotorOperation") private Boolean f1MainMotorOperation; //F1_主电机_运行 @JsonProperty(value = "f2MainMotorOperation") private Boolean f2MainMotorOperation; //F2_主电机_运行 } 控制实体类==================================================================== //万里一矿主扇 2024-07-11 @Data public class FanMainWl1kFrom{ } 枚举========================================================================= //万里一矿主扇 2024-07-11 public enum FanMainWl1kEnum { FAN_MAIN_WL1K_ENUM_F1MAINMOTOROPERATION("f1MainMotorOperation", "F1_主电机_运行", "M1085.0"), FAN_MAIN_WL1K_ENUM_F2MAINMOTOROPERATION("f2MainMotorOperation", "F2_主电机_运行", "M2085.0"); private String name; //状态位/控制位 private String message; //指令描述 private String point; FanMainWl1kEnum(String name, String message,String point) { this.name = name; this.message = message; this.point = point; } public String getName() { return name; } public String getMessage() { return message; } public String getPoint(){return point;} } 业务实现类===================================================================== import com.ventanaly.tool.enums.PLCDevice2Enum; import com.ventanaly.tool.froms.FanMainFrom; import com.ventanaly.tool.page.FanMainPage; import com.ventanaly.tool.utils.Constants; import com.ventanaly.tool.page.DeviceRelationPage; import com.ventanaly.tool.page.SubStationPage; import com.ventanaly.tool.utils.SensorNet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.util.Map; //万里一矿主扇 2024-07-11 @Component public class FanMainWl1kFacility { private final Logger logger = LoggerFactory.getLogger(getClass()); public static final String TYPE = "fan_main_wl1k"; public static final String TYPE_NAME = "万里一矿主扇"; private static boolean control = true; public FanMainWl1kVo fanMainWl1kStatus(DeviceRelationPage dr, Map tableMeta, FanMainPage page) { FanMainWl1kVo vo = new FanMainWl1kVo(); vo.setDeviceType(Constants.DEVICE_TYPE_FAN_MAIN); vo.setSmallType(TYPE); vo.setDeviceId(dr.getDevice_id()); vo.setId(dr.getId()); SubStationPage sp = dr.getSubStationPage(); if (null == sp) { return vo; } SensorNet net = sp.getSensorNet(); vo.setNetStatus(net.isLinkState() ? 1 : 0); if (1 == vo.getNetStatus()) { String address; String tName; vo.setUrl(net.getIp()); tName = PLCDevice2Enum.FanMainWl1kEnum.FAN_MAIN_WL1K_ENUM_F1MAINMOTOROPERATION.getName(); address = tableMeta.get(tName); Boolean f1MainMotorOperation = net.getSensorBoolean(address); logger.debug("F1_主电机_运行-ID:{}-点位名称:{},address:{},Val:{}", dr.getId(), tName, address, f1MainMotorOperation); vo.setF1MainMotorOperation(f1MainMotorOperation); tName = PLCDevice2Enum.FanMainWl1kEnum.FAN_MAIN_WL1K_ENUM_F2MAINMOTOROPERATION.getName(); address = tableMeta.get(tName); Boolean f2MainMotorOperation = net.getSensorBoolean(address); logger.debug("F2_主电机_运行-ID:{}-点位名称:{},address:{},Val:{}", dr.getId(), tName, address, f2MainMotorOperation); vo.setF2MainMotorOperation(f2MainMotorOperation); } dr.setObjVo(vo); return vo; } } 控制方法实现==================================================================== //万里一矿主扇 2024-07-11 public boolean controlFanMainWl1k(FanMainFrom from, Json json, FanMainPage fm, UserLogPage ulPage) { boolean r = false; ulPage.setDeviceType(4); DeviceRelationPage dr = SubStationStatic.DRMap.get(from.getId()); if (null == dr) { throw new ServiceException("不存在的分站"); } SubStationPage page = dr.getSubStationPage(); try { RelationVo g = (RelationVo) dr.getObjVo(); from.setStrInstallPos(g.getStrInstallPos()); } catch (Exception e) { e.printStackTrace(); } Map tableMeta = SubStationStatic.tableMetas.get(dr.getPLC_table()); json.setMsg("无任何操作"); if (dr.getDevice_id() != fm.getNFanID()) { throw new ServiceException("输入密码不正确"); } SensorNet net = page.getSensorNet(); if (!dr.getIsFake()) { if (!net.getState()) { json.setMsg("无任何操作"); throw new ServiceException("无法与设备建立链接"); } } return r; } 监测方法片段==================================================================== //万里一矿主扇 2024-07-11 case FanMainWl1kFacility.TYPE: vo = fanMainWl1kFacility.status(dr,tableMeta,page); break; 点表配置json==================================================================== {"f1MainMotorOperation":"M1085.0","f2MainMotorOperation":"M2085.0"} 点位解释json==================================================================== { "f1MainMotorOperation":"F1_主电机_运行", "f2MainMotorOperation":"F2_主电机_运行" } 控制请求表格==================================================================== |参数名|必选|类型|说明| |:---- |:---|:----- |----- |