2using System.Collections.Generic;
5using System.Threading.Tasks;
26 private string sensor;
58 public override async Task
FromXml(XmlElement Definition)
62 await base.FromXml(Definition);
64 List<FieldNode> Fields =
new List<FieldNode>();
72 this.fields = Fields.ToArray();
83 throw new Exception(
"Sensor not found: " + this.sensor);
86 throw new Exception(
"Not a sensor server object: " + this.sensor);
88 Dictionary<ThingReference, LinkedList<Field>> FieldsByThing =
new Dictionary<ThingReference, LinkedList<Field>>();
93 Ref =
Field.ThingReference;
94 if (!FieldsByThing.TryGetValue(Ref, out LinkedList<Field> Fields))
96 Fields =
new LinkedList<Field>();
97 FieldsByThing[Ref] = Fields;
110 foreach (KeyValuePair<
ThingReference, LinkedList<Field>> P
in FieldsByThing)
112 LinkedList<Field> Fields = P.Value;
113 LinkedListNode<Field> Loop = Fields.First;
114 LinkedListNode<Field> Next;
130 Sensor.NewMomentaryValues(P.Key, Fields);
140 return Task.FromResult<LinkedListNode<IActivityNode>>(
null);
150 SortedDictionary<string, bool> Sorted =
new SortedDictionary<string, bool>();
155 string[] Result =
new string[Sorted.Count];
156 Sorted.Keys.CopyTo(Result, 0);
168 StringBuilder sb =
new StringBuilder();
170 if (!
string.IsNullOrEmpty(Ref.
SourceId))
176 if (!
string.IsNullOrEmpty(Ref.
Partition))
184 return sb.ToString();
192 public static string Join(
string[] References)
194 StringBuilder sb =
new StringBuilder();
197 foreach (
string Ref
in References)
207 return sb.ToString();
216 public override void ExportPlantUml(StreamWriter Output,
int Indentation,
char QuoteChar)
218 Indent(Output, Indentation);
219 Output.Write(
":NewMomentaryFields(");
220 Output.Write(this.sensor);
223 if (!
string.IsNullOrEmpty(s))
229 Output.WriteLine(
");");
Root node of a simulation model
ISimulationNode[] Children
Child nodes.
static void Indent(StreamWriter Output, int Indentation)
Adds indentation to the current row.
Abstract base class for sensor data field nodes.
Reports new momentary sensor data fields.
static string Join(string[] References)
Joins an array of references, and delimits them with ", ".
NewMomentaryValues(ISimulationNode Parent, Model Model)
Reports new momentary sensor data fields.
override void ExportPlantUml(StreamWriter Output, int Indentation, char QuoteChar)
Exports PlantUML
override async Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
static string[] GetThingReferences(FieldNode[] FieldNodes)
Gets referenced thing references
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
override Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
static string GetReference(ThingReference Ref)
Gets a string reference representing a ThingReference.
override string LocalName
Local name of XML element defining contents of class.
Abstract base class for IoT XMPP activity nodes.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Client managing the Personal Eventing Protocol (XEP-0163). https://xmpp.org/extensions/xep-0163....
Task Publish(string Node, EventHandlerAsync< ItemResultEventArgs > Callback, object State)
Publishes an item on a node.
Contains personal sensor data.
Implements an XMPP sensor server interface.
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Base class for all sensor data fields.
Contains a reference to a thing
string Partition
Optional partition in which the Node ID is unique.
string SourceId
Optional ID of source containing node.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.