26 changed files with 414 additions and 349 deletions
-
25src/main/java/a8k/app/a8ktype/appevent/A8kEcodeContextListPromptEvent.java
-
30src/main/java/a8k/app/a8ktype/appevent/A8kErrorsPromptEvent.java
-
4src/main/java/a8k/app/a8ktype/appevent/AppEvent.java
-
16src/main/java/a8k/app/a8ktype/appevent/AppPromptEvent.java
-
16src/main/java/a8k/app/a8ktype/appevent/AppPromptEvents.java
-
12src/main/java/a8k/app/a8ktype/appevent/MessageBoxUpdateEvent.java
-
3src/main/java/a8k/app/a8ktype/state/DeviceWorkState.java
-
16src/main/java/a8k/app/a8ktype/ui/MessageBox.java
-
4src/main/java/a8k/app/a8ktype/ui/MessageLevel.java
-
36src/main/java/a8k/app/a8ktype/ui/ZAppPromopt.java
-
7src/main/java/a8k/app/a8ktype/ui/ZAppPromoptDetailInfoType.java
-
34src/main/java/a8k/app/a8ktype/ui/ZAppPromoptTable.java
-
22src/main/java/a8k/app/controler/api/v1/app/basic/AppEventBusControler.java
-
18src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java
-
77src/main/java/a8k/app/factory/ZAppPromoptFactory.java
-
108src/main/java/a8k/app/service/bases/FrontEndEventRouter.java
-
159src/main/java/a8k/app/service/bases/FrontEndMessageBoxAndEventMgr.java
-
4src/main/java/a8k/app/service/lowerctrl/DeviceInitCtrlService.java
-
3src/main/java/a8k/app/service/lowerctrl/ProjIDCardCtrlAndMonitorService.java
-
25src/main/java/a8k/app/service/mainctrl/mainflowctrl/MainFlowCtrlScheduler.java
-
1src/main/java/a8k/app/service/mainctrl/mainflowctrl/action/P30ScanTubeHolderTask.java
-
8src/main/java/a8k/app/service/statemgr/DeviceWorkStateMgrService.java
-
1src/main/java/a8k/extui/mgr/ExtApiPageGroupCfgMgr.java
-
53src/main/java/a8k/extui/page/debug/P00AppEventAndMessageBoxDebugPage.java
-
69src/main/java/a8k/extui/page/frond_end_test/VirtualEventGeneratorPage.java
@ -1,25 +0,0 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
import a8k.app.service.mainctrl.mainflowctrl.base.AppActionErrorContext; |
|||
import a8k.app.utils.ZList; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class A8kEcodeContextListPromptEvent extends AppEvent { |
|||
public List<AppActionErrorContext> ecodeList; |
|||
|
|||
public A8kEcodeContextListPromptEvent(List<AppActionErrorContext> ecodeList) { |
|||
super(A8kEcodeContextListPromptEvent.class.getSimpleName()); |
|||
this.ecodeList = ecodeList; |
|||
} |
|||
|
|||
public A8kEcodeContextListPromptEvent(AppActionErrorContext... ecodeList) { |
|||
super(A8kEcodeContextListPromptEvent.class.getSimpleName()); |
|||
this.ecodeList = ZList.of(ecodeList); |
|||
} |
|||
|
|||
|
|||
public String toString() { |
|||
return String.format("ecodeList:%s", ecodeList); |
|||
} |
|||
} |
@ -1,30 +0,0 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
import a8k.app.hardware.type.a8kcanprotocol.A8kEcode; |
|||
import a8k.app.a8ktype.error.AppError; |
|||
import a8k.app.utils.ZList; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class A8kErrorsPromptEvent extends AppEvent { |
|||
public List<AppError> errors; |
|||
|
|||
public A8kErrorsPromptEvent(A8kEcode errorCode) { |
|||
super(A8kErrorsPromptEvent.class.getSimpleName()); |
|||
errors = ZList.of(new AppError(errorCode)); |
|||
} |
|||
|
|||
public A8kErrorsPromptEvent(AppError erro) { |
|||
super(A8kErrorsPromptEvent.class.getSimpleName()); |
|||
errors = ZList.of(erro); |
|||
} |
|||
|
|||
public A8kErrorsPromptEvent(List<AppError> errors) { |
|||
super(A8kErrorsPromptEvent.class.getSimpleName()); |
|||
this.errors = errors; |
|||
} |
|||
|
|||
public String toString() { |
|||
return String.format("%s", errors); |
|||
} |
|||
} |
@ -1,12 +1,12 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
import java.util.Date; |
|||
import java.util.UUID; |
|||
|
|||
public class AppEvent { |
|||
public String typeName; |
|||
public Integer timestamp = (int) (new Date().getTime() / 1000); |
|||
// public String id = UUID.randomUUID().toString(); |
|||
|
|||
public String eventId = UUID.randomUUID().toString(); |
|||
public AppEvent(String typeName) { |
|||
this.typeName = typeName; |
|||
} |
|||
|
@ -0,0 +1,16 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
import a8k.app.a8ktype.ui.ZAppPromopt; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class AppPromptEvent extends AppEvent { |
|||
|
|||
public ZAppPromopt prompt; |
|||
|
|||
public AppPromptEvent(ZAppPromopt prompt) { |
|||
super(AppPromptEvent.class.getSimpleName()); |
|||
this.prompt = prompt; |
|||
} |
|||
|
|||
} |
@ -1,16 +0,0 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
import a8k.app.a8ktype.ui.ZAppPromopt; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class AppPromptEvents extends AppEvent { |
|||
|
|||
public List<ZAppPromopt> prompt; |
|||
|
|||
public AppPromptEvents(List<ZAppPromopt> prompt) { |
|||
super(AppPromptEvents.class.getSimpleName()); |
|||
this.prompt = prompt; |
|||
} |
|||
|
|||
} |
@ -1,12 +0,0 @@ |
|||
package a8k.app.a8ktype.appevent; |
|||
|
|||
|
|||
public class MessageBoxUpdateEvent extends AppEvent { |
|||
public String message; |
|||
public Integer overtimes = 0; |
|||
|
|||
public MessageBoxUpdateEvent(String message) { |
|||
super(MessageBoxUpdateEvent.class.getSimpleName()); |
|||
this.message = message; |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package a8k.app.a8ktype.ui; |
|||
|
|||
import java.util.Date; |
|||
|
|||
public class MessageBox { |
|||
public Date time; |
|||
public MessageLevel messageLevel; |
|||
public String message; |
|||
|
|||
public MessageBox(MessageLevel messageLevel, String message) { |
|||
this.time = new Date(); |
|||
this.messageLevel = messageLevel; |
|||
this.message = message; |
|||
} |
|||
|
|||
} |
@ -1,7 +1,7 @@ |
|||
package a8k.app.a8ktype.ui; |
|||
|
|||
public enum ZAppPromoptType { |
|||
Notify, //通知 |
|||
public enum MessageLevel { |
|||
Info, //通知 |
|||
Warn, //警告 |
|||
Error, //错误 |
|||
Fatal, //致命错误 |
@ -0,0 +1,7 @@ |
|||
package a8k.app.a8ktype.ui; |
|||
|
|||
public enum ZAppPromoptDetailInfoType { |
|||
Text,//文本 |
|||
Forms, //表单 |
|||
Table, //表格 |
|||
} |
@ -1,27 +1,39 @@ |
|||
package a8k.app.a8ktype.ui; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
public class ZAppPromoptTable { |
|||
|
|||
public enum ColorType { |
|||
Normal, |
|||
Warning, |
|||
Error |
|||
} |
|||
|
|||
public static class Val { |
|||
public ColorType colorType;//Normal,Warning, Error |
|||
public String val; |
|||
public MessageLevel messageLevel;//Normal,Warning,Error |
|||
public String val; |
|||
|
|||
public Val(ColorType colorType, String val) { |
|||
this.val = val; |
|||
this.colorType = colorType; |
|||
public Val(MessageLevel messageLevel, String val) { |
|||
this.val = val; |
|||
this.messageLevel = messageLevel; |
|||
} |
|||
|
|||
public Val(String val) { |
|||
this.messageLevel = MessageLevel.Info; |
|||
this.val = val; |
|||
} |
|||
} |
|||
|
|||
public List<String> header = new ArrayList<>(); |
|||
public List<String> types = new ArrayList<>(); |
|||
public List<Val[]> vars = new ArrayList<>(); |
|||
|
|||
public void addHeader(String... header) { |
|||
this.header.addAll(Arrays.asList(header)); |
|||
} |
|||
|
|||
public void addType(String... type) { |
|||
this.types.addAll(Arrays.asList(type)); |
|||
} |
|||
|
|||
public void addVar(Val... var) { |
|||
this.vars.add(var); |
|||
} |
|||
} |
@ -1,108 +0,0 @@ |
|||
package a8k.app.service.bases; |
|||
|
|||
import a8k.app.factory.ZAppPromoptFactory; |
|||
import a8k.app.a8ktype.appevent.*; |
|||
import jakarta.annotation.PostConstruct; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
import java.util.Queue; |
|||
|
|||
@Component |
|||
@Slf4j |
|||
public class FrontEndEventRouter { |
|||
static class ORDER { |
|||
static final int pollAppEvent = 1; |
|||
} |
|||
|
|||
|
|||
@Resource |
|||
AppEventBusService eventBus; |
|||
|
|||
private final Queue<AppEvent> appEventQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
eventBus.regListener(this::onAppEvent); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// Internal APIs |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
|
|||
AppEvent preProcessAppEvent(AppEvent event) { |
|||
/* |
|||
* 下面事件,直接转发给前端,前端需要处理 |
|||
*/ |
|||
if (event instanceof AppIDCardMountEvent) { |
|||
return event; //前端需要更新IDcard的状态,并弹窗,有新的IDcard插入,询问用户是否保存 |
|||
} else if (event instanceof AppIDCardUnmountEvent) { |
|||
return event; //前端需要更新IDcard的状态 |
|||
} else if (event instanceof AppTubeholderSettingUpdateEvent) { |
|||
return event;//前端需要更新试管架设置 |
|||
} else if (event instanceof DoA8kStepActionEvent) { |
|||
return new MessageBoxUpdateEvent(((DoA8kStepActionEvent) event).actionStepName); |
|||
} |
|||
|
|||
/* |
|||
* 下面事件,均转换成 AppPromptEvents |
|||
*/ |
|||
else if (event instanceof A8kEcodeContextListPromptEvent e) { |
|||
return ZAppPromoptFactory.buildAppPromptEvents(e); |
|||
} else if (event instanceof A8kErrorsPromptEvent e) { |
|||
return ZAppPromoptFactory.buildAppPromptEvents(e); |
|||
} else if (event instanceof AppWarningNotifyEvent e) { |
|||
return new AppPromptEvents(List.of(ZAppPromoptFactory.buildAppPromopt(e.error))); |
|||
} else if (event instanceof AppPromptEvents) { |
|||
return event; //前端需要显示提示信息 |
|||
} else if (event instanceof AppExceptionEvent e) { |
|||
return ZAppPromoptFactory.buildAppPromoptEvent(e.exception); |
|||
} |
|||
|
|||
/* |
|||
* 下面事件,不需要前端处理 |
|||
*/ |
|||
else if (event instanceof A8kCanBusOnConnectEvent) { |
|||
return null; //过滤,前端不需要处理 |
|||
} else if (event instanceof A8kHardwareReport) { |
|||
return null;//过滤,前端不需要处理 |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
synchronized AppEvent pollAppEventFromQueue() { |
|||
return appEventQueue.poll(); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// 事件处理 |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
public void onAppEvent(AppEvent event) { |
|||
AppEvent afProcessEvent = preProcessAppEvent(event); |
|||
if (afProcessEvent == null) { |
|||
return; |
|||
} |
|||
appEventQueue.add(afProcessEvent); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// Exposed APIs |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
public AppEvent pollAppEvent() { |
|||
return (pollAppEventFromQueue()); |
|||
} |
|||
|
|||
public List<AppEvent> pollAllAppEvents() { |
|||
List<AppEvent> ret = new java.util.ArrayList<>(); |
|||
while (!appEventQueue.isEmpty()) { |
|||
ret.add(pollAppEventFromQueue()); |
|||
} |
|||
return ret; |
|||
} |
|||
} |
@ -0,0 +1,159 @@ |
|||
package a8k.app.service.bases; |
|||
|
|||
import a8k.app.a8ktype.ui.MessageBox; |
|||
import a8k.app.a8ktype.ui.MessageLevel; |
|||
import a8k.app.factory.ZAppPromoptFactory; |
|||
import a8k.app.a8ktype.appevent.*; |
|||
import jakarta.annotation.PostConstruct; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.LinkedList; |
|||
import java.util.List; |
|||
import java.util.Queue; |
|||
|
|||
@Component |
|||
@Slf4j |
|||
public class FrontEndMessageBoxAndEventMgr { |
|||
public static class FrontEndMessageBoxState { |
|||
public MessageBox topMessage; //顶部消息 |
|||
public final LinkedList<MessageBox> messageBoxList = new LinkedList<>(); //消息列表 |
|||
public Integer stateVersion = 0; |
|||
} |
|||
|
|||
@Resource |
|||
AppEventBusService eventBus; |
|||
|
|||
|
|||
private final Queue<AppEvent> reportAppEventQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); //事件上报队列 |
|||
private final LinkedList<AppEvent> appHistoryEventList = new LinkedList<>();//历史事件 |
|||
|
|||
private final FrontEndMessageBoxState frontEndMessageBoxState = new FrontEndMessageBoxState(); |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
eventBus.regListener(this::onAppEvent); |
|||
pushMessageBox(new MessageBox(MessageLevel.Info, "系统启动")); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// Internal APIs |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
|
|||
AppEvent preProcessAppEvent(AppEvent event) { |
|||
/* |
|||
* 下面事件,直接转发给前端,前端需要处理 |
|||
*/ |
|||
if (event instanceof AppIDCardMountEvent) { |
|||
return event; //前端需要更新IDcard的状态,并弹窗,有新的IDcard插入,询问用户是否保存 |
|||
} else if (event instanceof AppIDCardUnmountEvent) { |
|||
return event; //前端需要更新IDcard的状态 |
|||
} else if (event instanceof AppTubeholderSettingUpdateEvent) { |
|||
return event;//前端需要更新试管架设置 |
|||
} else if (event instanceof DoA8kStepActionEvent) { |
|||
// return new MessageBoxUpdateEvent(((DoA8kStepActionEvent) event).actionStepName); |
|||
return null; |
|||
} |
|||
|
|||
/* |
|||
* 下面事件,均转换成 AppPromptEvents |
|||
*/ |
|||
else if (event instanceof AppWarningNotifyEvent e) { |
|||
return new AppPromptEvent(ZAppPromoptFactory.buildAppPromopt(e.error)); |
|||
} else if (event instanceof AppPromptEvent) { |
|||
return event; //前端需要显示提示信息 |
|||
} else if (event instanceof AppExceptionEvent e) { |
|||
return ZAppPromoptFactory.buildAppPromoptEvent(e.exception); |
|||
} |
|||
|
|||
/* |
|||
* 下面事件,不需要前端处理 |
|||
*/ |
|||
else if (event instanceof A8kCanBusOnConnectEvent) { |
|||
return null; //过滤,前端不需要处理 |
|||
} else if (event instanceof A8kHardwareReport) { |
|||
return null;//过滤,前端不需要处理 |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
synchronized AppEvent pollAppEventFromQueue() { |
|||
return reportAppEventQueue.poll(); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// 事件处理 |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
synchronized void tryFilterAndPushReportEvent(AppEvent event) { |
|||
AppEvent afProcessEvent = preProcessAppEvent(event); |
|||
if (afProcessEvent == null) { |
|||
return; |
|||
} |
|||
reportAppEventQueue.add(afProcessEvent); |
|||
appHistoryEventList.addFirst(afProcessEvent); |
|||
if (appHistoryEventList.size() > 50) { |
|||
appHistoryEventList.removeLast(); |
|||
} |
|||
} |
|||
|
|||
synchronized void processEventInternal(AppEvent event) { |
|||
if (event instanceof DoA8kStepActionEvent e) { |
|||
pushMessageBox(new MessageBox(MessageLevel.Info, e.actionStepName)); |
|||
} |
|||
|
|||
} |
|||
|
|||
synchronized public void onAppEvent(AppEvent event) { |
|||
tryFilterAndPushReportEvent(event); |
|||
processEventInternal(event); |
|||
} |
|||
|
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// Exposed APIs |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
synchronized public List<AppEvent> pollAllAppEvents() { |
|||
List<AppEvent> ret = new java.util.ArrayList<>(); |
|||
while (!reportAppEventQueue.isEmpty()) { |
|||
ret.add(pollAppEventFromQueue()); |
|||
} |
|||
return ret; |
|||
} |
|||
|
|||
synchronized public List<AppEvent> getAppHistoryEventList() { |
|||
return appHistoryEventList; |
|||
} |
|||
|
|||
synchronized public MessageBox getTopMessage() { |
|||
return frontEndMessageBoxState.topMessage; |
|||
} |
|||
|
|||
synchronized public List<MessageBox> getMessageBoxList() { |
|||
return frontEndMessageBoxState.messageBoxList; |
|||
} |
|||
|
|||
synchronized public void confirmPromoptInfo(String eventId) { |
|||
log.info("confirmPromoptInfo:{}", eventId); |
|||
} |
|||
|
|||
|
|||
synchronized public FrontEndMessageBoxState getMessageBoxState() { |
|||
return frontEndMessageBoxState; |
|||
} |
|||
|
|||
synchronized public void pushMessageBox(MessageBox messageBox) { |
|||
frontEndMessageBoxState.messageBoxList.addFirst(messageBox); |
|||
if (frontEndMessageBoxState.messageBoxList.size() > 30) { |
|||
frontEndMessageBoxState.messageBoxList.removeLast(); |
|||
} |
|||
frontEndMessageBoxState.topMessage = messageBox; |
|||
frontEndMessageBoxState.stateVersion++; |
|||
|
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,53 @@ |
|||
package a8k.extui.page.debug; |
|||
|
|||
import a8k.app.a8ktype.appevent.AppEvent; |
|||
import a8k.app.a8ktype.ui.MessageBox; |
|||
import a8k.app.service.bases.FrontEndMessageBoxAndEventMgr; |
|||
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 P00AppEventAndMessageBoxDebugPage { |
|||
|
|||
@Resource |
|||
FrontEndMessageBoxAndEventMgr frontEndMessageBoxAndEventMgr; |
|||
|
|||
@Resource |
|||
ExtApiPageMgr extApiPageMgr; |
|||
|
|||
@ExtApiStatu(name = "", group = "最新消息", order = 1) |
|||
synchronized public MessageBox getTopMessage() { |
|||
return frontEndMessageBoxAndEventMgr.getTopMessage(); |
|||
} |
|||
|
|||
|
|||
@ExtApiStatu(name = "", group = "历史消息列表", order = 2) |
|||
synchronized public List<MessageBox> getMessageBoxList() { |
|||
return frontEndMessageBoxAndEventMgr.getMessageBoxList(); |
|||
} |
|||
|
|||
|
|||
@ExtApiStatu(name = "", group = "历史事件列表", order = 3) |
|||
synchronized public List<AppEvent> getAppHistoryEventList() { |
|||
return frontEndMessageBoxAndEventMgr.getAppHistoryEventList(); |
|||
} |
|||
|
|||
synchronized public void confirmPromoptInfo(String eventId) { |
|||
frontEndMessageBoxAndEventMgr.confirmPromoptInfo(eventId); |
|||
} |
|||
|
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
var page = extApiPageMgr.newPage(this); |
|||
page.addFunction("Promopt确认", this::confirmPromoptInfo); |
|||
extApiPageMgr.addPage(page); |
|||
} |
|||
|
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue