DWIS.Client.ReferenceImplementation
1.0.10
See the version list below for details.
dotnet add package DWIS.Client.ReferenceImplementation --version 1.0.10
NuGet\Install-Package DWIS.Client.ReferenceImplementation -Version 1.0.10
<PackageReference Include="DWIS.Client.ReferenceImplementation" Version="1.0.10" />
paket add DWIS.Client.ReferenceImplementation --version 1.0.10
#r "nuget: DWIS.Client.ReferenceImplementation, 1.0.10"
// Install DWIS.Client.ReferenceImplementation as a Cake Addin #addin nuget:?package=DWIS.Client.ReferenceImplementation&version=1.0.10 // Install DWIS.Client.ReferenceImplementation as a Cake Tool #tool nuget:?package=DWIS.Client.ReferenceImplementation&version=1.0.10
DWIS.Client.ReferenceImplementation
This is the main component of the DDHub .net SDK.
Installation
The simplest is to use nuget packages.
dotnet add package DWIS.Client.ReferenceImplementation --version 1.0.5
The package relies on the Unified Automation .Net SDK. This product is licensed: if you have a license, place it in the folder containing your executable. Otherwise, the client will only run for one hour.
Getting started
Creating a client
To instantiate a client, you need to pass some arguments.
IDWISClientConfiguration clientConfiguration
: contains the connection information to the DDHub server. A standard implementation of the interface is the classDefaultDWISConfiguration
, in the same namespace. The interface exposes the following fields:ServerAdress
: the opc address to be used, including the port numberUseWebAPI
: can be set totrue
if the server also exposes an http interface. If set tofalse
the standard opc ua communication will be used for semantic interaction.WebAPIUrl
: the url of the web service. Only relevant ifUseWebPI
istrue
.
IUAApplicationConfiguration uAApplicationConfiguration
: for the management of opc ua communication. A standard implementation of the interface isUAApplicationConfiguration
, in theDWIS.OPCUA.LicenseManager
namespace. The interface exposes the following fields:LicenseFilePath
ApplicationName
ProductName
CertificateStorePath
CertificateSubjectName
TrustedCertificateStore
IssuerCertificateStore
RejectedCertificatesStore
ILogger<DWISClient>? logger, ILoggerFactory? loggerFactory
IUALicenseManager? uALicenseManager
. A standard implementation of the interface isLicenseManager
, in theDWIS.OPCUA.LicenseManager
namespace.
A client can be implemented by:
var client = new DWISClient(
new DefaultDWISClientConfiguration()
{
ServerAddress = "opc.tcp://localhost:48030",
UseWebAPI = false
},
new UAApplicationConfiguration(),
null,
null,
new LicenseManager());
Another example, based on dependency injection:
var hostBuilder = Host.CreateDefaultBuilder();
hostBuilder.ConfigureServices((hostContext, services) =>
{
services
.AddSingleton<IDWISClientConfiguration>(DefaultDWISClientConfiguration.LoadDefault())//standard method that will load from a JSON file at a predefined location, or construct a configuration with default parameters.
.AddSingleton<IUAApplicationConfiguration, UAApplicationConfiguration>()
.AddSingleton<IUALicenseManager,LicenseManager>()
.AddSingleton<IOPCUADWISClient, DWISClient>();
});
var host = hostBuilder.Build();
var client = host.Services.GetRequiredService<IOPCUADWISClient>();
Using the DDHub API
Inject a manifest
Manifest injection is done by calling the Inject
method. The manifest class is in the DWIS.API.DTO
namespace.
ManifestFile myManifest = new ManifestFile();
//populate your manifest
var result = client.Inject(myManifest);
If your manifest contains some provided variables, those can be updated on the server by calling the UpdateProvidedVariables
method:
ManifestFile myManifest = new ManifestFile();
myManifest.ProvidedVariables = new List<ProvidedVariable>();
myManifest.ProvidedVariables.Add(new ProvidedVariable()
{
DataType = "double",
Rank = 0,
VariableID = "mySPP"
});
var result = client.Inject(myManifest);//the client will maintain the mapping between the provided variable ID and the opc ua nodeID on the main server.
client.UpdateProvidedVariables(new List<(string, object, DateTime)>() { ("mySPP", 1e5, DateTime.Now) });
Acquisition files
AcquisitionFile acquisitionFile = new AcquisitionFile();
AcquisitionItem acquisitionItem = new AcquisitionItem();
acquisitionItem.Name = "SPP";
acquisitionItem.Criterias.Add(new AcquisitionCriteria() { Classes = new List<string>() { Nouns.Measurement, Nouns.SPP }, CriteriaIndex = 0 });
acquisitionItem.Name = "SFT";
acquisitionItem.Criterias.Add(new AcquisitionCriteria() { Classes = new List<string>() { Nouns.Measurement, Nouns.SurfaceTorque }, CriteriaIndex = 0 });
var resolvedFile = client.Resolve(acquisitionFile);
string[] keys = { "SPP", "SFT" };
foreach (string key in keys)
{
var results = resolvedFile.Resolutions.First(r => r.Name == key);
foreach (var criteria in results.ITemResults)
{
Console.WriteLine($"Results for {key} criteria {criteria.Index}");
foreach (var item in criteria.CriteriaResults)
{
Console.WriteLine($"Found a signal with ID {item.SignalID.ID} in the namespace with index {item.SignalID.NameSpaceIndex}");
}
}
}
You can also register an acquisition file to receive updates when new resolutions are available:
client.RegisterAcquisitionFile(acquisitionFile, Callback);
private void Callback(AcquisitionDiff acquisitionDiff)
{
//manage your application's response here.
Console.WriteLine("Received new results for the acquisition file.");
}
Sparql queries
The client can be used to resolve sparql queries such as:
SELECT ?convA ?convB
WHERE {
?unit <http://ddhub.no/ConversionFactorA> ?convA .
?unit <http://ddhub.no/ConversionFactorB> ?convB .
}
This query will return all the conversion factors of the units stored in the DDHub server. To get the result, just call the GetQueryResult
method
string sparql;//write your sparql query in plain text here
var res = client.GetQueryResult(sparql);
You can also register a query to get notified when new solutions are found:
var res = client.RegisterQuery(sparql, Callback);
private void Callback(QueryResultsDiff resultsDiff)
{
//manage your application's response here.
Console.WriteLine("Received new results for the query.");
}
Avanced
Query builder
Acquired signals
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- DWIS.OPCUA.Schemas (>= 1.0.10)
- DWIS.OPCUA.Utils (>= 1.0.10)
- DWIS.SPARQL.Utils (>= 1.0.10)
- Microsoft.Extensions.Logging (>= 7.0.0)
- UnifiedAutomation.UaBase.BouncyCastle (>= 3.2.1)
- UnifiedAutomation.UaClient (>= 3.2.1)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on DWIS.Client.ReferenceImplementation:
Package | Downloads |
---|---|
DWIS.OPCUA.UALicenseManager
Package Description |
|
DWIS.Server.ReferenceImplementation.Base
Package Description |
|
DWIS.OPCUA.DDHubServerManager
Package Description |
|
DWIS.Client.ReferenceImplementation.UnifiedAutomation
Package Description |
|
DWIS.Client.ReferenceImplementation.OPCFoundation
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.9 | 157 | 12/12/2024 |
2.1.8 | 126 | 12/10/2024 |
2.1.7 | 155 | 10/29/2024 |
2.1.6 | 132 | 10/29/2024 |
2.1.5 | 152 | 10/22/2024 |
2.1.4 | 164 | 10/17/2024 |
2.1.3 | 194 | 10/9/2024 |
2.1.2 | 212 | 10/8/2024 |
2.1.1 | 283 | 9/2/2024 |
2.1.0 | 233 | 6/26/2024 |
2.0.0 | 604 | 2/16/2024 |
1.0.10 | 131 | 1/29/2024 |
1.0.9 | 165 | 9/6/2023 |
1.0.5 | 275 | 2/7/2023 |
1.0.4 | 291 | 2/3/2023 |
1.0.3 | 296 | 1/17/2023 |
1.0.2 | 138 | 1/9/2023 |