2using System.Collections.Generic;
4using System.Threading.Tasks;
25 private IValue value =
null;
65 public override async Task
FromXml(XmlElement Definition)
71 await base.FromXml(Definition);
73 List<ThingReference> Nodes =
new List<ThingReference>();
78 Nodes.Add(NodeRef.ThingReference);
81 this.nodes = Nodes.ToArray();
90 if (this.value is
null)
93 throw new Exception(
"Value already defined.");
106 throw new Exception(
"Controller not found: " + ControllerName);
108 object Obj = v.ValueObject;
110 throw new Exception(
"Not a control client object: " + ControllerName);
119 ??
throw new Exception(
"No connection in roster with Bare JID: " + To);
122 throw new Exception(
"Contact not online: " + To);
128 await Controller.Set(To, Parameter, b, this.nodes);
129 else if (
Value is
double d)
130 await Controller.Set(To, Parameter, d, this.nodes);
131 else if (
Value is Enum e)
132 await Controller.Set(To, Parameter, e, this.nodes);
133 else if (
Value is
int i)
134 await Controller.Set(To, Parameter, i, this.nodes);
135 else if (
Value is
long l)
136 await Controller.Set(To, Parameter, l, this.nodes);
137 else if (
Value is
string s)
138 await Controller.Set(To, Parameter, s, this.nodes);
139 else if (
Value is TimeSpan TS)
140 await Controller.Set(To, Parameter, TS, this.nodes);
141 else if (
Value is System.DateTime TP)
142 await Controller.Set(To, Parameter, TP, TP.TimeOfDay == TimeSpan.Zero,
this.nodes);
144 await Controller.Set(To, Parameter, d2, this.nodes);
146 await Controller.Set(To, Parameter, cl, this.nodes);
147 else if (
Value is SKColor cl2)
148 await Controller.Set(To, Parameter,
new ColorReference(cl2.Red, cl2.Green, cl2.Red, cl2.Alpha),
this.nodes);
150 throw new Exception(
"Unsupported control type: " +
Value.GetType().FullName);
161 public override void ExportPlantUml(StreamWriter Output,
int Indentation,
char QuoteChar)
163 Indent(Output, Indentation);
164 Output.Write(
":ControlActuator(");
165 Output.Write(this.controller.
Value);
167 Output.Write(this.to.
Value);
170 if (!
string.IsNullOrEmpty(s))
176 Output.WriteLine(
");");
186 SortedDictionary<string, bool> Sorted =
new SortedDictionary<string, bool>();
191 string[] Result =
new string[Sorted.Count];
192 Sorted.Keys.CopyTo(Result, 0);
Root node of a simulation model
static void Indent(StreamWriter Output, int Indentation)
Adds indentation to the current row.
Contains the value of a string attribute, possibly with embedded script.
async Task< string > GetValueAsync(Variables Variables)
Gets the value of the attribute.
string Value
String value, from definition
Abstract base class for values
Controls an actuator by setting control parameters.
override string LocalName
Local name of XML element defining contents of class.
override async Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
static string[] GetThingReferences(ThingReference[] Nodes)
Gets referenced node references
override async Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
override void ExportPlantUml(StreamWriter Output, int Indentation, char QuoteChar)
Exports PlantUML
ControlActuator(ISimulationNode Parent, Model Model)
Controls an actuator by setting control parameters.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
void Register(IValue Value)
Registers a value for the argument.
Reports new momentary sensor data fields.
static string Join(string[] References)
Joins an array of references, and delimits them with ", ".
static string GetReference(ThingReference Ref)
Gets a string reference representing a ThingReference.
Abstract base class for IoT XMPP activity nodes.
Color reference. Separate class to avoid reference to Windows Forms or WPF libraries.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Implements an XMPP control client interface.
Maintains information about an item in the roster.
bool HasLastPresence
If the roster item has received presence from an online resource having the given bare JID.
string LastPresenceFullJid
Full JID of last resource sending online presence.
PresenceEventArgs LastPresence
Last presence received from a resource having this bare JID.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Contains a reference to a thing
ISimulationNode[] Children
Child nodes.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Task< object > EvaluateAsync(Variables Variables)
Evaluates the value.
Interface for nodes holding a value node
Represents a duration value, as defined by the xsd:duration data type: http://www....