5using System.Threading.Tasks;
55 if ((s.StartsWith(
'{') && s.EndsWith(
'}')) ||
56 (s.StartsWith(
'[') && s.EndsWith(
']')))
62 this.Timestamp = DateTime.UtcNow;
94 List<Field> Fields =
new List<Field>();
95 this.AppendFields(
ThingReference, Fields, Request, this.value, Prefix);
98 return Task.CompletedTask;
103 if (Value is Dictionary<string, object> Object)
105 if (
string.IsNullOrEmpty(Prefix))
107 foreach (KeyValuePair<string, object> P
in Object)
112 foreach (KeyValuePair<string, object> P
in Object)
113 this.AppendFields(
ThingReference, Fields, Request, P.Value, Prefix +
", " + P.
Key);
116 else if (Value is IEnumerable Array && !(Value is
string))
120 if (
string.IsNullOrEmpty(Prefix))
122 foreach (
object Item
in Array)
127 foreach (
object Item
in Array)
133 if (
string.IsNullOrEmpty(Prefix))
144 else if (Value is
string s)
146 if (
System.TimeSpan.TryParse(s, out TimeSpan TimeSpan))
148 else if (
System.DateTime.TryParse(s, out DateTime DateTime))
150 if (DateTime.TimeOfDay == TimeSpan.Zero)
162 else if (Value is
int i)
164 else if (Value is
long l)
166 else if (Value is
double d)
173 else if (Value is decimal d2)
180 else if (Value is
bool b)
199 (n) => Task.FromResult<
string>(
this.json),
202 this.value = JSON.Parse(v);
204 this.Topic.MqttClient.PUBLISH(this.Topic.FullTopic, this.QoS, this.Retain, Encoding.UTF8.GetBytes(v));
205 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....