Connectivity Software User's Guide and Reference
FindOrCreateSystem(SparkplugSystemDescriptor) Method



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug.System Namespace > EasySparkplugInfrastructure Class > FindOrCreateSystem Method : FindOrCreateSystem(SparkplugSystemDescriptor) Method
The Sparkplug system descriptor.

The value of this parameter cannot be null (Nothing in Visual Basic).

Find an existing Sparkplug system by a system descriptor, or create a new one (and add it to the infrastructure) if not found.
Syntax
'Declaration
 
<JetBrains.Annotations.NotNullAttribute()>
Public Overloads Function FindOrCreateSystem( _
   ByVal systemDescriptor As SparkplugSystemDescriptor _
) As EasySparkplugSystem
'Usage
 
Dim instance As EasySparkplugInfrastructure
Dim systemDescriptor As SparkplugSystemDescriptor
Dim value As EasySparkplugSystem
 
value = instance.FindOrCreateSystem(systemDescriptor)
[JetBrains.Annotations.NotNull()]
public EasySparkplugSystem FindOrCreateSystem( 
   SparkplugSystemDescriptor systemDescriptor
)
[JetBrains.Annotations.NotNull()]
public:
EasySparkplugSystem^ FindOrCreateSystem( 
   SparkplugSystemDescriptor^ systemDescriptor
) 

Parameters

systemDescriptor
The Sparkplug system descriptor.

The value of this parameter cannot be null (Nothing in Visual Basic).

Return Value

Returns the Sparkplug system object that has been found or created.

This method never returns null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The Sparkplug operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Remarks

If the SystemId of the systemDescriptor is an empty string, the method attempts to find an existing system by the ConnectionDescriptor and SparkplugVersion of the systemDescriptor, and returns it if it was found. If such system was not found, it creates a new one with the specified ConnectionDescriptor and SparkplugVersion. When SparkplugVersion is OpcLabs.EasySparkplug.SparkplugVersions.None, the method searches for a system with any Sparkplug version, and creates a system with default version (EasySparkplugSystem.DefaultSparkplugVersion).

If SystemId of the systemDescriptor is not an empty string, the method attempts to find an existing with this given system Id. If such system is found, and its EasySparkplugSystem.ConnectionDescriptor equals to the specified EasySparkplugSystem.ConnectionDescriptor of the systemDescriptor, this system is returned. If the connection descriptors do not match, the methods throws a OpcLabs.EasySparkplug.OperationModel.SparkplugException. If a system with specified SystemId was not found, the method creates a new one with the specified EasySparkplugSystem.ConnectionDescriptor and SparkplugVersion. When SparkplugVersion equals to OpcLabs.EasySparkplug.SparkplugVersions.None, a system with default version (EasySparkplugSystem.DefaultSparkplugVersion) is created.

A new Sparkplug system is only ever created by this method if AutoCreateSystem is true (which is the default). If a system is not found and AutoCreateSystem is false, this method throws a OpcLabs.EasySparkplug.OperationModel.SparkplugException.

 

Sparkplug is a trademark of Eclipse Foundation, Inc. "MQTT" is a trademark of the OASIS Open standards consortium. Other related terms are trademarks of their respective owners. Any use of these terms on this site is for descriptive purposes only and does not imply any sponsorship, endorsement or affiliation.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also