From e770e7ca068d2e3b7c49828ee33ee8f815cd2c69 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 9 Jun 2025 22:13:41 +0800 Subject: [PATCH] update --- .../api/v1/app/ctrl/DeviceCtrlControler.java | 13 ++++++ .../api/v1/app/ctrl/DeviceExCtrlController.java | 46 ++-------------------- .../api/v1/app/ws/AppWebSocketEndpointMgr.java | 4 +- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java b/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java index 94c7438..c16a70a 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java +++ b/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceCtrlControler.java @@ -1,5 +1,6 @@ package a8k.app.controler.api.v1.app.ctrl; +import a8k.app.service.mainctrl.AppDeviceInitCtrlService; import a8k.app.service.mainctrl.AppDeviceMainFlowCtrlService; import a8k.app.type.exception.AppException; import a8k.app.type.ui.ApiRet; @@ -22,6 +23,10 @@ public class DeviceCtrlControler { @Resource AppDeviceMainFlowCtrlService appDeviceMainFlowCtrlService; + @Resource + AppDeviceInitCtrlService appDeviceInitCtrlService; + + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // EXT FUNC // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -57,4 +62,12 @@ public class DeviceCtrlControler { return ApiRet.success(); } + + @Operation(description = "失能设备") + @PostMapping("/disableDevice") + public ApiRet disableDevice() throws AppException { + appDeviceInitCtrlService.disableAllMiniServo(); + appDeviceInitCtrlService.disableAllMotor(); + return ApiRet.success(); + } } diff --git a/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceExCtrlController.java b/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceExCtrlController.java index c16a70a..193812a 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ctrl/DeviceExCtrlController.java +++ b/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.ResponseBody; -@Tag(name = "设备控制", description = "") +@Tag(name = "设备扩展控制", description = "") @Slf4j @Controller -@RequestMapping(value = "/api/v1/app/deviceCtrl/") +@RequestMapping(value = "/api/v1/app/deviceExCtrl/") @ResponseBody -public class DeviceCtrlControler { - - @Resource - AppDeviceMainFlowCtrlService appDeviceMainFlowCtrlService; +public class DeviceExCtrlController { @Resource AppDeviceInitCtrlService appDeviceInitCtrlService; - - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // EXT FUNC - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * 设备控制 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - @Operation(description = "开始工作") - @PostMapping("/startWork") - public ApiRet startWork() throws AppException { - appDeviceMainFlowCtrlService.startWork(); - return ApiRet.success(); - } - - @Operation(description = "停止工作") - @PostMapping("/stopWork") - public ApiRet stopWork() throws AppException { - appDeviceMainFlowCtrlService.stopWork(); - return ApiRet.success(); - } - - @Operation(description = "暂停工作") - @PostMapping("/pauseWork") - public ApiRet pauseWork() throws AppException { - appDeviceMainFlowCtrlService.pauseWork(); - return ApiRet.success(); - } - - @Operation(description = "继续工作") - @PostMapping("/continueWork") - public ApiRet continueWork() throws AppException { - appDeviceMainFlowCtrlService.continueWork(); - return ApiRet.success(); - } - - @Operation(description = "失能设备") @PostMapping("/disableDevice") public ApiRet disableDevice() throws AppException { diff --git a/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java b/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java index 877003b..b0197ed 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java +++ b/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java @@ -70,7 +70,7 @@ public class AppWebSocketEndpointMgr { List eventWebsocketSessions = new ArrayList<>(); Thread workThread; Boolean newStateSession = false; - Map stateVersionCache =new HashMap<>(); + Map stateVersionCache = new HashMap<>(); synchronized void setNewStateSession() { this.newStateSession = true; @@ -150,7 +150,6 @@ public class AppWebSocketEndpointMgr { } - @Scheduled(fixedDelay = 200) public void reportDeviceState() { //TODO : 这里可以考虑增加一个状态版本号,只有状态变化时才发送 @@ -195,6 +194,7 @@ public class AppWebSocketEndpointMgr { public void onNewStateSession() { if (getAndClearNewStateSession()) { log.info("onNewStateSession: new state session detected, broadcasting current state"); + stateVersionCache.clear(); reportDeviceState(); reportSessionState(); quickReportStateSchedule();