github
用于测试
Payprus文件是
here
Papyrus
. 状态机应该将两个单状态机合并为一个,如第一幅图所示:
状态机1在第2张图中定义,状态机2在第3张图中定义
我正在使用spring应用程序的UML(向下滚动查看代码)
System.out.println()
正在编写整个代码。
但是有了这两个状态机,机器在
在
. 这是意料之中的事情,而且正在发挥作用
比我预期的要多
顶部出口点1
到
SM1入口点
状态机1
状态机2
-&燃气轮机;返回到
等等
但不幸的是,我的机器中唯一被使用的状态是
-&燃气轮机;这个
顶部s1
状态
控制台日志仅显示以下内容:
2017-09-14 17:41:42.002 INFO 25414 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-14 17:41:42.008 INFO 25414 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
State change to top_s1
2017-09-14 17:41:42.070 INFO 25414 --- [ main] o.s.s.support.LifecycleObjectSupport : started org.springframework.statemachine.support.DefaultStateMachineExecutor@4afd21c6
2017-09-14 17:41:42.070 INFO 25414 --- [ main] o.s.s.support.LifecycleObjectSupport : started top_s1 topFinalState top_r2_s1 top_s2 top_FinalState1 sm2_s1 sm2_s2 sm1_s2 sm1_s1 / top_s1 / uuid=e3a76fb9-5d3f-46b2-9c01-17d23eabedea / id=null
2017-09-14 17:41:42.071 INFO 25414 --- [ main] d.j.u.UmlSpringStateMachineApplication : Started UmlSpringStateMachineApplication in 2.584 seconds (JVM running for 2.85)
2017-09-14 17:41:42.073 INFO 25414 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1e4a7dd4: startup date [Thu Sep 14 17:41:39 CEST 2017]; root of context hierarchy
2017-09-14 17:41:42.076 INFO 25414 --- [ Thread-3] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2017-09-14 17:41:42.077 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : stopped org.springframework.statemachine.support.DefaultStateMachineExecutor@4afd21c6
2017-09-14 17:41:42.078 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : stopped top_s1 topFinalState top_r2_s1 top_s2 top_FinalState1 sm2_s1 sm2_s2 sm1_s2 sm1_s1 / / uuid=e3a76fb9-5d3f-46b2-9c01-17d23eabedea / id=null
2017-09-14 17:41:42.078 INFO 25414 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-09-14 17:41:42.079 INFO 25414 --- [ Thread-3] o.s.s.support.LifecycleObjectSupport : destroy called
如果有人能看一下,也许知道如何帮助,那就太酷了。
UmlSpringStateMachineApplication
package de.joergi.umlspringstatemachine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.statemachine.StateMachine;
@SpringBootApplication
public class UmlSpringStateMachineApplication implements CommandLineRunner {
@Autowired
private StateMachine<String, String> stateMachine;
public static void main(String[] args) {
SpringApplication.run(UmlSpringStateMachineApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
stateMachine.start();
}
}
还有我的
StateMachineConfig
看起来像这样:
package de.joergi.umlspringstatemachine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer;
import org.springframework.statemachine.config.builders.StateMachineModelConfigurer;
import org.springframework.statemachine.config.model.StateMachineModelFactory;
import org.springframework.statemachine.listener.StateMachineListener;
import org.springframework.statemachine.listener.StateMachineListenerAdapter;
import org.springframework.statemachine.state.State;
import org.springframework.statemachine.uml.UmlStateMachineModelFactory;
@Configuration
@EnableStateMachine
public class StateMachineConfig extends StateMachineConfigurerAdapter<String, String> {
@Override
public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
config.withConfiguration().autoStartup(false).listener(listener());
}
@Override
public void configure(StateMachineModelConfigurer<String, String> model) throws Exception {
model.
withModel().factory(modelFactoryStateMachine());
}
@Bean
public StateMachineModelFactory<String, String> modelFactoryStateMachine() {
return new UmlStateMachineModelFactory("classpath:papyrus/new_test.uml");
}
@Bean
public StateMachineListener<String, String> listener() {
return new StateMachineListenerAdapter<String, String>() {
@Override
public void stateChanged(State<String, String> from, State<String, String> to) {
System.out.println("State change to " + to.getId());
}
};
}
}
如果要查看模型资源管理器的外观: