|
@ -0,0 +1,84 @@ |
|
|
|
|
|
package a8k.extui.page.test.driver; |
|
|
|
|
|
|
|
|
|
|
|
import a8k.app.a8ktype.exception.AppException; |
|
|
|
|
|
import a8k.app.hardware.driver.StepMotorCtrlDriver; |
|
|
|
|
|
import a8k.app.hardware.driver.type.StepMotorMId; |
|
|
|
|
|
import a8k.extui.mgr.ExtApiPageMgr; |
|
|
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
|
|
public class MotorCtrlPage { |
|
|
|
|
|
@Resource |
|
|
|
|
|
StepMotorCtrlDriver stepMotorCtrlDriver; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
ExtApiPageMgr extApiPageMgr; |
|
|
|
|
|
|
|
|
|
|
|
StepMotorMId id = StepMotorMId.FeedingModXM; |
|
|
|
|
|
Integer dpos = 10; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setStepMotorId(StepMotorMId id) { |
|
|
|
|
|
this.id = id; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setStepMotorDpos(Integer dpos) { |
|
|
|
|
|
this.dpos = dpos; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
public void enableMotor() throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEnable(id, 1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void disableMotor() throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEnable(id, 0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void stepMotorEasyMoveToZero() throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEasyMoveToZeroPointQuickBlock(id, 10000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void stepMotorEasyMoveForward() throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEasyMoveByBlock(id, dpos, 10000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void stepMotorEasyMoveBackward() throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEasyMoveByBlock(id, -dpos, 10000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void stepMotorEasyMoveTo(Integer pos) throws AppException { |
|
|
|
|
|
stepMotorCtrlDriver.stepMotorEasyMoveToBlock(id, pos, 10000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
|
|
void init() { |
|
|
|
|
|
var page = extApiPageMgr.newPage(this); |
|
|
|
|
|
|
|
|
|
|
|
page.newGroup("上下文"); |
|
|
|
|
|
page.addFunction("设置电机ID", this::setStepMotorId).setParamVal("id", () -> id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page.newGroup("基础操作"); |
|
|
|
|
|
page.addFunction("使能电机", this::enableMotor); |
|
|
|
|
|
page.addFunction("失能电机", this::disableMotor); |
|
|
|
|
|
page.addFunction("快速归零", this::stepMotorEasyMoveToZero); |
|
|
|
|
|
|
|
|
|
|
|
page.newGroup("相对移动"); |
|
|
|
|
|
page.addFunction("设置相对移动距离", this::setStepMotorDpos).setParamVal("dpos", () -> dpos); |
|
|
|
|
|
page.addFunction("正向移动", this::stepMotorEasyMoveForward); |
|
|
|
|
|
page.addFunction("反向移动", this::stepMotorEasyMoveBackward); |
|
|
|
|
|
|
|
|
|
|
|
page.newGroup("绝对移动"); |
|
|
|
|
|
page.addFunction("绝对移动", this::stepMotorEasyMoveTo); |
|
|
|
|
|
|
|
|
|
|
|
extApiPageMgr.addPage(page); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |