2using System.Collections;
3using System.Collections.Generic;
5using System.Threading.Tasks;
55 if ((s.StartsWith(
"{") && s.EndsWith(
"}")) || (s.StartsWith(
"[") && s.EndsWith(
"]")))
61 this.Timestamp = DateTime.UtcNow;
93 List<Field> Fields =
new List<Field>();
94 this.AppendFields(
ThingReference, Fields, Request, this.value, Prefix);
97 return Task.CompletedTask;
102 if (Value is Dictionary<string, object> Object)
104 if (
string.IsNullOrEmpty(Prefix))
106 foreach (KeyValuePair<string, object> P
in Object)
111 foreach (KeyValuePair<string, object> P
in Object)
112 this.AppendFields(
ThingReference, Fields, Request, P.Value, Prefix +
", " + P.
Key);
115 else if (Value is IEnumerable Array && !(Value is
string))
119 if (
string.IsNullOrEmpty(Prefix))
121 foreach (
object Item
in Array)
126 foreach (
object Item
in Array)
132 if (
string.IsNullOrEmpty(Prefix))
143 else if (Value is
string s)
145 if (System.TimeSpan.TryParse(s, out TimeSpan TimeSpan))
147 else if (System.DateTime.TryParse(s, out DateTime DateTime))
149 if (DateTime.TimeOfDay == TimeSpan.Zero)
161 else if (Value is
int i)
163 else if (Value is
long l)
165 else if (Value is
double d)
172 else if (Value is decimal d2)
179 else if (Value is
bool b)
198 (n) => Task.FromResult<
string>(
this.json),
201 this.value = JSON.Parse(v);
203 this.Topic.MqttClient.PUBLISH(this.Topic.FullTopic, this.QoS, this.Retain, Encoding.UTF8.GetBytes(v));
204 return Task.CompletedTask;
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
static bool TryParseRfc822(string s, out DateTimeOffset Value)
Parses a date and time value encoded according to RFC 822, §5.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Helps with common JSON-related tasks.
static object Parse(string Json)
Parses a JSON string.
Information about content received from the MQTT server.
string DataString
String representation of UTF-8 encoded binary data.
MqttHeader Header
MQTT Header
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 ...
Abstract base class for control parameters.
Multi-line text control parameter.
Represents an MQTT topic with JSON-encoded data.
override bool IsControllable
TODO
override IMqttData CreateNew(MqttTopic Topic, MqttContent Content)
Creates a new instance of the data.
override Task StartReadout(ThingReference ThingReference, ISensorReadout Request, string Prefix, bool Last)
Starts a readout of the data.
override ControlParameter[] GetControlParameters()
TODO
override Grade DefaultSupport
Default support.
JsonData(MqttTopic Topic, string Json, object Value)
Represents an MQTT topic with JSON-encoded data.
JsonData()
Represents an MQTT topic with JSON-encoded data.
override void SnifferOutput(ICommunicationLayer Output)
Outputs the parsed data to the sniffer.
override Task< string > GetTypeName(Language Language)
Type name representing data.
override Task< DataProcessingResult > DataReported(MqttTopic Topic, MqttContent Content)
Called when new data has been published.
Abstract base class for MQTT data encapsulations.
void Information(ICommunicationLayer Output, string Info)
Outputs information to sniffer.
MqttTopic Topic
Topic used
DateTime Timestamp
Timestamp of data reception.
A Metering node representing an MQTT topic
Represents a boolean value that can be either true or false.
Represents a date and optional time value.
Represents a duration value. Duration values adhere to the type specified by xsd:duration.
Represents a 32-bit integer value.
Represents a 64-bit integer value.
Represents a physical quantity value.
Represents a string value.
Represents a time value. Time values adhere to the type specified by xsd:time.
Contains a reference to a thing
string Key
Key for thing reference: [NodeId[, SourceId[, Partition]]]
Interface for observable classes implementing communication protocols.
Interface for classes managing sensor data readouts.
Task ReportFields(bool Done, params Field[] Fields)
Report read fields to the client.
Interface for MQTT Data encapsulations
Task< DataProcessingResult > DataReported(MqttTopic Topic, MqttContent Content)
Called when new data has been published.
delegate string ToString(IElement Element)
Delegate for callback methods that convert an element value to a string.
DataProcessingResult
Results from processing an incoming message.
FieldQoS
Field Quality of Service flags
FieldType
Field Type flags
Represents a duration value, as defined by the xsd:duration data type: http://www....