Connectivity Software User's Guide and Reference
FindOrCreateSystem(String,SparkplugConnectionDescriptor,SparkplugVersions) Method



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug.System Namespace > EasySparkplugInfrastructure Class > FindOrCreateSystem Method : FindOrCreateSystem(String,SparkplugConnectionDescriptor,SparkplugVersions) Method
The Sparkplug system ID.

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

The Sparkplug connection descriptor.

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

The Sparkplug version used by the system.
Find an existing Sparkplug system by a combination of a system ID, connection descriptor and Sparkplug version, or create a new one (and add it to the infrastructure) if not found.
Syntax
'Declaration
 
<JetBrains.Annotations.NotNullAttribute()>
Public Overloads Function FindOrCreateSystem( _
   ByVal systemId As String, _
   ByVal connectionDescriptor As SparkplugConnectionDescriptor, _
   ByVal sparkplugVersion As SparkplugVersions _
) As EasySparkplugSystem
'Usage
 
Dim instance As EasySparkplugInfrastructure
Dim systemId As String
Dim connectionDescriptor As SparkplugConnectionDescriptor
Dim sparkplugVersion As SparkplugVersions
Dim value As EasySparkplugSystem
 
value = instance.FindOrCreateSystem(systemId, connectionDescriptor, sparkplugVersion)

Parameters

systemId
The Sparkplug system ID.

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

connectionDescriptor
The Sparkplug connection descriptor.

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

sparkplugVersion
The Sparkplug version used by the system.

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 systemId is an empty string, the method attempts to find an existing system by the connectionDescriptor and sparkplugVersion, and returns it if it was found. If such system was not found, it creates a new one with the specified connectionDescriptor and sparkplugVersion. You can use OpcLabs.EasySparkplug.SparkplugVersions.None to search for a system with any Sparkplug version, and create a system with default version (EasySparkplugSystem.DefaultSparkplugVersion).

If systemId 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 connectionDescriptor, 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 connectionDescriptor and sparkplugVersion. You can use OpcLabs.EasySparkplug.SparkplugVersions.None to create a system with default version (EasySparkplugSystem.DefaultSparkplugVersion).

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