|
|
@ -0,0 +1,48 @@ |
|
|
|
package com.iflytop.gd.app.cmd.debug; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.gd.app.service.DeviceCommandService; |
|
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
|
import com.iflytop.gd.common.cmd.CommandFuture; |
|
|
|
import com.iflytop.gd.common.cmd.DeviceCommand; |
|
|
|
import com.iflytop.gd.common.cmd.DeviceCommandGenerator; |
|
|
|
import com.iflytop.gd.common.enums.cmd.CmdDevice; |
|
|
|
import com.iflytop.gd.common.enums.cmd.CmdDirection; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
/** |
|
|
|
* 加液泵 启动加液泵 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
@CommandMapping("debug_pump_start") |
|
|
|
public class DebugPumpStart extends BaseCommandHandler { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handle(CmdDTO cmdDTO) throws Exception { |
|
|
|
String pumpId = cmdDTO.getStringParam("pumpId"); |
|
|
|
String direction = cmdDTO.getStringParam("direction"); |
|
|
|
Double volume = cmdDTO.getDoubleParam("volume"); |
|
|
|
CmdDirection directionEnum = CmdDirection.valueOf(direction); |
|
|
|
CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); |
|
|
|
DeviceCommand deviceCommand; |
|
|
|
switch (pumpDevice) { |
|
|
|
case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Move(directionEnum, volume); |
|
|
|
case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Move(directionEnum, volume); |
|
|
|
default -> throw new RuntimeException("pumpId 未找到"); |
|
|
|
} |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
} |