【发布时间】:2016-05-19 07:36:58
【问题描述】:
我正在尝试为附加的状态图构建配置。 问题是我无法将入口操作注册到分叉内区域中的状态。 即对于状态 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 和 task 2 step1 的状态为 task3 和 task 4 step0 应该在并行区域 task1 和 task2 完成执行时完成。 step1 应该在并行区域 task3 和 task4 完成执行时完成。 实际上task1,task2,task3,task4这四个状态都应该并行执行
如果 step0 和 step2 完成,则 S1 完成。
只有在完成所有并行状态后才会发生从 S1 到 S2 的转换 即 (step0(task1 & task 2) and step2 (task3 and task4))
另外请注意,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 中的所有并行任务(即 task1,task2,task3,task4)之后发生。
【问题讨论】:
-
在我进一步查看之前,您是否尝试在父级别使用
.initial("S41").state("S41",null,null)或可能的.state("S41",null,null)为S41定义操作?下周正式发布的 1.1.x 也做了很多修复。 -
谢谢!它奏效了。
-
我已经更新了问题。感谢任何帮助