State Diagram Code Generation

  1. I need some information about the generated code from state diagrams. What is the model behind the generated classes (you know there are classes generated I did not define in the UML diagram).

  2. Is the generated code of state diagrams executable?

  3. Is there code generated from composite structure diagrams?

  4. How can it be done to send a trigger to initiate a state transition in another class/object?

  5. Is there a runtime engine behind with the possibility of asynchronous messaging/multi threading/message queues…

  6. Is there a way to record the message flow of a running state model and to show it in sequence charts?

My questions may seem a little strange but I am used to Rhapsody from former ILogix which is well know in the area of embedded SW development. But I would like to use Visual Paradigm, the diagramming features are very nice.

thanks in advance

Hello legolas,

Thank you for your post.

  1. Actually the generated code is mainly based on your controller class and the state machine diagram which consists of states and transitions.

  2. Sure. The generated code is fully executable

  3. No, at the moment.

  4. Do you mean establishing communication between state machines? If yes, I believe that you can make use of Instant Generator to generate the relationship between the classes, and use state machine code generation to generate the state machine code.

  5. You can adjust the “Synchronized transition methods” option. I believe that you have to modify the code to satisfy multi threading/message queues.

  6. We will support runtime sequence diagram generation in the future. If you want to try, I can arrange an early access release for you.

Finally, the following movie shows you how to generate C++ state machine code:
http://www.visual-paradigm.com/product/vpuml/demos/statecode/statecpp.jsp

I hope the information has helped. Please feel free to let me know if there are any questions.

Best regards,
Jick

  1. So what are following classes, the code generater has created additionally and what is their role/task and connex:

    • FSMContext.java
    • Context.java
    • State.java
    • StateChangeListener.java
    • StateUndefinedException.java
    • TransitionUndefinedException.java
  2. I think the code is not fully executable, because it cannot be clear to the code generator which objects in which sequence have to be generated, for that it would need the composite structure diagram. From which you said no code is generated at all.?

  3. :frowning:

  4. see 5)

  5. I’d like to only define “events” in one state machine, and use them as triggers in another state machine. Everything around: asynchronous event transfer, queueing of events, threading… should be generated automatically so as it is implemented in Rhapsody. I think your tool cannot do that, right? Is it planned to be implemented in future?

  6. Would be nice to get early access, thankyou.

regards
Legolas

Hello legolas,

  1. Here are the definition of the generated files
  • FSMContext.java
    Common superclass of Context, keep track of the current state

  • Context.java
    Subclass of FSMContext, with transition methods and states defined in diagram.

  • State.java
    Class modeling a State

  • StateChangeListener.java
    Listener interface for listening state change

  • StateUndefinedException.java

  • TransitionUndefinedException.java
    Exceptions

  1. Sorry but we do not quite understand your point. Attached please find a sample we prepared for you to prove that the code is runnable. You can run the following class to start the application:
    sample/ui/PhoneControllerFrame

4, 5) We do not understand your need. Which kind of source code (Java, C++…) do you want to generate?

  1. We will get back to you on this matter as soon as possible.

Best regards,
Jick
state-code-generation-sample.zip