Skip to content

[Server] Add Support for Sampling Groups to CustomNodeManager #3075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Applications/ConsoleReferenceServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static async Task<int> Main(string[] args)
bool appLog = false;
bool renewCertificate = false;
bool shadowConfig = false;
bool samplingGroups = false;
bool cttMode = false;
string password = null;
int timeout = -1;
Expand All @@ -78,6 +79,7 @@ public static async Task<int> Main(string[] args)
{ "r|renew", "renew application certificate", r => renewCertificate = r != null },
{ "t|timeout=", "timeout in seconds to exit application", (int t) => timeout = t * 1000 },
{ "s|shadowconfig", "create configuration in pki root", s => shadowConfig = s != null },
{ "sg|samplinggroups", "use the sampling group mechanism in the Reference Node Manager", sg => samplingGroups = sg != null },
{ "ctt", "CTT mode, use to preset alarms for CTT testing.", c => cttMode = c != null },
};

Expand Down Expand Up @@ -127,6 +129,12 @@ public static async Task<int> Main(string[] args)
// Create and add the node managers
server.Create(Servers.Utils.NodeManagerFactories);

// enable the sampling groups if requested
if (samplingGroups)
{
Quickstarts.Servers.Utils.UseSamplingGroupsInReferenceNodeManager(server.Server);
}

// start the server
output.WriteLine("Start the server.");
await server.StartAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class ReferenceNodeManager : CustomNodeManager2
/// <summary>
/// Initializes the node manager.
/// </summary>
public ReferenceNodeManager(IServerInternal server, ApplicationConfiguration configuration)
: base(server, configuration, Namespaces.ReferenceServer)
public ReferenceNodeManager(IServerInternal server, ApplicationConfiguration configuration, bool useSamplingGroups = false)
: base(server, configuration, useSamplingGroups, Namespaces.ReferenceServer)
{
SystemContext.NodeIdFactory = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ public partial class ReferenceServer : ReverseConnectServer
#region Properties
public ITokenValidator TokenValidator { get; set; }

/// <summary>
/// If true the ReferenceNodeManager is set to work with a sampling group mechanism
/// for managing monitored items instead of a Monitored Node mechanism
/// </summary>
public bool UseSamplingGroupsInReferenceNodeManager
{
get => m_useSamplingGroups;
set
{
m_useSamplingGroups = value;
}
}

#endregion

#region Overridden Methods
Expand All @@ -70,7 +83,7 @@ protected override MasterNodeManager CreateMasterNodeManager(IServerInternal ser
IList<INodeManager> nodeManagers = new List<INodeManager>();

// create the custom node manager.
nodeManagers.Add(new ReferenceNodeManager(server, configuration));
nodeManagers.Add(new ReferenceNodeManager(server, configuration, UseSamplingGroupsInReferenceNodeManager));

foreach (var nodeManagerFactory in NodeManagerFactories)
{
Expand Down Expand Up @@ -449,6 +462,7 @@ private IUserIdentity VerifyIssuedToken(IssuedIdentityToken issuedToken)

#region Private Fields
private ICertificateValidator m_userCertificateValidator;
private bool m_useSamplingGroups;
#endregion
}
}
9 changes: 9 additions & 0 deletions Applications/Quickstarts.Servers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.Reflection;
using Opc.Ua;
using Opc.Ua.Server;
using Quickstarts.ReferenceServer;

namespace Quickstarts.Servers
{
Expand Down Expand Up @@ -97,6 +98,14 @@ public static void AddDefaultNodeManagers(StandardServer server)
}
}

/// <summary>
/// Add all available node manager factories to the server.
/// </summary>
public static void UseSamplingGroupsInReferenceNodeManager(ReferenceServer.ReferenceServer server)
{
server.UseSamplingGroupsInReferenceNodeManager = true;
}

/// <summary>
/// The property with available node manager factories.
/// </summary>
Expand Down
Loading
Loading