2using System.Collections.Generic;
3using System.Net.NetworkInformation;
5using System.Threading.Tasks;
22 private string host =
string.Empty;
41 return Task.FromResult(Child is
IpHost);
58 [Header(2,
"Host Name:", 50)]
59 [ToolTip(3,
"Host Name or IP Address of device.")]
60 [DefaultValueStringEmpty]
65 set => this.host = value;
81 using (Ping Icmp =
new Ping())
83 PingReply Response = await Icmp.SendPingAsync(this.host, 2000, data, options);
84 DateTime Now = DateTime.Now;
85 string Module = typeof(
IpHost).Namespace;
87 if (Response.Status == IPStatus.Success)
89 List<Field> Fields =
new List<Field>()
96 Fields.Add(
new StringField(
this, Now,
"IP Address", Response.Address.ToString(),
FieldType.Identity,
FieldQoS.AutomaticReadout, Module, 8));
105 GetErrorMessage(Response)));
109 catch (PingException ex)
111 if (!(ex.InnerException is
null))
122 private static string GetErrorMessage(PingReply Response)
124 switch (Response.Status)
126 case IPStatus.Success:
return null;
127 case IPStatus.BadDestination:
return "Bad destination";
128 case IPStatus.BadHeader:
return "Bad header";
129 case IPStatus.BadOption:
return "Bad option";
130 case IPStatus.BadRoute:
return "Bad route";
131 case IPStatus.DestinationHostUnreachable:
return "Destination host unreachable";
132 case IPStatus.DestinationNetworkUnreachable:
return "Destination network unreachable";
133 case IPStatus.DestinationPortUnreachable:
return "Destination port unreachable";
134 case IPStatus.DestinationProhibited:
return "Destination prohibited";
136 case IPStatus.DestinationScopeMismatch:
return "Destination scope mismatch";
137 case IPStatus.DestinationUnreachable:
return "Destination unreachable";
138 case IPStatus.HardwareError:
return "Hardware error";
139 case IPStatus.IcmpError:
return "ICMP error";
140 case IPStatus.NoResources:
return "No resources";
141 case IPStatus.PacketTooBig:
return "Packet too big";
142 case IPStatus.ParameterProblem:
return "Parameter problem";
143 case IPStatus.SourceQuench:
return "Source quench";
144 case IPStatus.TimedOut:
return "Timed out";
145 case IPStatus.TimeExceeded:
return "Time exceeded";
146 case IPStatus.TtlExpired:
return "TTL expired";
147 case IPStatus.TtlReassemblyTimeExceeded:
return "TTL reassembly time exceeded";
148 case IPStatus.UnrecognizedNextHeader:
return "Unrecognized next header";
149 case IPStatus.Unknown:
151 return "Unknown error";
155 private static readonly
byte[] data = Encoding.ASCII.GetBytes(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
156 private static readonly PingOptions options =
new PingOptions(64,
true);
166 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(
Language, Caller) as LinkedList<Parameter>;
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 ...
Node representing an IP Host machine.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
async override Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
override bool IsReadable
If the node can be read.
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 ...
virtual async Task StartReadout(ISensorReadout Request)
Starts the readout of the sensor.
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...
string Host
Host name or IP address.
Class for the root node of the Metering topology.
Base class for all provisioned metering nodes.
Tokens available in request.
Represents a physical quantity value.
Represents a string value.
Contains information about an error on a thing
Interface for objects that contain a reference to a host.
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