Author Topic: State Machine: Changing guard condition variable via trigger  (Read 7645 times)

servic

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Sorry for the very basic question, but since I already spent the whole day trying to figure this out, I will now try my luck on this forum.

-Is there a way to change a value of a guard condition further down the State Machine (SysML 1.4) via a trigger?

Say:
(State1)--trigger1:{run=true}--> (State2)--[run]-->(State3)

I tried the "Change" and "Signal" triggers, but all of the variables do not seem to have any effect on the Guard statement...

Thanks a lot for your help!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #1 on: June 22, 2016, 09:13:22 am »
No, you can't change a guard from a trigger. You change a member variable so that the guard expression now evaluates to true.

servic

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #2 on: June 22, 2016, 05:02:35 pm »
Thank you Simon for the fast reply. As I read your reply it seems to me that the former sentence may contradict the latter one.
Could you please be more specific?
"You [would thereby] change a member variable so that the guard expression now evaluates to true [which is not permitted by bla-bla convention]."
or
"[But] You [can] change a member variable so that the guard expression now evaluates to true."

As I mentioned, I tried to change the variables using e.g. the Signal Trigger. I manually enter run=true during the simulation, but the Guard of the transition further down the flow still complains with the "ReferenceError: run is not defined". I would very much appreciate if you could help me here and sorry once again for the babysitting. How do  I change this variable so that it works?

servic

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #3 on: June 22, 2016, 06:35:59 pm »
Ok, it seems it is only possible to assign a variable to a transition itself (aka "effect"), but not to a trigger variable in order to change the guard transition, if I understood it correctly.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #4 on: June 23, 2016, 01:04:04 pm »
I was making a distinction between the guard, which is a static expression that won't change during the course of a simulation and the variables that it is evaluating.

Have you looked at the state machine simulation examples in the example model?

servic

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #5 on: June 23, 2016, 05:29:05 pm »
Yes, everything I found so far was: "Playlist Maintence", "DSP Effects", "On" and the SM with "Init, Running and Stopped". If there as an another useful exemple, please let me know. All these SM's can only be executed in Manual mode, their execution in the Interpreted mode fails because the guard conditions are not defined anywhere. We need to define what we mean with variables though. So if I set those "variables" (?) to true within the "Effect" window of some transition before, it works.

But my question was a bit different. If I simply define these variables somewhere early and want to test my State Machine using a range of parameters, I have to define a separate Transitions+Triggers+Effects to change the guard handling further down the simulation. So if I have a simple guard condition x>5, only for that I need two transitions, two triggers, and two Effects (x=3 and x=7) to test the guard. It looks less transparent with all that many transitions I have to put in place.  I thought one could use those variables that are defined in "Attributes" somehow...
They are of no use here, right? Or maybe I can change the guard variables using those values defined in Attributes and Operations?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #6 on: June 24, 2016, 09:47:31 am »
None of those are the ones I was thinking of. The following are all designed for interpreted simulation and demonstrate different behavior.

Project Model.Model Simulation.State Machine Models.Traffic Lights.TrafficLightController.Pedestrian Crossing.Pedestrian Crossing
Shows setting  variables in entry/exit and transitions and checking variables in guards.

Project Model.Model Simulation.State Machine Models.Customer Login.Customer.Customer Login
Shows using a dialog defined in EA, signals with parameters and guards using those parameters.

Project Model.Model Simulation.State Machine Models.Music Player.MusicPlayer.PlayerState.PlayerState
Shows calling an activity, concurrent states, submachine states, signals/triggers, guards checking variables and guards checking the current state.

servic

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: State Machine: Changing guard condition variable via trigger
« Reply #7 on: June 27, 2016, 05:08:32 am »
Thank you Simon for your help! I will check them up.