Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GroupReference.cs
2using System.Threading.Tasks;
3using Waher.Groups;
6using Waher.Things;
8
10{
15 {
20 : base()
21 {
22 }
23
27 [Header(29, "Group ID:", 20)]
28 [Page(66, "Job", 0)]
29 [ToolTip(30, "ID of the group being referenced.")]
30 [Required]
31 public string ReferenceNodeId { get; set; }
32
38 public override Task<string> GetTypeNameAsync(Language Language)
39 {
40 return Language.GetStringAsync(typeof(GroupReference), 31, "Group Reference");
41 }
42
47 public override async Task FindNodes<T>(ChunkedList<T> Nodes)
48 {
49 INode Node = await GroupSource.GetNode(this.ReferenceNodeId);
50
51 if (Node is null)
52 {
53 await this.LogErrorAsync("InvalidReference", "Group not found.");
54 return;
55 }
56
57 if (Node is T TypedNode)
58 Nodes.Add(TypedNode);
59 else
60 {
61 ChunkedList<INode> CheckChildren = new ChunkedList<INode>() { Node };
62
63 while (CheckChildren.HasFirstItem)
64 {
65 Node = CheckChildren.RemoveFirst();
66 IEnumerable<INode> Children = await Node.ChildNodes;
67
68 if (!(Children is null))
69 {
70 foreach (INode Child in Children)
71 {
72 if (Child is T TypedChild)
73 Nodes.Add(TypedChild);
74 else
75 CheckChildren.Add(Child);
76 }
77 }
78 }
79 }
80 }
81 }
82}
Defines the Groups data source. This data source contains a tree structure of groups of nodes
Definition: GroupSource.cs:21
static Task< GroupNode > GetNode(string NodeId)
Gets a node from the Metering Topology
Definition: GroupSource.cs:101
virtual Task LogErrorAsync(string Body)
Logs an error message on the node.
Definition: JobNode.cs:193
A reference to a metering group.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
GroupReference()
A reference to a metering group.
Abstract base class for reference nodes.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
bool HasFirstItem
If there is a first item in the collection
Definition: ChunkedList.cs:778
T RemoveFirst()
Removes the first item in the collection.
Definition: ChunkedList.cs:876
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
Contains information about a language.
Definition: Language.cs:17
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 ...
Definition: Language.cs:209
Base Interface for all metering nodes.
Definition: IGroup.cs:11
Task< T[]> FindNodes< T >()
Finds nodes referenced by the group node.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Task< IEnumerable< INode > > ChildNodes
Child nodes. If no child nodes are available, null is returned.
Definition: INode.cs:140