Hello !
I have just different statemachines to mange state for one object [computer]. I just learned the basics.
Now, I feel, this is too complex and a much better fit would be to use a real hierarchical statemachine.
But I dont find an expressive way to define the states. There is nothing like "hirerachical enums". The
PhoneCall sample is just very raw for this. My first attempt is to use a enmum like this:
{ New, Animating_PingOk, Animating_PingFailed, Connecting_ConnectOk, Connecting_ConnectFailed, ....Disabled }
where New, Animating_* [!!], Connecting_* express my toplevel states, where the identifier part after
the underscore shows the substate. I feel not good with this, but I am not finding an alternative.
I've tried classes and subsclasses and failed. My last attempt was this:
public class States
{
public enum New {};
public enum Animating { PingOk, PingFailed };
public enum Connecting { ConnectionOk, ConnectionFailed };
public enum Operating { Working, Failed };
public enum Failed {};
}
but I failed to configure:
this.states = new States();
this.sm = new StateMachine<States, Trigger2>(this.states);
this.sm.Configure(this.states)
.Permit(Trigger2.Animating_PingOk, this.states.Operating ); <== error [tried first: Operating.Working].
I really dont understand the statmachine definition. VS shows me:
class Stateless.StateMachine<
TStateI am looking for samples, how to express this. Enums are really easy to understand.
The documentation says this:
"Generic support for states and triggers of any .NET type (numbers, strings, enums, etc.) "
I am stuck here. If someone probably has a little moment and can give me a hint, that
would be really great!
Thanks anyway and best regards,
++mabra