Question

This question is a bit philosophical and is like "data and code are the same thing or not".

Is there any clear difference between event (signal) and state?

Example:

For example, there is a car passing by the road. When the car horns, a man (man_A) crossing the road stops suddenly. Horn is the signal, "man_A stops suddenly" is the state of man_A.

Another man (man_B) was crossing the road too at the same time, at the same place.

Let's consider that man_B was deaf, so he can't hear the horn. But realizing "man_A stopped suddenly" would be a signal for him. He would stop suddenly as if he heard the horn.

So I would say "A state could be a signal for another process. A signal puts a process another state. That's why they are exactly the same thing"

Am I wrong, is there a clear difference between them?

A signal is a state change. We may define any signal with two states.

Was it helpful?

Solution

Well, a state is not a signal because a signal comes at a certain specific point in time.

A state-change is a result of a signal and can be seen as a signal by itsself. But it is not the state itsself. The state continues to be after the signal is long gone.

How would the initial state be a signal, for example.

OTHER TIPS

They are very, very different:

  • The same event may cause transitions to different states, depending on the current state:
    Three states with transitions between them, triggered by the same event

  • In SCXML you can have <parallel> states defining orthogonal regions. In this case a single event may trigger multiple simultaneous transitions to different states:
    enter image description here

  • Further, due to the possible presence of cond="…" attributes, a transition to another state may or may not occur when triggered by a an event. So now we have an event that might not change state.

  • Further, it is possible to have a transition with no event attribute, causing a state change as soon as some data model value or script result is right. So now we have a state change that can take place with no triggering event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top