3using System.Security.Cryptography.X509Certificates;
5using System.Threading.Tasks;
26 private string protocol =
string.Empty;
28 private bool tls =
false;
37 return Task.FromResult(
false);
64 [Header(4,
"Port Number:", 60)]
65 [ToolTip(5,
"Port number to use when communicating with device.")]
72 set => this.port = value;
79 [Header(11,
"Encrypted (TLS)", 70)]
80 [ToolTip(12,
"Check if Transport Layer Encryption (TLS) should be used.")]
84 set => this.tls = value;
91 [Header(41,
"Protocol:", 60)]
92 [ToolTip(42,
"Name of protocol or service on port number.")]
93 [DefaultValueStringEmpty]
98 set => this.protocol = value;
107 get => this.protocol;
108 set => this.protocol = value;
121 throw new Exception(
"Parent node not an IP Host node.");
137 await Client.ConnectAsync(HostName, this.port, this.tls);
157 public async Task<TextTcpClient>
ConnectTcp(Encoding Encoding,
bool DecoupledEvents, params
ISniffer[] Sniffers)
162 await Client.ConnectAsync(HostName, this.port, this.tls);
181 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(
Language, Caller) as LinkedList<Parameter>;
185 if (!
string.IsNullOrEmpty(this.
Protocol))
199 DateTime Now = DateTime.UtcNow;
200 string Module = typeof(
IpHost).Namespace;
204 List<Field>
Fields =
new List<Field>()
206 new QuantityField(
this, Now,
"Connect", (DateTime.UtcNow-Now).TotalMilliseconds, 0,
"ms",
FieldType.Momentary,
FieldQoS.AutomaticReadout, Module, 13)
212 Client.RemoteCertificateValid,
this, Now,
Fields);
Implements a binary TCP Client, by encapsulating a TcpClient. It also makes the use of TcpClient safe...
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
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 ...
Extract the fields of a type or an object.
Makes sure an expression is defined. Otherwise, an exception is thrown.
Helper methods for encrypting and decrypting streams of data.
const SslProtocols SecureTls
TLS 1.2 & 1.3
Node representing an IP Host machine.
Node representing a port on an IP Host machine.
static void AddCertificateFields(X509Certificate Certificate, bool IsValid, ThingReference Node, DateTime Timestamp, List< Field > Fields)
Adds information from a certificate as fields to a collection of fields.
Node representing a port on an IP Host machine.
async override Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
async Task< string > GetHostName()
Gets the host name or IP address of the parent IP Host node.
string PortName
Old property, replaced by Protocol.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
virtual async Task StartReadout(ISensorReadout Request)
Starts the readout of the sensor.
string Protocol
Port number.
async Task< BinaryTcpClient > ConnectTcp(bool DecoupledEvents, params ISniffer[] Sniffers)
Connect to the remote host and port using a binary protocol over TCP.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a presumptive child, i.e. can receive as a child (if that child accepts the node ...
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
async Task< TextTcpClient > ConnectTcp(Encoding Encoding, bool DecoupledEvents, params ISniffer[] Sniffers)
Connect to the remote host and port using a text-based protocol over TCP.
bool Tls
If connection is encrypted using TLS or not.
async Task< INode > GetParent()
Gets the parent of the node.
Base class for all provisioned metering nodes.
Tokens available in request.
Represents a physical quantity value.
Contains information about an error on a thing
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
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.
bool IsIncluded(string FieldName)
Checks if a field with the given parameters is included in the readout.
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.
FieldQoS
Field Quality of Service flags
FieldType
Field Type flags