|
|
@ -0,0 +1,123 @@ |
|
|
|
package a8k.extui.newpage.init; |
|
|
|
|
|
|
|
import a8k.app.a8ktype.DeviceRunMode; |
|
|
|
import a8k.app.a8ktype.exception.AppException; |
|
|
|
import a8k.app.a8ktype.others.checkpoint.CheckResult; |
|
|
|
import a8k.app.service.background.BackgroudProcessCtrlService; |
|
|
|
import a8k.app.service.lowerctrl.DeviceInitCtrlService; |
|
|
|
import a8k.app.service.statemgr.GStateMgrService; |
|
|
|
import a8k.extui.mgr.ExtApiPageMgr; |
|
|
|
import a8k.extui.type.ExtApiStatu; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class DeviceInitPage { |
|
|
|
|
|
|
|
@Resource |
|
|
|
GStateMgrService gstate; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
DeviceInitCtrlService deviceInitCtrlService; |
|
|
|
|
|
|
|
|
|
|
|
@ExtApiStatu(name = "", group = "设备工作模式", order = 1) |
|
|
|
public String getDeviceRunMode() { |
|
|
|
if (gstate.getDeviceRunMode() == DeviceRunMode.RealMode) { |
|
|
|
return "真实模式"; |
|
|
|
} else if (gstate.getDeviceRunMode() == DeviceRunMode.VirtualMode) { |
|
|
|
return "虚拟模式"; |
|
|
|
} else if (gstate.getDeviceRunMode() == DeviceRunMode.RunOnlyMode) { |
|
|
|
return "设备空转模式"; |
|
|
|
} else if (gstate.getDeviceRunMode() == DeviceRunMode.VirtualStateGenerateMode) { |
|
|
|
return "虚拟状态生成模式"; |
|
|
|
} |
|
|
|
return gstate.getDeviceRunMode().name(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
public void setInRealMode() { |
|
|
|
gstate.setDeviceRunMode(DeviceRunMode.RealMode); |
|
|
|
} |
|
|
|
|
|
|
|
public void setInVirtualMode() { |
|
|
|
gstate.setDeviceRunMode(DeviceRunMode.VirtualMode); |
|
|
|
} |
|
|
|
|
|
|
|
public void setInRunOnlyMode() { |
|
|
|
gstate.setDeviceRunMode(DeviceRunMode.RunOnlyMode); |
|
|
|
} |
|
|
|
|
|
|
|
public void setInVirtualStateMode() { |
|
|
|
gstate.setDeviceRunMode(DeviceRunMode.VirtualStateGenerateMode); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String moveAllStepMotorToZero() throws AppException { |
|
|
|
deviceInitCtrlService.moveAllMotorToZero(); |
|
|
|
return "SUCCESS"; |
|
|
|
} |
|
|
|
|
|
|
|
public String disableAll() throws AppException { |
|
|
|
deviceInitCtrlService.disableAllMotor(); |
|
|
|
return "已失能所有电机"; |
|
|
|
} |
|
|
|
|
|
|
|
public String enableAll() throws AppException { |
|
|
|
deviceInitCtrlService.enableAllMotor(); |
|
|
|
return "已使能所有电机"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
BackgroudProcessCtrlService backgroudProcessCtrlService; |
|
|
|
|
|
|
|
public void startTemperatureControl() throws AppException { |
|
|
|
backgroudProcessCtrlService.startProcess(); |
|
|
|
} |
|
|
|
|
|
|
|
public void stopTemperatureControl() throws AppException { |
|
|
|
backgroudProcessCtrlService.stopProcess(); |
|
|
|
} |
|
|
|
|
|
|
|
public List<CheckResult> initializeDevice() throws AppException { |
|
|
|
var ret = deviceInitCtrlService.initDevice(); |
|
|
|
List<CheckResult> errorList = new java.util.ArrayList<>(); |
|
|
|
for (var checkResult : ret) { |
|
|
|
if (!checkResult.pass) { |
|
|
|
errorList.add(checkResult); |
|
|
|
} |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
@Resource |
|
|
|
ExtApiPageMgr extApiPageMgr; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
|
var page = extApiPageMgr.newPage(this); |
|
|
|
page.newGroup("设备工作模式"); |
|
|
|
page.addFunction("设置为真实模式", this::setInRealMode); |
|
|
|
page.addFunction("设置为虚拟模式", this::setInVirtualMode); |
|
|
|
page.addFunction("设置为设备空转模式", this::setInRunOnlyMode); |
|
|
|
page.addFunction("设置为虚拟状态生成模式", this::setInVirtualStateMode); |
|
|
|
|
|
|
|
page.newGroup("设备初始化"); |
|
|
|
page.addFunction("初始化设备", this::initializeDevice); |
|
|
|
page.addFunction("开始控温", this::startTemperatureControl); |
|
|
|
page.addFunction("停止控温", this::stopTemperatureControl); |
|
|
|
|
|
|
|
page.newGroup("电机初始化"); |
|
|
|
page.addFunction("电机归零", this::moveAllStepMotorToZero); |
|
|
|
page.addFunction("使能所有电机", this::enableAll); |
|
|
|
page.addFunction("失能所有电机", this::disableAll); |
|
|
|
|
|
|
|
extApiPageMgr.addPage(page); |
|
|
|
} |
|
|
|
} |