Book a Demo

Author Topic: state machine guard transition  (Read 4295 times)

Seth

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
state machine guard transition
« on: February 23, 2022, 11:41:00 pm »
hey all!

i've encountered an issue in my design of a state machine wherein; it runs 1 of 2 runtimes, and i would like it that when it transitions from running routineA for instance, to completed. that if it is in the loop runtime state, it will loop back to A. but the issue i have is that since the 1 guard of IS_IN("loop runtime") is part of 2 transitions from 1 state it gets locked into that completed state.

in short is there a way i could tell it that "if it is in loop runtime state, go back to the state that you came from"?

not sure how to attach an image of the state machine to this post?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: state machine guard transition
« Reply #1 on: February 23, 2022, 11:42:35 pm »
i've attached an image of the state machine.
No you didn't  ;D

You can post an image on a public image hosting site such as imgur.com, and then post the link here.

Geert

Seth

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: state machine guard transition
« Reply #2 on: February 24, 2022, 12:55:54 am »
yeah, oops that was presumptuous... i tried to hide my shame by editing the post but didn't get it in time clearly lol...

https://imgur.com/a/0WOoIPU

hopefully that works?

you can see that routine completed needs to loop back to the routine that was executed, but ideally needs to do it from 1 IS_IN state condition as a guard. but EA understandably gets confused...

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: state machine guard transition
« Reply #3 on: February 24, 2022, 06:34:09 am »
I'm not a specialist in state machines, but if it's similar to activities then your middle states do have deadlock. They have 2 incoming edges, but only one would be fired.

q.

Seth

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: state machine guard transition
« Reply #4 on: February 24, 2022, 09:49:11 pm »
hi qwerty, that isn't the issue. the problem is that routine complete has 2 outs that both need the same condition to be executed, and because of that it never leaves the state because it doesn't know which path to take. hence i was wondering if anyone knows of a facility in EA where you can say if condition A is met, loop back to the state you come from e.g. if last state was routine A, IS_IN "loop", take the path back to A.

i

  • EA Novice
  • *
  • Posts: 13
  • Karma: +1/-0
    • View Profile
Re: state machine guard transition
« Reply #5 on: May 11, 2022, 11:12:20 pm »
What if in addition to [Runtime] and [Mode] you captured in [LastRoutine] the last routine as a state and you included that as a condition in both cases?

Otherwise you could also achieve this with a bit of Javascript setting a variable when you enter in any of those routines and then use that variable in the guard as well.
Code: [Select]
this.last_routine = "A";
This is what I've done here:


Transitions are triggered here by signals, namely: goToA, goToB, continue and end, just for simplicity sake.
In the case of the transition from Evaluate back to either Routine A or Routine B, the guard
Code: [Select]
this.last_routine == "A";allows the state machine to go back to Routine A when that condition is True at the same time the "continue" signal is triggered, and similarly in the other case.

I hope this helps :)
« Last Edit: May 11, 2022, 11:43:39 pm by i »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: state machine guard transition
« Reply #6 on: May 12, 2022, 05:51:46 am »
Shouldn't the "do" be an "entry" instead?

(I alread said I'm no SM specialist) Isn't there History state for exactly that purpose?

q.

i

  • EA Novice
  • *
  • Posts: 13
  • Karma: +1/-0
    • View Profile
Re: state machine guard transition
« Reply #7 on: May 12, 2022, 02:42:06 pm »
Hi qwerty, thanks for your comment :)

Shouldn't the "do" be an "entry" instead?
It would work as well, same as if you used the "exit" operation instead. As long as only one of these routines runs at a time it doesn't make any difference at which point (operation) the assignment is done.

Isn't there History state for exactly that purpose?
Not as far as I know, but I'm no expert either. If there's a built in history state record it would be cleaner to use it. It would be great if someone with more insight in this matter could clarify if this is possible or not.

Regards,
i.