2021-12-23 08:22:03 +00:00
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Opc.Ua;
|
|
|
|
|
using Quickstarts;
|
|
|
|
|
using Quickstarts.ReferenceServer;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Plugin
|
|
|
|
|
{
|
2021-12-24 06:22:45 +00:00
|
|
|
|
public class UAService :IDisposable
|
2021-12-23 08:22:03 +00:00
|
|
|
|
{
|
|
|
|
|
string applicationName = "ConsoleReferenceServer";
|
|
|
|
|
string configSectionName = "Quickstarts.ReferenceServer";
|
|
|
|
|
|
2021-12-24 06:22:45 +00:00
|
|
|
|
public UAServer<ReferenceServer> server = null;
|
2021-12-23 08:22:03 +00:00
|
|
|
|
|
2021-12-24 06:22:45 +00:00
|
|
|
|
public UAService()
|
2021-12-23 08:22:03 +00:00
|
|
|
|
{
|
|
|
|
|
server = new UAServer<ReferenceServer>(null)
|
|
|
|
|
{
|
|
|
|
|
AutoAccept = false,
|
|
|
|
|
Password = null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
server.LoadAsync(applicationName, configSectionName).ConfigureAwait(false);
|
|
|
|
|
server.CheckCertificateAsync(false).ConfigureAwait(false);
|
|
|
|
|
server.StartAsync().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-24 06:22:45 +00:00
|
|
|
|
public void Dispose()
|
2021-12-23 08:22:03 +00:00
|
|
|
|
{
|
|
|
|
|
server.StopAsync().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|