2using System.Collections.Generic;
3using System.Threading.Tasks;
59 : base(new
ScriptNode[] { Sensor, FieldTypes, Fields },
77 : base(new
ScriptNode[] { Sensor, FieldTypes, Fields, From },
96 : base(new
ScriptNode[] { Sensor, FieldTypes, Fields, From, To },
110 public override string[]
DefaultArgumentNames =>
new string[] {
"Sensor",
"FieldTypes",
"Fields",
"From",
"To" };
150 Obj =
Arguments[i++].AssociatedObjectValue;
162 Obj =
Arguments[i++].AssociatedObjectValue;
164 if (Obj is
string[] Names)
166 else if (Obj is
object[] Objects)
168 int j, d = Objects.
Length;
170 FieldNames =
new string[d];
172 for (j = 0; j < d; j++)
174 if (Objects[j] is
string s)
180 else if (Obj is
null)
190 Obj =
Arguments[i++].AssociatedObjectValue;
192 if (Obj is DateTime TP)
194 else if (Obj is
null)
195 From = DateTime.MinValue;
200 From = DateTime.MinValue;
204 Obj =
Arguments[i++].AssociatedObjectValue;
206 if (Obj is DateTime TP)
208 else if (Obj is
null)
209 To = DateTime.MaxValue;
214 To = DateTime.MaxValue;
216 TaskCompletionSource<bool> ReadoutCompleted =
new TaskCompletionSource<bool>();
217 Dictionary<string, List<Field>> Fields =
new Dictionary<string, List<Field>>();
218 List<ThingError> Errors =
new List<ThingError>();
230 Nodes = Approval.
Nodes;
238 Actor, Nodes, FieldTypes, FieldNames, From, To, (Sender, e) =>
240 foreach (
Field F
in e.Fields)
242 if (Fields.TryGetValue(F.Name, out List<Field> List))
245 Fields[F.Name] = new List<Field>() { F };
249 ReadoutCompleted.TrySetResult(
true);
251 return Task.CompletedTask;
255 Errors.AddRange(e.Errors);
259 ReadoutCompleted.TrySetResult(
true);
261 return Task.CompletedTask;
264 Task Timeout = Task.Delay(60000);
265 Task T = await Task.WhenAny(ReadoutCompleted.Task, Timeout);
267 if (!ReadoutCompleted.Task.IsCompleted)
269 Errors.Add(
new ThingError(Sensor,
"Timeout."));
273 Dictionary<string, IElement> Fields2 =
new Dictionary<string, IElement>();
275 foreach (KeyValuePair<
string, List<Field>> P
in Fields)
277 if (P.Value.Count == 1)
283 return new ObjectValue(
new Dictionary<string, IElement>()
285 {
"Error", Error ? BooleanValue.True : BooleanValue.False },
286 {
"Ok", Error ? BooleanValue.False : BooleanValue.True },
295 public static string DefaultSource
320 if (Sources != sources)
322 Dictionary<string, IDataSource> SourceById =
new Dictionary<string, IDataSource>();
323 Add(SourceById, Sources);
324 sourceById = SourceById;
328 return sourceById.TryGetValue(SourceId, out Source);
331 private static void Add(Dictionary<string, IDataSource> SourceById, IEnumerable<IDataSource> Sources)
335 SourceById[Source.
SourceID] = Source;
343 private static Dictionary<string, IDataSource> sourceById =
null;
Static class managing the runtime environment of the IoT Gateway.
static XmppClient XmppClient
XMPP Client connection of gateway.
static ConcentratorServer ConcentratorServer
XMPP Concentrator Server.
Represents an external node.
CaseInsensitiveString Jid
JID of remote entity.
Gets a node object on the gateway.
static Task< RequestOrigin > GetOriginOfRequest(Variables Variables)
Gets the origin of a request.
Reads sensor data from a sensor node.
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
ReadSensorData(ScriptNode Sensor, ScriptNode FieldTypes, int Start, int Length, Expression Expression)
Reads sensor data from a sensor node.
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
ReadSensorData(ScriptNode Sensor, ScriptNode FieldTypes, ScriptNode Fields, ScriptNode From, ScriptNode To, int Start, int Length, Expression Expression)
Reads sensor data from a sensor node.
ReadSensorData(ScriptNode Sensor, ScriptNode FieldTypes, ScriptNode Fields, ScriptNode From, int Start, int Length, Expression Expression)
Reads sensor data from a sensor node.
override string FunctionName
Name of the function
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override string[] DefaultArgumentNames
Default Argument names
static bool TryGetDataSource(string SourceId, out IDataSource Source)
Tries to get a data source, from its data source ID.
ReadSensorData(ScriptNode Sensor, ScriptNode FieldTypes, ScriptNode Fields, int Start, int Length, Expression Expression)
Reads sensor data from a sensor node.
ReadSensorData(ScriptNode Sensor, int Start, int Length, Expression Expression)
Reads sensor data from a sensor node.
Contains information about what sensor data readout parameters have been approved.
FieldType FieldTypes
Approved types to read.
string[] FieldNames
Approved field names to read.
IThingReference[] Nodes
Approved nodes to read.
Manages a chat sensor data readout request.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
Script runtime exception.
Class managing a script expression.
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
Tokens available in request.
Base class for all sensor data fields.
Contains information about an error on a thing
Basic interface for all types of elements.
Basic interface for a user.
Interface for datasources that are published through the concentrator interface.
bool HasChildren
If the source has any child sources.
IEnumerable< IDataSource > ChildSources
Child sources. If no child sources are available, null is returned.
string SourceID
ID of data source.
Interface for sensor nodes.
Interface for thing references.
ArgumentType
Type of parameter used in a function definition or a lambda definition.
FieldType
Field Type flags