我试图为附加的状态图构建一个配置。问题是我无法将入口操作注册到分叉内区域中的状态。即对于状态 S41、S41E、S42、S42E。
配置如下所示。
Builder builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.autoStartup(false).listener(listener()).taskExecutor(taskExecutor());
builder.configureStates().withStates().initial("S1", ActionFactory.getAction("S1EntryAction"))
.fork("FORK_STATE")
.join("JOIN_STATE")
.state("S4")
.state("S2", ActionFactory.getAction("S2EntryAction"), null)
.state("S3", ActionFactory.getAction("S3EntryAction"), null)
.state("S5", ActionFactory.getAction("S5EntryAction"), null)
.state("S6", ActionFactory.getAction("S6EntryAction"), null)
.state("S7", ActionFactory.getAction("S7EntryAction"), null)
.and().withStates().parent("S4").initial("S41").end("S41E")
.and().withStates().parent("S4").initial("S42").end("S42E");
builder.configureTransitions()
.withExternal().source("S1").target("S2")
.and().withExternal().source("S2").target("S3")
.and().withExternal().source("S3").target("FORK_STATE")
.and().withFork().source("FORK_STATE").target("S4")
.and().withExternal().source("S41").target("S41E")
.and().withExternal().source("S42").target("S42E")
.and().withJoin().source("S4").target("JOIN_STATE")
.and().withExternal().source("JOIN_STATE").target("S5")
.and().withExternal().source("S5").target("S6")
.and().withExternal().source("S6").target("S7");
return builder.build();
另一项帮助。在上面的状态机配置中,每个状态都有嵌套的状态机。
S1 有 step0 和 step1。两者都是正交的 step0 具有状态 task1 并且任务 2 step1 具有状态 task3 并且任务 4 step0 应该在并行区域 task1 和 task2 完成其执行时完成。step1 应该在并行区域 task3 和 task4 完成执行时完成。事实上,task1、task2、task3、task4 这四个状态都应该并行执行
如果 step0 和 step2 完成,则 S1 完成。
从 S1 到 S2 的转换只会在完成所有并行状态后发生,即(步骤 0(任务 1 和任务 2)和步骤 2(任务 3 和任务 4))
另请注意,S1 是我的配置的初始状态。
我已经更新了状态配置,如下所示
.and().withStates().parent("S1")
.initial("Step0")
.and().withStates().parent("Step0")
.initial("task1", dummyAction1())
.and().withStates().parent("Step0")
.initial("task2", dummyAction2())
.and().withStates().parent("S1")
.initial("Step1")
.and().withStates().parent("Step1")
.initial("task3", dummyAction3())
.and().withStates().parent("Step1")
.initial("task4", dummyAction4())
.and().withStates().parent("S2")
.initial("Step01")
.and().withStates().parent("Step01")
.initial("task5", dummyAction3())
.and().withStates().parent("Step01")
.initial("task6", dummyAction4())
.and().withStates().parent("S2")
.initial("Step11")
.and().withStates().parent("Step11")
.initial("task7", dummyAction3())
.and().withStates().parent("Step11")
.initial("task8", dummyAction4())
如何配置从 S1 到 S2 的转换?(S1 是初始状态,S1 到 S2 应该在完成 S1 中的所有并行任务(即任务 1、任务 2、任务 3、任务 4)之后发生。