2017-09-14 180 views
1

鏈接到項目測試
的Payprus文件被here上<a href="https://github.com/joergi/uml-spring-state-machine/" rel="nofollow noreferrer">github</a>使用2個不同的紙莎草UMLstatemachines與彈簧的statemachine項目

我試圖做一個狀態機與Papyrus。狀態機應該兩個單狀態機結合起來,一個,你可以第一個圖像中看到: State Machine Top

機1在第二圖像和狀態機2所定義的狀態,在第3畫面 定義State Machine 1 State Machine 2

我消耗了UML與我的Spring應用程序(向下滾動碼)

我試圖與一個真正簡單的單一狀態機(所以只有像狀態機1,但最初和最後的點),它的工作完美,System.out.println()正在編寫整個代碼。

但隨着這2條狀態機,該機在在top_initalTOP開始,然後進入top_s1。這是預料和工作

比我預想到topExitPoint1到對面的sm1EntryPoint - >進入StateMachine1 - >比StateMachine2 - >回頂部等。

但不幸的是在我的機器,其使用了唯一的國家一直是一個在頂部 - >的top_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.s[email protected]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.spring[email protected]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.s[email protected]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 

我嘗試了很多事情紙莎草改變這種行爲,但沒有任何變化。 會很酷,如果有人可以看看它,也許知道如何提供幫助。

這裏是Java代碼:我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()); 
      } 
     }; 
    } 
} 

如果你想看到的模型瀏覽器中的樣子:

mode-explorer

+0

我想我需要嘗試你的項目,但我不知道該模型是如何有效的,因爲有沒有機器啓動的初始狀態。即使在「頂部」狀態下,其右側區域也缺少初始狀態。只是現在這個評論,直到我去嘗試它。 –

+0

嗨@JanneValkealahti,感謝您的評論。在*左*側* TOP *中有一個初始狀態。比它應該(據我瞭解UML和狀態機)再往* StateMachine1 *爲切入點和* StateMachine2 *和* TOP右側*最終在* TopFinalState * * StateMachine1 *和* StateMachine2 *不應該單獨啓動 - 只需進入EntryPoint並通過退出點離開。 是否有比* StateMachine1 *和* StateMachine2 *所需的初始點? – Joerg

+0

我不得不問,你是如何在頂級機器之外添加其他狀態機的?我現在可以看到這個,當我打開這個紙莎草紙,但我不能在頂部之外創建任何東西。 –

回答

相關問題