2using System.Collections.Generic;
4using System.Threading.Tasks;
14 private readonly List<ITriggerNode> triggers =
new List<ITriggerNode>();
51 if (this.timeout is
null)
54 throw new Exception(
"A timeout has already been defined.");
57 this.triggers.Add(Node);
67 int i, c = this.triggers.Count;
69 throw new Exception(
"No triggers defined.");
73 if (!(this.timeout is
null))
76 Task[] Tasks =
new Task[d];
78 for (i = 0; i < c; i++)
79 Tasks[i] = this.triggers[i].GetTask();
81 if (!(this.timeout is
null))
82 Tasks[c] = this.timeout.
GetTask();
84 Task Result = await Task.WhenAny(Tasks);
85 i = Array.IndexOf<Task>(Tasks, Result);
88 throw new Exception(
"Unexpected error.");
91 await this.triggers[i].Execute(
Variables);
104 public override void ExportPlantUml(StreamWriter Output,
int Indentation,
char QuoteChar)
106 Indent(Output, Indentation);
107 Output.WriteLine(
":Wait for first:;");
108 Indent(Output, Indentation);
120 Indent(Output, Indentation);
121 Output.WriteLine(
"end split");
Root node of a simulation model
Abstract base class for activity nodes
Adds a timeout limit in a Wait statement.
Task GetTask()
Gets a task object.
override async Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
Conditional execution in an activity, based on external events.
override async Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
override string LocalName
Local name of XML element defining contents of class.
void Register(ITriggerNode Node)
Register a trigger node.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
override void ExportPlantUml(StreamWriter Output, int Indentation, char QuoteChar)
Exports PlantUML
Wait(ISimulationNode Parent, Model Model)
Conditional execution in an activity, based on external events.
static void Indent(StreamWriter Output, int Indentation)
Adds indentation to the current row.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Interface for trigger nodes
void ExportPlantUml(StreamWriter Output, int Indentation, bool First, char QuoteChar)
Exports PlantUML