Comments (7)
Dear Thomas,
thanks for the answer. I'm still not sure since in the SCXML spec, at the link I provided, you can read (excerpt)
To simplify the following definitions, we introduce the event NULL. NULL has no name and is used only in these definitions. It never occurs in the event queues of an SCXML Processor. All other events have names and are distinct from NULL. (In effect, NULL is a pseudo-event that is used in these definitions as a trigger for eventless transitions.)
A transition is enabled by NULL in atomic state S if a) T lacks an 'event' attribute, and b) T's source state is S or an ancestor of S and c) T lacks an 'cond' attribute or its 'cond' attribute evaluates to "true". (Note that such a transition can never be enabled by any named event.)]
[Definition: A microstep consists of the execution of the transitions in an optimal enabled transition set.]
From this I understood that it should be fired. Also in Rhapsody since "The low-to-high transition of the condition (or Boolean value) is considered to be the triggering event" then the bold part of your comment should also encompass the low-to-high transition of the condition.
I know I can use CycleBased
but it introduces delays due to sampling time.
Finally, the very same model in the SCXML Qt editor (https://doc.qt.io/qt-5/qtscxml-index.html) provides a different result (it ends in stateB
from statecharts.
Providing triggers derived from variable changes makes sense. Here is an excerpt of an internal task (which is not scheduled yet):
In addition to events statecharts define a set of state variables in their interface. Changes to these variables should be considered as events wich are processed according to the existing event execution semantics.
To be backwards compatible and provide a consistent definition inion of semantics the following issues are considered:
- changing or 'overloading' existing guard only transition semantics is not desired
- change triggers must be specified explicitly
- the extension must be consistent with existing language concepts
Two approaches are possible:
- specify trigger property on declaration:
@trigger var x : integer
- specify change trigger on transition:
x@changed [x > 100] / doSomething()
As an extension to the second alternative also change events on expression could be implemented:
(x > 100)@changed
(x > 100)@becomes(true)
from statecharts.
From my understanding, Yakindu does not behave differently from SCXML nor Rhapsody in that regard.
Setting a variable is not triggering a run-to-completion step (or what is called macrostep in the SCXML doc). I think the Rhapsody documentation is just not clear in their wording. They also say "...all guards without triggers are tested every time an event happens". And further down, "Each time this event occurs, the state machine evaluates the two guards...". Omitting the event on the transition just means that it is checked for every event that occurs, but it still needs some event to occur.
For me, this indicates the same behavior as in the @EventDriven
mode of Yakindu.
If you don't want to have events triggering a run-to-completion step, you can use the @CycleBased
mode to have it triggered periodically.
from statecharts.
Okay, I read the SCXML docs again and my understanding now is that event-less (NULL) transitions are taken at the end of a macrostep when all other events are consumed. Consider this example:
When myEvent
is invoked, StateB gets active, and then all event-less transitions are checked, making the state machine go to StateC. Same holds for your example, as the event-less transitions are also checked after the initial state is activated.
What I do not read out in the specification is that merely changing the value is also considered to trigger a macrostep.
In Rhapsody, things might be different. I don't know enough about Rhapsody, but it is possible that changing a property value is considered being an event that triggers a step.
So yes, Yakindu behaves differently. In @EventDriven
mode, the state machine does only react to events (or time triggers). Having an event-less transition is the same as putting the always
trigger on the event, which makes it react to every event that is processed. But just changing a property value is not considered to be an event.
That said, you can do the following to get closer to the desired behavior:
If you want to have SCXML code and behavior in the end, you can use the SCXML domain. The simulation will then invoke an SCXML interpreter.
If you want to generate Java code, you can consider enabling super steps semantics with @SuperSteps(yes)
. The behavior will be still different than what is specified by SCXML or Rhapsody, but your and my example models would end up in the desired states.
from statecharts.
Dear Thomas,
thanks for the clear explanations. I'll read about superstep semantics.
A last minor question to see if it is a workaround. Considering changing a value in an event-less guard from the code (the setter from the SCInterface). Is it safe to explicitly invoke the runcycle()
method after the value setter ? In this case it somehow acts as a trigger from the value change; and the behavior is the expected one.
thanks again
from statecharts.
Yes, that sounds like a valid workaround for me.
However, in the recent version of Yakindu, we changed the APIs, so that runCycle() is no more visible from the outside for event-driven statecharts (only for cycle-based ones). So probably you will be able to do it only with 3.x. versions, and not with the 4.x version.
from statecharts.
thanks for the complementary answer. This is quite interesting.
just a personal feeling:
At a first glance it seems to me that specifying the annotation in the interface is more intuitive and make the state chart simpler (and more classical) to read. Consequently, it means that every usage of the variable is subject to "guard only" transition and of course that every expression where it is used is also concerned.
I'm not sure if there are situations where this is not the case and where we want to choose transition by transition the semantics to be applied. It is also worth noticing that in this case it seems that we can always specify explicitly the trigger (e.g., every Xms [x > 0]
)
my two cents
from statecharts.
Related Issues (20)
- [Homepage] Code formatting is broken on home page HOT 1
- [Homepage] Move/Remove docu + social buttons HOT 1
- [C/C++] Add compiler flags
- [C Generator] Typed observables HOT 1
- [C] Support pointer for observables
- License feature missing HOT 1
- Domain com.yakindu.domain.scxml is not available SCXML export bug HOT 2
- Eclipse 2020-09 + 2.9.3 Community Edition -> broken Java Code generation HOT 1
- Why is a composite state required to have a default initial pseudostate? HOT 1
- python code generator ease of use enhancements HOT 5
- Error in language reference regarding final states HOT 1
- Missing documentation of behavior of events in guards HOT 2
- Copy / paste of state(s) not working in version 4 HOT 3
- Named entry/exit equivalent in UML HOT 1
- Python code generator doesn't support hyphens in folder names HOT 4
- semantics precision on final nodes in orthogonal regions HOT 3
- Connection to github HOT 2
- Support final states in active() checks
- Support 'done' checks for SCXML statecharts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from statecharts.