OPC DB server Project First Commit

This commit is contained in:
2026-02-09 02:55:47 +00:00
commit 3181052619
53 changed files with 5719 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.5.378.106" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.5.378.106" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,191 @@
// cd ~/projects/OpcConnectionTest
// 기존 파일 삭제
// rm Program.cs
// # 새 파일 생성
//cat > Program.cs << 'EOF'
using Opc.Ua;
using Opc.Ua.Client;
using Opc.Ua.Configuration;
namespace OpcConnectionTest
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("=== Experion OPC UA Connection Test ===\n");
// ⚠️ Experion 서버 IP 주소 수정
string primaryEndpoint = "opc.tcp://192.168.0.20:4840";
string secondaryEndpoint = "opc.tcp://192.168.1.20:4840";
Console.WriteLine($"Primary: {primaryEndpoint}");
Console.WriteLine($"Secondary: {secondaryEndpoint}\n");
ISession? session = null;
try
{
var config = new ApplicationConfiguration()
{
ApplicationName = "OPC Test",
ApplicationType = ApplicationType.Client,
ApplicationUri = "urn:OpcTest",
SecurityConfiguration = new SecurityConfiguration
{
ApplicationCertificate = new CertificateIdentifier
{
StoreType = "Directory",
StorePath = "OPC Foundation/CertificateStores/MachineDefault"
},
AutoAcceptUntrustedCertificates = true,
RejectSHA1SignedCertificates = false
},
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 15000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }
};
await config.ValidateAsync(ApplicationType.Client);
Console.WriteLine("Step 1: Discovering endpoints...");
var endpoints = await DiscoverAsync(config, primaryEndpoint);
if (endpoints.Count == 0)
{
Console.WriteLine("❌ No endpoints found!");
return;
}
Console.WriteLine($"✅ Found {endpoints.Count} endpoint(s)");
Console.WriteLine("\nStep 2: Connecting...");
session = await ConnectAsync(config, endpoints[0]);
if (session == null)
{
Console.WriteLine("❌ Connection failed!");
return;
}
Console.WriteLine($"✅ Connected! ID: {session.SessionId}");
Console.WriteLine("\nStep 3: Reading server info...");
await ReadInfoAsync(session);
Console.WriteLine("\nStep 4: Checking redundancy...");
await CheckRedundancyAsync(session);
Console.WriteLine("\n✅ Test completed!");
}
catch (Exception ex)
{
Console.WriteLine($"\n❌ Error: {ex.Message}");
}
finally
{
if (session != null)
{
await session.CloseAsync();
session.Dispose();
}
}
Console.WriteLine("\nPress Enter to exit...");
Console.ReadLine();
}
static async Task<EndpointDescriptionCollection> DiscoverAsync(
ApplicationConfiguration config, string url)
{
try
{
var epConfig = EndpointConfiguration.Create(config);
epConfig.OperationTimeout = 10000;
var client = await DiscoveryClient.CreateAsync(
new Uri(url), epConfig, config,
DiagnosticsMasks.None, CancellationToken.None);
var eps = await client.GetEndpointsAsync(null);
client.Dispose();
return eps;
}
catch
{
return new EndpointDescriptionCollection();
}
}
static async Task<ISession?> ConnectAsync(
ApplicationConfiguration config, EndpointDescription ep)
{
try
{
var epConfig = EndpointConfiguration.Create(config);
var configEp = new ConfiguredEndpoint(null, ep, epConfig);
var channel = SessionChannel.Create(
config,
configEp.Description,
configEp.Configuration,
X509CertificateValidator.TolerateAll,
null);
var sess = new Session(channel, config, configEp, null);
await sess.OpenAsync(
config.ApplicationName, 60000,
new UserIdentity(new AnonymousIdentityToken()),
null, CancellationToken.None);
return sess;
}
catch
{
return null;
}
}
static async Task ReadInfoAsync(ISession s)
{
try
{
var v1 = await s.ReadValueAsync(new NodeId(Variables.Server_ServerStatus_State));
Console.WriteLine($" State: {v1.Value}");
var v2 = await s.ReadValueAsync(new NodeId(Variables.Server_ServerStatus_CurrentTime));
Console.WriteLine($" Time: {v2.Value}");
}
catch (Exception ex)
{
Console.WriteLine($" Failed: {ex.Message}");
}
}
static async Task CheckRedundancyAsync(ISession s)
{
try
{
var v = await s.ReadValueAsync(new NodeId(Variables.Server_ServiceLevel));
byte level = Convert.ToByte(v.Value);
Console.WriteLine($" Service Level: {level}");
if (level >= 200)
Console.WriteLine(" ✅ PRIMARY server");
else if (level > 0)
Console.WriteLine(" ⚠️ SECONDARY server");
else
Console.WriteLine(" STANDALONE");
}
catch (Exception ex)
{
Console.WriteLine($" Failed: {ex.Message}");
}
}
}
}

View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "8.0.123"
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("OpcConnectionTest")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("OpcConnectionTest")]
[assembly: System.Reflection.AssemblyTitleAttribute("OpcConnectionTest")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
934b875e72b64b90c5572e45c51a754c2d824022123ba85dea23cfc05669d35b

View File

@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = OpcConnectionTest
build_property.ProjectDir = /home/pacer/projects/OpcConnectionTest/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
859302d0d0eef299017c6ba5eb484ad68daade90e3fd76bac845760289b34007

View File

@@ -0,0 +1,5 @@
/home/pacer/projects/OpcConnectionTest/obj/Debug/net8.0/OpcConnectionTest.csproj.AssemblyReference.cache
/home/pacer/projects/OpcConnectionTest/obj/Debug/net8.0/OpcConnectionTest.GeneratedMSBuildEditorConfig.editorconfig
/home/pacer/projects/OpcConnectionTest/obj/Debug/net8.0/OpcConnectionTest.AssemblyInfoInputs.cache
/home/pacer/projects/OpcConnectionTest/obj/Debug/net8.0/OpcConnectionTest.AssemblyInfo.cs
/home/pacer/projects/OpcConnectionTest/obj/Debug/net8.0/OpcConnectionTest.csproj.CoreCompileInputs.cache

View File

@@ -0,0 +1,71 @@
{
"format": 1,
"restore": {
"/home/pacer/projects/OpcConnectionTest/OpcConnectionTest.csproj": {}
},
"projects": {
"/home/pacer/projects/OpcConnectionTest/OpcConnectionTest.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/pacer/projects/OpcConnectionTest/OpcConnectionTest.csproj",
"projectName": "OpcConnectionTest",
"projectPath": "/home/pacer/projects/OpcConnectionTest/OpcConnectionTest.csproj",
"packagesPath": "/home/pacer/.nuget/packages/",
"outputPath": "/home/pacer/projects/OpcConnectionTest/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/pacer/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"OPCFoundation.NetStandard.Opc.Ua": {
"target": "Package",
"version": "[1.5.378.106, )"
},
"OPCFoundation.NetStandard.Opc.Ua.Client": {
"target": "Package",
"version": "[1.5.378.106, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/8.0.123/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/pacer/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/pacer/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.8.1</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/pacer/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)system.text.json/10.0.2/buildTransitive/net8.0/System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json/10.0.2/buildTransitive/net8.0/System.Text.Json.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/10.0.2/buildTransitive/net8.0/Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/10.0.2/buildTransitive/net8.0/Microsoft.Extensions.Logging.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.options/10.0.2/buildTransitive/net8.0/Microsoft.Extensions.Options.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.options/10.0.2/buildTransitive/net8.0/Microsoft.Extensions.Options.targets')" />
</ImportGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
{
"version": 2,
"dgSpecHash": "KrguJvkD41Un9qS/sxFwULOR3owX1Gzwg9Kz5TmdqikJypnpz2UYGOX4knjW3w4fcsh2k1y/V+pMLyI7ALdxig==",
"success": true,
"projectFilePath": "/home/pacer/projects/OpcConnectionTest/OpcConnectionTest.csproj",
"expectedPackageFiles": [
"/home/pacer/.nuget/packages/bitfaster.caching/2.5.4/bitfaster.caching.2.5.4.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.dependencyinjection/10.0.2/microsoft.extensions.dependencyinjection.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.dependencyinjection.abstractions/10.0.2/microsoft.extensions.dependencyinjection.abstractions.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.logging/10.0.2/microsoft.extensions.logging.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.logging.abstractions/10.0.2/microsoft.extensions.logging.abstractions.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.options/10.0.2/microsoft.extensions.options.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/microsoft.extensions.primitives/10.0.2/microsoft.extensions.primitives.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/newtonsoft.json/13.0.4/newtonsoft.json.13.0.4.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua/1.5.378.106/opcfoundation.netstandard.opc.ua.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.client/1.5.378.106/opcfoundation.netstandard.opc.ua.client.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.configuration/1.5.378.106/opcfoundation.netstandard.opc.ua.configuration.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.core/1.5.378.106/opcfoundation.netstandard.opc.ua.core.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.gds.client.common/1.5.378.106/opcfoundation.netstandard.opc.ua.gds.client.common.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.gds.server.common/1.5.378.106/opcfoundation.netstandard.opc.ua.gds.server.common.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.security.certificates/1.5.378.106/opcfoundation.netstandard.opc.ua.security.certificates.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.server/1.5.378.106/opcfoundation.netstandard.opc.ua.server.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/opcfoundation.netstandard.opc.ua.types/1.5.378.106/opcfoundation.netstandard.opc.ua.types.1.5.378.106.nupkg.sha512",
"/home/pacer/.nuget/packages/system.collections.immutable/10.0.2/system.collections.immutable.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/system.diagnostics.diagnosticsource/10.0.2/system.diagnostics.diagnosticsource.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/system.formats.asn1/10.0.2/system.formats.asn1.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/system.io.pipelines/10.0.2/system.io.pipelines.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/system.text.encodings.web/10.0.2/system.text.encodings.web.10.0.2.nupkg.sha512",
"/home/pacer/.nuget/packages/system.text.json/10.0.2/system.text.json.10.0.2.nupkg.sha512"
],
"logs": []
}