Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FieldNode.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using System.Xml;
7using Waher.Script;
9
11{
15 public abstract class FieldNode : NodeReference, IValueRecipient
16 {
17 private IValue value = null;
18 private string name;
20 private FieldQoS qos;
21 private bool writable;
22
29 : base(Parent, Model)
30 {
31 }
32
36 public IValue Value => this.value;
37
41 public string Name => this.name;
42
47
51 public FieldQoS QualityOfService => this.qos;
52
56 public bool Writable => this.writable;
57
62 public override Task FromXml(XmlElement Definition)
63 {
64 this.name = XML.Attribute(Definition, "name");
65 this.type = (Waher.Things.SensorData.FieldType)XML.Attribute(Definition, "type", Waher.Things.SensorData.FieldType.Momentary);
66 this.qos = (FieldQoS)XML.Attribute(Definition, "qos", FieldQoS.AutomaticReadout);
67 this.writable = XML.Attribute(Definition, "writable", false);
68
69 return base.FromXml(Definition);
70 }
71
76 public void Register(IValue Value)
77 {
78 if (this.value is null)
79 this.value = Value;
80 else
81 throw new Exception("Field node already has a value defined.");
82 }
83
89 public abstract Task AddFields(LinkedList<Field> Fields, Variables Variables);
90 }
91}
Root node of a simulation model
Definition: Model.cs:49
Abstract base class for values
Definition: Value.cs:11
Abstract base class for sensor data field nodes.
Definition: FieldNode.cs:16
FieldQoS QualityOfService
Field Quality of Service
Definition: FieldNode.cs:51
bool Writable
If the field is writable (using a control parameter with the same name).
Definition: FieldNode.cs:56
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
Definition: FieldNode.cs:62
Waher.Things.SensorData.FieldType Type
Field Type
Definition: FieldNode.cs:46
void Register(IValue Value)
Registers a value for the argument.
Definition: FieldNode.cs:76
FieldNode(ISimulationNode Parent, Model Model)
Abstract base class for sensor data field nodes.
Definition: FieldNode.cs:28
abstract Task AddFields(LinkedList< Field > Fields, Variables Variables)
Adds sensor-data fields.
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Collection of variables.
Definition: Variables.cs:25
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Interface for nodes holding a value node
FieldQoS
Field Quality of Service flags
Definition: FieldQoS.cs:10
FieldType
Field Type flags
Definition: FieldType.cs:10
Definition: App.xaml.cs:4