Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ModbusUnitChildNode.cs
1using System;
2using System.Threading.Tasks;
4
6{
11 {
16 : base()
17 {
18 }
19
25 public override Task<bool> AcceptsParentAsync(INode Parent)
26 {
27 return Task.FromResult(Parent is ModbusUnitNode || Parent is ModbusCompositeChildNode);
28 }
29
35 public override Task<bool> AcceptsChildAsync(INode Child)
36 {
37 return Task.FromResult(false);
38 }
39
43 public async Task<ThingReference> GetReportAs()
44 {
45 if (await this.GetParent() is ModbusCompositeChildNode Composite)
46 return Composite;
47 else
48 return this;
49 }
50
54 public async Task<ModbusGatewayNode> GetGateway()
55 {
56 INode Loop = await this.GetParent();
57 while (!(Loop is null))
58 {
59 if (Loop is ModbusGatewayNode Gateway)
60 return Gateway;
61 else if (Loop is MeteringNode MeteringNode)
62 Loop = await MeteringNode.GetParent();
63 else
64 Loop = Loop.Parent;
65 }
66
67 throw new Exception("Modbus Gateway node not found.");
68 }
69
73 public async Task<ModbusUnitNode> GetUnitNode()
74 {
75 INode Loop = await this.GetParent();
76 while (!(Loop is null))
77 {
78 if (Loop is ModbusUnitNode UnitNode)
79 return UnitNode;
80 else if (Loop is MeteringNode MeteringNode)
81 Loop = await MeteringNode.GetParent();
82 else
83 Loop = Loop.Parent;
84 }
85
86 throw new Exception("Modbus Unit node not found.");
87 }
88
89 }
90}
Base class for all metering nodes.
Definition: MeteringNode.cs:28
INode Parent
Parent Node, or null if a root node.
async Task< INode > GetParent()
Gets the parent of the node.
Base class for all provisioned metering nodes.
Represents a composition of nodes, under a unit.
Node representing a TCP/IP connection to a Modbus Gateway
Abstract base class for child nodes to Mobus Unit nodes.
ModbusUnitChildNode()
Abstract base class for child nodes to Mobus Unit nodes.
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...
async Task< ModbusGatewayNode > GetGateway()
Modbus Gateway node.
async Task< ModbusUnitNode > GetUnitNode()
Modbus Unit node.
async Task< ThingReference > GetReportAs()
Under what node fields are to be reported.
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 ...
Represents a Unit Device on a Modbus network.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
INode Parent
Parent Node, or null if a root node.
Definition: INode.cs:116