5 changed files with 129 additions and 36 deletions
-
47src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpSet.java
-
45src/main/java/com/iflytop/gd/app/cmd/debug/DebugPumpStop.java
-
20src/main/java/com/iflytop/gd/hardware/controller/ServoController.java
-
28src/main/java/com/iflytop/gd/hardware/controller/StepMotorController.java
-
25src/main/resources/sql/init.sql
@ -0,0 +1,47 @@ |
|||
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 lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 加液泵 设置加液泵 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("debug_pump_set") |
|||
public class DebugPumpSet extends BaseCommandHandler { |
|||
private final DeviceCommandService deviceCommandService; |
|||
|
|||
@Override |
|||
public void handle(CmdDTO cmdDTO) throws Exception { |
|||
String pumpId = cmdDTO.getStringParam("pumpId"); |
|||
Integer current = cmdDTO.getIntegerParam("current"); |
|||
Double speed = cmdDTO.getDoubleParam("speed"); |
|||
Double innerDiameter = cmdDTO.getDoubleParam("innerDiameter"); |
|||
CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); |
|||
DeviceCommand deviceCommand; |
|||
switch (pumpDevice) { |
|||
case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Set(current, speed); |
|||
case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Set(current, speed); |
|||
case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Set(current, speed); |
|||
case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Set(current, speed); |
|||
case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Set(current, speed); |
|||
case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Set(current, speed); |
|||
case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Set(current, speed); |
|||
case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Set(current, speed); |
|||
default -> throw new RuntimeException("pumpId 未找到"); |
|||
} |
|||
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|||
commandWait(deviceCommandFuture); |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
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_stop") |
|||
public class DebugPumpStop extends BaseCommandHandler { |
|||
private final DeviceCommandService deviceCommandService; |
|||
|
|||
@Override |
|||
public void handle(CmdDTO cmdDTO) throws Exception { |
|||
String pumpId = cmdDTO.getStringParam("pumpId"); |
|||
CmdDevice pumpDevice = CmdDevice.valueOf(pumpId); |
|||
DeviceCommand deviceCommand; |
|||
switch (pumpDevice) { |
|||
case CmdDevice.acid_pump_1 -> deviceCommand = DeviceCommandGenerator.acidPump1Stop(); |
|||
case CmdDevice.acid_pump_2 -> deviceCommand = DeviceCommandGenerator.acidPump2Stop(); |
|||
case CmdDevice.acid_pump_3 -> deviceCommand = DeviceCommandGenerator.acidPump3Stop(); |
|||
case CmdDevice.acid_pump_4 -> deviceCommand = DeviceCommandGenerator.acidPump4Stop(); |
|||
case CmdDevice.acid_pump_5 -> deviceCommand = DeviceCommandGenerator.acidPump5Stop(); |
|||
case CmdDevice.acid_pump_6 -> deviceCommand = DeviceCommandGenerator.acidPump6Stop(); |
|||
case CmdDevice.acid_pump_7 -> deviceCommand = DeviceCommandGenerator.acidPump7Stop(); |
|||
case CmdDevice.acid_pump_8 -> deviceCommand = DeviceCommandGenerator.acidPump8Stop(); |
|||
default -> throw new RuntimeException("pumpId 未找到"); |
|||
} |
|||
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|||
commandWait(deviceCommandFuture); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue