Book a Demo

Author Topic: State Machine Code Generation  (Read 5961 times)

weh

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
State Machine Code Generation
« on: December 04, 2015, 01:36:16 am »
Hi,

I'm currently investigating the code generation of state machines in C#. Here are my questions so far:
  • At first look the produced code looks a little bit confusing. Is there a special pattern behind? Is the code for simulation uses only?
  • Is there a way to use triggers with parameters?  
  • Is there a code example without the simulation class with its string event parsing stuff?

Thank you


« Last Edit: December 04, 2015, 01:43:35 am by wernerhu »

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: State Machine Code Generation
« Reply #1 on: December 04, 2015, 08:47:59 am »
1. The Statemachine defined in UML Specification is complicated. Rather than focus on "toy" examples (e.g. simple state); EA produced code fully conform to the Spec and it is executable.

The simulation is actually a visual debug (step) of the code running at the behind.

If you likes to read the code, it would be easier if you have a full trace the debug process.

2. Create Signal Event; then the attributes of the signal can be used as parameters of trigger. E.g. you can use them in transition guard, change the run-time value of these attributes in the transition's behavior.

3. More details?

Hope that helps
MMA

weh

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: State Machine Code Generation
« Reply #2 on: December 08, 2015, 09:07:04 pm »
Ok. Thanks. I got it running with the signal event arguments. However in the guard condition I have to access the signal like that: ((MySignal)_event.signal).Arg1==2
Is this the proper way? Or can I somehow access the Argument Arg1 directly?

With pattern I thought about extended state design pattern or state table or something like that.

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: State Machine Code Generation
« Reply #3 on: December 09, 2015, 09:25:46 am »
Quote
Ok. Thanks. I got it running with the signal event arguments. However in the guard condition I have to access the signal like that: ((MySignal)_event.signal).Arg1==2
Is this the proper way?

You are correct.

At least you need the word "MySignal" and "Arg1" to appear in the expression; then the actual expression didn't add too much on the basic ;)

weh

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: State Machine Code Generation
« Reply #4 on: December 16, 2015, 08:50:36 pm »
There's no option accessing the argument in the gui?
So you have to look into the generated code first to know that the signal parameter is called _event? That's ... great!