Author Topic: Communication between Statemachines?  (Read 6785 times)

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Communication between Statemachines?
« on: May 02, 2013, 07:01:14 am »
Is bidirectional communication between statemachines in simulation possible?

I have tried to establish such a communication but i could not succeed.

Example: I have a Statemachine(x) and i call an another statemachine(y) in a state(x.a) of statemachine(x).Statemachine(y) execute sand  sends a signal(BroadcastSignal in state y.a) to statemachine(x) and the transition in statemachine(x.a to x.b) is triggered with this signal. Now Statemachine(y) is in state(y.a)and waiting for a signal to go to state(y.b). Statemachine(x in x.b) boradcasts a signal that should have been received by statemachine(y) but it does not.So the signal is lost and the statemachin(x) terminates.

So from this example i get the result that just a caller can receive a signal from called behaviour. But the called behaviour can not receive a signal from its caller.

Is there any possibility to establish such a connection? Can signals be send via classifiers with defined targets? Because both SendSignal action in activity diagrams and BroadcastSignal do not specifiy any special target behaviour that should receive the signal.

Any answer would be really helpful since Enterprise Architect is one of the software that  i evaluate the simulation capabilities in terms of my university thesis.

thanks in advance, Kesen

Statemachine1

Statemachine2
« Last Edit: May 02, 2013, 06:57:33 pm by yck »

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #1 on: May 02, 2013, 03:50:40 pm »
Given the complexity of the text presented it might help to add an image of the proposed diagram. There is a lot more chance you will get feedback from that.
Also I suggest you check the options covered in the EAExamle model under:
Project Models.Model Simulation.Activity Models.Sending Signal.Sending Signals.Sending Signals

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #2 on: May 02, 2013, 06:51:25 pm »
Thanks for the answer. I have already checked the example but its a very simple example since the signals will be sent in the same diagram.


so i upload 2 pictures describing the situation.

Actually the only question is = Can a state machine(x) send a signal to another statemache(y). If y is started as a behaviour from statemachine(x). Or can just statemachine(y) can send a signal to statemachine(x)?

« Last Edit: May 02, 2013, 06:57:16 pm by yck »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #3 on: May 03, 2013, 09:06:25 am »
Yes, they can.

The trick is to start the two state machines in the same simulation. The easiest way to do that is to have a launcher state machine that contains a subMachineState for both of the machines you want to communicate.

I have an example I just made (one machine broadcasting a tick, the other a tock and it looping between the two.) If you want to contact Sparx Systems support I can ensure that you get it.

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #4 on: May 03, 2013, 07:03:59 pm »
hey thanks for the answer.I have written to [email protected].

What do you mean exactly "a substatemachine for both of the machines you want to communicate"? so i should have a state machine(x) that launches this two machines(a,b) and each statemachine(a,b) from a substatemachine in x? Is the order of substatemachines relevant?


So it is not possible in the case that i have described? But only in the case you have described?

Thanks!
« Last Edit: May 03, 2013, 07:12:11 pm by yck »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #5 on: May 06, 2013, 08:36:24 am »
Two (or more) state machines can communicate, but only if they are both running in the same simulation. In order to do that you need to initially start a setup behavior of some sort. You could do that with an activity that has two CallBehaviorActions or a subMachineState (which just means that the internal behavior of that state is specified by an external state machine)

I'm not sure I understand how that isn't what you want.

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #6 on: May 07, 2013, 06:28:32 am »
Quote
Two (or more) state machines can communicate, but only if they are both running in the same simulation. In order to do that you need to initially start a setup behavior of some sort. You could do that with an activity that has two CallBehaviorActions or a subMachineState (which just means that the internal behavior of that state is specified by an external state machine)

I'm not sure I understand how that isn't what you want.

thanks, i get what you mean. But that is not what i want :-/

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #7 on: May 07, 2013, 10:14:33 am »
So, what is it that you want?

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #8 on: May 07, 2013, 08:27:17 pm »
Quote
So, what is it that you want?


A statemachine(x) calls a statemachine (y). Can the statemachine x send a signal to statemachine y ?

In this case y can send a signal to x. But a signal sent by x can not received by state machine y.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #9 on: May 08, 2013, 09:30:14 am »
There is no distinction between X and Y as which was originally called except when exiting. Yes, you can broadcast messages picked up by the calling state machine.
« Last Edit: May 08, 2013, 09:31:02 am by simonm »

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #10 on: May 08, 2013, 11:50:09 pm »
Quote
There is no distinction between X and Y as which was originally called except when exiting. Yes, you can broadcast messages picked up by the calling state machine.

Here is again what i mean: a callee sends a signal to to its caller and the caller soes to next state.In same time the calle waits for a signal x. But this signal can not be activated from the caller.

As in the exemple in the first post. State machine 1 can not fire any trigger in statemachine 2. Those activate 1 and activate 2 must be triggered manually although the satet machine 1 broadcasts them. If it is possible and i can not model it, can you maybe show me an example showing the same case?
« Last Edit: May 08, 2013, 11:54:07 pm by yck »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #11 on: May 10, 2013, 08:35:55 am »
I believe that your problem is using the second state machine as entry behavior of a state. If you used a subMachineState (drag from the project browser while holding control and select instance) I think it would work.

yck

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Communication between Statemachines?
« Reply #12 on: May 17, 2013, 06:58:45 am »
Quote
I believe that your problem is using the second state machine as entry behavior of a state. If you used a subMachineState (drag from the project browser while holding control and select instance) I think it would work.

Yes i want to simulate it as a entry state behaviour but not as a substatemachine. It is clear for me that it works if i model it as a substatemachine.Since I want to evaluate the simulation semantic/syntax of EA. Such as :in which cases does a simulation work, in which cases can the diagrams can communicate and how. But i think as long as i use it as an entry state behaviour the broadcastsignal command just works in one way.direction callee to caller.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Communication between Statemachines?
« Reply #13 on: May 17, 2013, 02:45:16 pm »
As far as I understand it, EA treats an entry or exit behavior as atomic in terms of the calling machine.