2using System.Threading.Tasks;
86 public override Task
Parse(XmlElement Xml)
92 return base.Parse(Xml);
100 base.OnChildNodesUpdated();
102 this.@
event = this.GetChildElement<EventNode>(
true);
111 if (this.newState.
IsConstant && !
this.newState.IsEmpty && !Machine.
TryGetState(
this.newState.Definition, out
_))
114 if (this.failureState.
IsConstant && !
this.failureState.IsEmpty && !Machine.
TryGetState(
this.failureState.Definition, out
_))
117 base.CheckReferences(Machine,
Token);
127 if (this.newState?.IsEmpty ??
true)
140 if (this.failureState?.IsEmpty ??
true)
153 if (this.suppressSample?.IsEmpty ??
true)
199 if (this.@event is
null)
202 return await this.@
event.Register(EventIndex, Arguments,
this);
212 return this.@
event?.Unregister(EventIndex, Arguments) ?? Task.CompletedTask;
223 if (this.@event is
null)
226 return await this.@
event.StateUpdated(Arguments);
236 if (this.@event is
null)
237 return Task.FromResult(
true);
239 return this.@
event.Applies(Arguments);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Exception related to state machine.
Abstract base class for nodes referencing an action.
bool IsEmpty
If the definition is empty.
bool IsExpression
If the attribute value is an expression.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
bool IsConstant
If the attribute value is a constant.
string Definition
Attribute definition
Scriptable Boolean attribute.
Scriptable string attribute.
Contains information required for evaluating script in a state-machine.
Variables Variables
Current set of variables.
Represents an event definition.
Abstract base class for State-Machine event nodes.
Action executed when entering a state.
bool HasFailureStateExpression
If the failure state is defined by an expression
bool HasFailureStateConstant
If the failure state is defined by a constant
Task Unregister(int EventIndex, EvaluationArguments Arguments)
Registers the event
string NewStateDefinition
New State Definition
override IStateMachineNode Create()
Creates a new node of the corresponding type.
override void OnChildNodesUpdated()
Method called whenever ChildNodes is updated.
async Task< bool > GetSuppressSample(EvaluationArguments Arguments)
Gets a Boolean value indicating if samples should be suppressed for the event.
override string LocalName
Local name
bool HasNewStateConstant
If the new state is defined by a constant
string FailureStateDefinition
Failure State Definition
bool HasFailureState
If the event defines a failure state.
bool HasNewStateExpression
If the new state is defined by an expression
async Task< EventHandlerReference > Register(int EventIndex, EvaluationArguments Arguments)
Registers the event
override Task Parse(XmlElement Xml)
Parses the State-machine node.
virtual Task< bool > Applies(EvaluationArguments Arguments)
If the event node applies to the current context.
async Task< string > GetFailureState(EvaluationArguments Arguments)
Gets the failure state ID when the event is triggered.
async Task< EventHandlerReference > StateUpdated(EvaluationArguments Arguments)
Method called when the internal state of the state-machine has been updated.
OnEvent()
Action executed when entering a state.
override void CheckReferences(StateMachine Machine, Token Token)
Checks references in the node.
bool HasNewState
If the event defines a new state.
string SuppressSampleDefinition
Suppress Sample Definition
async Task< string > GetNewState(EvaluationArguments Arguments)
Gets the new state ID when the event is triggered.
Class representing a state machine.
bool TryGetState(string Id, out State State)
Tries to get a state.
Interface for State-Machine nodes