Browse Source

update

master
zhaohe 2 months ago
parent
commit
e770e7ca06
  1. 13
      src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java
  2. 46
      src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceExCtrlController.java
  3. 4
      src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java

13
src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java

@ -1,5 +1,6 @@
package a8k.app.controler.api.v1.app.ctrl; package a8k.app.controler.api.v1.app.ctrl;
import a8k.app.service.mainctrl.AppDeviceInitCtrlService;
import a8k.app.service.mainctrl.AppDeviceMainFlowCtrlService; import a8k.app.service.mainctrl.AppDeviceMainFlowCtrlService;
import a8k.app.type.exception.AppException; import a8k.app.type.exception.AppException;
import a8k.app.type.ui.ApiRet; import a8k.app.type.ui.ApiRet;
@ -22,6 +23,10 @@ public class DeviceCtrlControler {
@Resource @Resource
AppDeviceMainFlowCtrlService appDeviceMainFlowCtrlService; AppDeviceMainFlowCtrlService appDeviceMainFlowCtrlService;
@Resource
AppDeviceInitCtrlService appDeviceInitCtrlService;
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXT FUNC // EXT FUNC
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -57,4 +62,12 @@ public class DeviceCtrlControler {
return ApiRet.success(); return ApiRet.success();
} }
@Operation(description = "失能设备")
@PostMapping("/disableDevice")
public ApiRet<Void> disableDevice() throws AppException {
appDeviceInitCtrlService.disableAllMiniServo();
appDeviceInitCtrlService.disableAllMotor();
return ApiRet.success();
}
} }

46
src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceExCtrlController.java

@ -13,56 +13,16 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@Tag(name = "设备控制", description = "")
@Tag(name = "设备扩展控制", description = "")
@Slf4j @Slf4j
@Controller @Controller
@RequestMapping(value = "/api/v1/app/deviceCtrl/")
@RequestMapping(value = "/api/v1/app/deviceExCtrl/")
@ResponseBody @ResponseBody
public class DeviceCtrlControler {
@Resource
AppDeviceMainFlowCtrlService appDeviceMainFlowCtrlService;
public class DeviceExCtrlController {
@Resource @Resource
AppDeviceInitCtrlService appDeviceInitCtrlService; AppDeviceInitCtrlService appDeviceInitCtrlService;
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXT FUNC
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* 设备控制
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
@Operation(description = "开始工作")
@PostMapping("/startWork")
public ApiRet<Void> startWork() throws AppException {
appDeviceMainFlowCtrlService.startWork();
return ApiRet.success();
}
@Operation(description = "停止工作")
@PostMapping("/stopWork")
public ApiRet<Void> stopWork() throws AppException {
appDeviceMainFlowCtrlService.stopWork();
return ApiRet.success();
}
@Operation(description = "暂停工作")
@PostMapping("/pauseWork")
public ApiRet<Void> pauseWork() throws AppException {
appDeviceMainFlowCtrlService.pauseWork();
return ApiRet.success();
}
@Operation(description = "继续工作")
@PostMapping("/continueWork")
public ApiRet<Void> continueWork() throws AppException {
appDeviceMainFlowCtrlService.continueWork();
return ApiRet.success();
}
@Operation(description = "失能设备") @Operation(description = "失能设备")
@PostMapping("/disableDevice") @PostMapping("/disableDevice")
public ApiRet<Void> disableDevice() throws AppException { public ApiRet<Void> disableDevice() throws AppException {

4
src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java

@ -70,7 +70,7 @@ public class AppWebSocketEndpointMgr {
List<Session> eventWebsocketSessions = new ArrayList<>(); List<Session> eventWebsocketSessions = new ArrayList<>();
Thread workThread; Thread workThread;
Boolean newStateSession = false; Boolean newStateSession = false;
Map<String, Integer> stateVersionCache =new HashMap<>();
Map<String, Integer> stateVersionCache = new HashMap<>();
synchronized void setNewStateSession() { synchronized void setNewStateSession() {
this.newStateSession = true; this.newStateSession = true;
@ -150,7 +150,6 @@ public class AppWebSocketEndpointMgr {
} }
@Scheduled(fixedDelay = 200) @Scheduled(fixedDelay = 200)
public void reportDeviceState() { public void reportDeviceState() {
//TODO : 这里可以考虑增加一个状态版本号只有状态变化时才发送 //TODO : 这里可以考虑增加一个状态版本号只有状态变化时才发送
@ -195,6 +194,7 @@ public class AppWebSocketEndpointMgr {
public void onNewStateSession() { public void onNewStateSession() {
if (getAndClearNewStateSession()) { if (getAndClearNewStateSession()) {
log.info("onNewStateSession: new state session detected, broadcasting current state"); log.info("onNewStateSession: new state session detected, broadcasting current state");
stateVersionCache.clear();
reportDeviceState(); reportDeviceState();
reportSessionState(); reportSessionState();
quickReportStateSchedule(); quickReportStateSchedule();

Loading…
Cancel
Save