package com.zy.common.utils; import com.core.common.SpringUtils; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.SlaveType; import com.zy.core.model.LiftSlave; import com.zy.core.model.command.NyLiftCommand; import com.zy.core.model.protocol.LiftStaProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.LiftThread; import javax.swing.*; /** * 牛眼提升机工具类 */ public class NyLiftUtils { /** * 获取提升机命令 */ public static NyLiftCommand getLiftCommand(Integer liftNo, Integer taskModel, Integer sourceSta, Integer targetSta, Integer taskNo) { NyLiftCommand command = new NyLiftCommand(); command.setLiftNo(liftNo.shortValue()); command.setTaskNo(taskNo.shortValue()); command.setTaskModel(taskModel.shortValue()); command.setSourceSta(sourceSta.shortValue()); command.setTargetSta(targetSta.shortValue()); return command; } /** * 获取提升机复位命令 */ public static NyLiftCommand getLiftResetCommand(Integer liftNo) { NyLiftCommand command = new NyLiftCommand(); command.setLiftNo(liftNo.shortValue()); command.setTaskNo((short) 0); command.setTaskModel((short) 0); command.setSourceSta((short) 0); command.setTargetSta((short) 0); return command; } //获取提升机站点 public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) { SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); for (LiftSlave liftSlave : slaveProperties.getLift()) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getStaNo().equals(staNo)) { return liftStaProtocol; } } } return null; } //获取提升机站点 public static LiftStaProtocol getLiftStaByStaNo(Integer liftNo, Integer staNo) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getStaNo().equals(staNo)) { return liftStaProtocol; } } return null; } //获取提升机站点 public static LiftStaProtocol getLiftStaByLev(Integer liftNo, Integer lev) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getLev().equals(lev)) { return liftStaProtocol; } } return null; } }