2using System.Collections.Generic;
4using System.Threading.Tasks;
30 private string proxyNodeId;
31 private string proxyFieldName;
43 [Page(1,
"IEEE 1451")]
44 [Header(29,
"Proxy Node ID:", 400)]
45 [ToolTip(30,
"Node ID of device to represent using this channel node.")]
49 get => this.proxyNodeId;
50 set => this.proxyNodeId = value;
56 [Page(1,
"IEEE 1451")]
57 [Header(31,
"Proxy Field Name:", 500)]
58 [ToolTip(32,
"Name of field to represent using this channel node.")]
62 get => this.proxyFieldName;
63 set => this.proxyFieldName = value;
96 LinkedList<Parameter> Parameters = (LinkedList<Parameter>)await base.GetDisplayableParametersAsync(
Language, Caller);
134 return Task.FromResult(
false);
149 return Grade.Excellent;
152 return Grade.NotAtAll;
162 StringBuilder sb =
new StringBuilder();
164 sb.Append(
"Channel-");
189 await base.StartReadout(Request,
false);
230 ??
throw new Exception(
"Node not found in Metering Topology: " + this.proxyNodeId);
233 throw new Exception(
"Node not a sensor node: " + this.proxyNodeId);
235 List<Field> Fields =
new List<Field>();
236 List<ThingError> Errors =
new List<ThingError>();
237 TaskCompletionSource<bool> Completed =
new TaskCompletionSource<bool>();
240 new string[] { this.proxyFieldName }, DateTime.MinValue, DateTime.MaxValue,
243 Fields.AddRange(e.Fields);
245 Completed.TrySetResult(
true);
247 return Task.CompletedTask;
251 Errors.AddRange(e.Errors);
253 Completed.TrySetResult(
true);
255 return Task.CompletedTask;
258 await Sensor.StartReadout(Readout);
261 (_) => Completed.TrySetException(
new TimeoutException()));
263 await Completed.Task;
265 if (Errors.Count > 0)
273 return Fields.ToArray();
295 if (BrokerNode is
null)
302 string Topic = await CommunicationNode.GetFullTopic();
303 if (
string.IsNullOrEmpty(Topic))
316 double Value = Quantity.Value;
317 double NrDecimals = Quantity.NrDecimals;
321 byte NrDec = (byte)(NrDecimals < 0 ? 0 : NrDecimals > 255 ? 255 : Math.Round(NrDecimals));
327 else if (MainField is
null)
330 StringValue = MainField.
ObjectValue?.ToString() ??
string.Empty;
332 StringBuilder ToSniffer = BrokerNode.HasSniffers ?
new StringBuilder() :
null;
337 if (!(ToSniffer is
null))
338 await BrokerNode.
Information(ToSniffer.ToString());
379 if (BrokerNode is
null)
386 string Topic = await CommunicationNode.GetFullTopic();
387 if (
string.IsNullOrEmpty(Topic))
391 StringBuilder ToSniffer;
396 ToSniffer = BrokerNode.HasSniffers ?
new StringBuilder() :
null;
407 List<TedsRecord> Records =
new List<TedsRecord>();
413 double Value = Quantity.Value;
414 double NrDecimals = Quantity.NrDecimals;
417 Records.Add(
new Ieee1451_0.TEDS.FieldTypes.TransducerChannelTeds.PhysicalUnits(Ieee1451Unit));
420 ToSniffer = BrokerNode.HasSniffers ?
new StringBuilder() :
null;
423 this.
TimIdBinary, (ushort)this.ChannelId, ToSniffer,
429 ToSniffer = BrokerNode.HasSniffers ?
new StringBuilder() :
null;
431 this.
TimIdBinary, (ushort)this.ChannelId, ToSniffer,
434 new Ieee1451_0.TEDS.FieldTypes.TransducerNameTeds.Content(
this.EntityName));
441 if (!(ToSniffer is
null))
442 await BrokerNode.
Information(ToSniffer.ToString());
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Manages a chat sensor data readout request.
Contains information about a language.
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
static bool TryParse(string UnitString, out Unit Unit)
Tries to parse a string into a unit.
IEEE 1451.0 TEDS Access Message
static byte[] SerializeResponse(ushort ErrorCode, byte[] NcapId, byte[] TimId, ushort ChannelId, StringBuilder SnifferOutput, TedsId TedsHeader, params TedsRecord[] Records)
Serializes a response to a TEDS request.
IEEE 1451.0 Transducer Access Message
static byte[] SerializeResponse(ushort ErrorCode, byte[] NcapId, byte[] TimId, ushort ChannelId, string Value, DateTime Timestamp, StringBuilder SnifferOutput)
Serializes a request for transducer data.
TEDS identification header (§6.3)
MQTT Topic node that publishes discovery commands in accordance with IEEE 1451.0.
Topic node representing an IEEE 1451.0 Channel.
MqttChannelTopicNode()
Topic node representing an IEEE 1451.0 Channel.
Topic node representing an IEEE 1451.0 NCAP.
int TimeoutMilliseconds
Timeout for request/response, in milliseconds.
byte[] NcapIdBinary
NCAP ID in binary form.
Topic node representing an IEEE 1451.0 TIM.
byte[] TimIdBinary
TIM ID in binary form.
Topic node representing a proxy for an IEEE 1451.0 Channel.
async Task TransducerDataRequest(TransducerAccessMessage TransducerAccessMessage, SamplingMode SamplingMode, double TimeoutSeconds)
A request for transducer data has been received.
override Task< string > GetTypeNameAsync(Language Language)
Diaplayable type name for node.
string ProxyFieldName
Proxy Field Name
async Task< Field[]> TryReadSensor(string Actor)
Tries to read the proxy node. If not successful, an error is logged on the node, and null is returned...
Field GetMainField(Field[] Fields)
Gets the main field, from a set of fields.
override async Task StartReadout(ISensorReadout Request, bool DoneAfter)
Starts the readout of the sensor.
string ProxyNodeId
Proxy Node ID
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a given parent.
async Task< Field[]> ReadSensor(string Actor)
Reads the transducer value.
override string LocalId
Local ID
ProxyMqttChannelTopicNode()
Topic node representing a proxy for an IEEE 1451.0 Channel.
override async Task< IMqttTopicNode > CreateNew(MqttTopicRepresentation Topic)
Creates a new node of the same type.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
async Task TedsRequest(TedsAccessMessage TedsAccessMessage, TedsAccessCode TedsAccessCode, uint TedsOffset, double TimeoutSeconds)
A request for TEDS data has been received.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a given child.
override Grade Supports(MqttTopicRepresentation Topic)
How well the topic node supports an MQTT topic
Topic node representing an IEEE 1451.0 NCAP Proxy.
Topic node representing an IEEE 1451.0 TIM Proxy.
Static class for IEEE 1451-related parsing tasks.
Base class for all metering nodes.
static async Task< string > GetUniqueNodeId(string NodeId)
Gets a Node ID, based on NodeId that is not already available in the database.
Defines the Metering Topology data source. This data source contains a tree structure of persistent r...
static Task< MeteringNode > GetNode(string NodeId)
Gets a node from the Metering Topology
MQTT Broker connection object.
Task Publish(string Topic, MqttQualityOfService QoS, bool Retain, byte[] Data)
Publishes binary data to a topic.
IMqttTopicNode Node
Reference to the MQTT Topic Node
Node representing a connection to an MQTT broker.
Task< MqttBroker > GetBroker()
Gets the corresponding broker node.
async Task Information(string Comment)
Called to inform the viewer of something.
string LocalTopic
Local Topic segment
Contains information about an MQTT topic
string CurrentSegment
Current segment being processed.
int SegmentIndex
Current segment index.
MqttTopic CurrentParentTopic
Current parent topic.
string[] Segments
Segments in topic string.
Tokens available in request.
Base class for all sensor data fields.
FieldType Type
Field Type flags.
abstract object ObjectValue
Field value, boxed as an object reference.
string Name
Unlocalized field name.
DateTime Timestamp
Timestamp of field value.
Represents a physical quantity value.
Contains information about an error on a thing
string ErrorMessage
Error message.
Interface for nodes that are published through the concentrator interface.
INode Parent
Parent Node, or null if a root node.
Interface for sensor nodes.
Interface for classes managing sensor data readouts.
string Actor
Actor making the request.
Task ReportErrors(bool Done, params ThingError[] Errors)
Report error states to the client.
Task ReportFields(bool Done, params Field[] Fields)
Report read fields to the client.
Interface for thing references.
Interface for nodes that can return TEDS.
Interface for nodes that can return transducer information.
Task< bool > RemoveErrorAsync()
Removes error messages with an empty event ID from the node.
Task< INode > GetParent()
Gets the parent of the node.
Task LogErrorAsync(string Body)
Logs an error message on the node.
MqttQualityOfService
MQTT Quality of Service level.
TedsAccessCode
TEDS Access Code
SamplingMode
Sampling Mode
FieldType
Field Type flags
static bool TryCreate(Unit Unit, ref double Value, ref double NrDecimals, out PhysicalUnits Units)
Tries to create an IEEE 1451 units object from a script unit.