Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ModelScript.cs
1using System.Threading.Tasks;
2using System.Xml;
3using Waher.Script;
4
6{
11 {
12 private string script;
13 private Expression expression;
14
21 : base(Parent, Model)
22 {
23 }
24
28 public string Script => this.script;
29
33 public Expression Expression => this.expression;
34
38 public override string LocalName => nameof(ModelScript);
39
47 {
48 return new ModelScript(Parent, Model);
49 }
50
55 public override Task FromXml(XmlElement Definition)
56 {
57 this.script = Values.Script.RemoveIndent(Definition.InnerText);
58 this.expression = new Expression(this.script);
59
60 return Task.CompletedTask;
61 }
62
66 public override async Task Initialize()
67 {
68 await this.expression.EvaluateAsync(this.Model.Variables);
69 await base.Initialize();
70 }
71 }
72}
Root node of a simulation model
Definition: Model.cs:49
Variables Variables
Model variables.
Definition: Model.cs:175
Executes model script, allowing for definitions that will be available across events.
Definition: ModelScript.cs:11
override async Task Initialize()
Initialized the node before simulation.
Definition: ModelScript.cs:66
Expression Expression
Parsed expression
Definition: ModelScript.cs:33
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
Definition: ModelScript.cs:55
ModelScript(ISimulationNode Parent, Model Model)
Executes model script, allowing for definitions that will be available across events.
Definition: ModelScript.cs:20
override string LocalName
Local name of XML element defining contents of class.
Definition: ModelScript.cs:38
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Definition: ModelScript.cs:46
Abstract base class for simulation nodes
ISimulationNode Parent
Parent node in the simulation model.
Class managing a script expression.
Definition: Expression.cs:39
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
Definition: Expression.cs:4275
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...