2using System.Collections.Generic;
4using System.Text.RegularExpressions;
5using System.Threading.Tasks;
24 public const string RegExString =
@"^\s*([A-Fa-f0-9]{2}){1,}\s*$";
29 public static readonly Regex
RegEx =
new Regex(
RegExString, RegexOptions.Compiled | RegexOptions.Singleline);
32 private bool firstReport =
true;
70 this.firstReport =
false;
79 this.Timestamp = DateTime.UtcNow;
106 List<Field> Data =
new List<Field>()
112 if (!(this.value is
null) && this.value.Length <= 256)
115 Convert.ToBase64String(
this.value),
FieldType.Momentary,
FieldQoS.AutomaticReadout));
120 return Task.CompletedTask;
139 this.value = Hashes.StringToBinary(v);
140 this.Topic.MqttClient.PUBLISH(this.Topic.FullTopic, this.QoS, this.Retain, Encoding.UTF8.GetBytes(v));
141 return Task.CompletedTask;
151 if (this.value is
null)
153 else if (this.value.Length == 1)
156 this.
Information(Output, this.value.Length.ToString() +
" bytes.");
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 ...
Contains methods for simple hash calculations.
static byte[] StringToBinary(string s)
Parses a hex string.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Abstract base class for control parameters.
String control parameter.
Represents an MQTT topic with binary data encoded as decimal strings.
const string RegExString
Regular expression for hexadecimal string data.
override bool IsControllable
TODO
override Grade DefaultSupport
Default support.
HexStringData(MqttTopic Topic, byte[] Value)
Represents an MQTT topic with binary data encoded as decimal strings.
static readonly Regex RegEx
Parsed regular expression for hexadecimal string data.
override IMqttData CreateNew(MqttTopic Topic, MqttContent Content)
Creates a new instance of the data.
HexStringData()
Represents an MQTT topic with binary data encoded as decimal strings.
override Task< DataProcessingResult > DataReported(MqttTopic Topic, MqttContent Content)
Called when new data has been published.
override void SnifferOutput(ICommunicationLayer Output)
Outputs the parsed data to the sniffer.
override Task< string > GetTypeName(Language Language)
Type name representing data.
override ControlParameter[] GetControlParameters()
TODO
override Task StartReadout(ThingReference ThingReference, ISensorReadout Request, string Prefix, bool Last)
Starts a readout of the data.
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.
string Append(string Prefix, string Name)
Appends a name to a topic name.
IMqttData FindDataType(MqttContent Content)
FInds best implementation to process binary data.
A Metering node representing an MQTT topic
Represents a 32-bit integer value.
Represents a string value.
Contains a reference to a thing
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.
DataProcessingResult
Results from processing an incoming message.
FieldQoS
Field Quality of Service flags
FieldType
Field Type flags