2using System.Collections.Generic;
5using System.Threading.Tasks;
18 private LinkedList<IActivityNode> activityNodes =
null;
19 private LinkedList<IEvent> events =
null;
21 private int executionCount = 0;
22 private bool logStart;
38 public string Id => this.id;
75 public override Task
FromXml(XmlElement Definition)
78 this.logStart =
XML.
Attribute(Definition,
"logStart",
true);
81 return base.FromXml(Definition);
90 return base.Initialize();
99 if (this.activityNodes is
null)
100 this.activityNodes =
new LinkedList<IActivityNode>();
111 if (this.events is
null)
112 this.events =
new LinkedList<IEvent>();
114 this.events.AddLast(
Event);
123 this.executionCount++;
125 if (!(this.activityNodes is
null))
145 LinkedListNode<IActivityNode> Next;
147 while (!(
Start is
null))
163 Output.WriteLine(this.
id);
164 Output.WriteLine(
new string(
'-', this.
id.Length + 3));
167 await base.ExportMarkdown(Output);
169 Output.WriteLine(
"```uml: Use Case chart for " + this.
id);
170 Output.WriteLine(
"@startuml");
174 if (!(this.events is
null))
180 Output.Write(
"usecase UC");
181 Output.Write((++Index).ToString());
182 Output.Write(
" as \"");
183 Output.Write(this.
id);
185 if (!
string.IsNullOrEmpty(Desc))
188 Output.WriteLine(
"==");
189 Output.Write(BreakWords(Desc, 25));
192 Output.WriteLine(
"\"");
200 Output.Write(
"usecase \"");
201 Output.Write(this.
id);
202 Output.WriteLine(
"\" as UC1");
205 Output.WriteLine(
"@enduml");
206 Output.WriteLine(
"```");
210 Output.WriteLine(
"```uml: Activity chart for " + this.
id);
211 Output.WriteLine(
"@startuml");
216 Output.WriteLine(
"@enduml");
217 Output.WriteLine(
"```");
220 this.
Model.ExportActivityCharts(this.
id, Output, this.events);
223 private static string BreakWords(
string s,
int Width)
225 StringBuilder sb =
new StringBuilder();
228 foreach (
string Word
in s.Split(
new char[] {
' ',
'\t',
'\r',
'\n' }, StringSplitOptions.RemoveEmptyEntries))
250 return sb.ToString();
Root node of a simulation model
void Register(IDistribution Distribution)
Registers a distribution with the runtime environment of the model.
Represents an activity that can be executed as the result of triggered events.
override string LocalName
Local name of XML element defining contents of class.
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
void Register(IEvent Event)
Registers an event that calls the activity.
bool LogEnd
If event should be logged at the end of each activity.
Activity(ISimulationNode Parent, Model Model)
Represents an activity that can be executed as the result of triggered events.
virtual async Task ExecuteTask(Variables Variables)
Executes the activity.
int ExecutionCount
Execution count
override async Task ExportMarkdown(StreamWriter Output)
Exports PlantUML
override Task Initialize()
Initialized the node before simulation.
void Register(IActivityNode Node)
Registers a child activity node.
static async Task ExecuteActivity(Variables Variables, LinkedListNode< IActivityNode > Start)
Executes an activity by executing a possibly branching sequence of nodes.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
bool LogStart
If event should be logged at each start of the activity.
Exceptions thrown when the execution of an activity is completed.
Represents the starting point of the activity.
override Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
Abstract base class for events
string Description
Event description
virtual void ExportUseCaseData(StreamWriter Output, int Index)
Exports use case diagram data.
Abstract base class for simulation nodes with children
ISimulationNode Parent
Parent node in the simulation model.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Interface for activity nodes
void ExportPlantUml(StreamWriter Output, int Indentation, char QuoteChar)
Exports PlantUML