|
|
@ -6,6 +6,7 @@ import com.iflytop.gd.common.enums.cmd.CmdDevice; |
|
|
|
import com.iflytop.gd.common.enums.cmd.CmdDirection; |
|
|
|
import com.iflytop.gd.hardware.command.CommandHandler; |
|
|
|
import com.iflytop.gd.hardware.drivers.StepMotorDriver.HBotDriver; |
|
|
|
import com.iflytop.gd.hardware.type.IO.OutputIOMId; |
|
|
|
import com.iflytop.gd.hardware.type.StepMotor.StepMotorMId; |
|
|
|
import com.iflytop.gd.hardware.type.MId; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@ -22,6 +23,10 @@ import java.util.stream.Collectors; |
|
|
|
public class HBotHandler extends CommandHandler { |
|
|
|
private final HBotDriver driver_; |
|
|
|
|
|
|
|
private final Map<CmdDevice, OutputIOMId> supportCmdDeviceIOOutputMap = Map.ofEntries( |
|
|
|
Map.entry(CmdDevice.gantry_z, OutputIOMId.DO_HBOTZ_MOTOR_CLAMP) |
|
|
|
); |
|
|
|
|
|
|
|
private final Map<CmdDevice, StepMotorMId> stepMotorMIdMap_ = Map.ofEntries( |
|
|
|
Map.entry(CmdDevice.gantry_x, StepMotorMId.HBOT_X_MOTOR_MID), |
|
|
|
Map.entry(CmdDevice.gantry_y, StepMotorMId.HBOT_Y_MOTOR_MID), |
|
|
@ -46,6 +51,9 @@ public class HBotHandler extends CommandHandler { |
|
|
|
public void handleCommand(DeviceCommand command) throws Exception { |
|
|
|
// 发送命令 |
|
|
|
StepMotorMId stepMotorMId = stepMotorMIdMap_.get(command.getDevice()); |
|
|
|
|
|
|
|
OutputIOMId clampMId = supportCmdDeviceIOOutputMap.get(command.getDevice()); |
|
|
|
|
|
|
|
if (command.getAction() == CmdAction.origin) { |
|
|
|
driver_.moveToHome(stepMotorMId); |
|
|
|
} |
|
|
@ -53,13 +61,17 @@ public class HBotHandler extends CommandHandler { |
|
|
|
driver_.stop(stepMotorMId); |
|
|
|
} |
|
|
|
else if(command.getAction() == CmdAction.move) { |
|
|
|
driver_.openClamp(clampMId); |
|
|
|
double position = command.getParam().getPosition(); |
|
|
|
driver_.moveTo(stepMotorMId, position); |
|
|
|
driver_.closeClamp(clampMId); |
|
|
|
} |
|
|
|
else if(command.getAction() == CmdAction.move_by) { |
|
|
|
driver_.openClamp(clampMId); |
|
|
|
double distance = command.getParam().getPosition(); |
|
|
|
|
|
|
|
driver_.moveBy(stepMotorMId, distance); |
|
|
|
driver_.closeClamp(clampMId); |
|
|
|
} |
|
|
|
else if(command.getAction() == CmdAction.set) { |
|
|
|
Double speed = command.getParam().getSpeed(); |
|
|
|