Files
dbserver/.Notebook/Nuget에 OPC UA 라이브러리설치.md

1.6 KiB
Raw Blame History

1 프로젝트 폴더에서 NuGet 설치

터미널에서 프로젝트 디렉토리로 이동:

cd ~/projects/DbTest

패키지 설치:

dotnet add package OPCFoundation.NetStandard.Opc.Ua

이 명령어가 NuGet에서 라이브러리 다운로드 + 프로젝트에 추가까지 해줌

설치 후 출력 메시지에 Successfully added 확인

2 설치 확인 dotnet list package

출력 예시:

Project 'DbTest' has the following package references [net8.0]: Top-level Package Requested Resolved

OPCFoundation.NetStandard.Opc.Ua 1.4.365 1.4.365

3 테스트 코드

설치 완료 후 간단한 OPC UA 연결 테스트 작성 가능:

using Opc.Ua; using Opc.Ua.Client; using Opc.Ua.Configuration;

class Program { static async Task Main() { var config = new ApplicationConfiguration { ApplicationName = "ExperionClient", ApplicationType = ApplicationType.Client, SecurityConfiguration = new SecurityConfiguration { ApplicationCertificate = new CertificateIdentifier() }, ClientConfiguration = new ClientConfiguration() }; await config.Validate(ApplicationType.Client);

    var endpointURL = "opc.tcp://<EXPERION_IP>:4840";
    var selectedEndpoint = CoreClientUtils.SelectEndpoint(endpointURL, useSecurity: false);
    var session = await Session.Create(config,
        new ConfiguredEndpoint(null, selectedEndpoint, EndpointConfiguration.Create(config)),
        false, "", 60000, null, null);

    Console.WriteLine("Experion OPC UA 연결 성공!");
}

}