CalejoControl/test_opcua_endpoints.py

55 lines
1.4 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
"""
Test script to check what OPC UA endpoints are available.
"""
import asyncio
import sys
import os
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from asyncua import Client
async def test_opcua_endpoints():
"""Test OPC UA server endpoints."""
print("Testing OPC UA server endpoints...")
try:
client = Client(url="opc.tcp://localhost:4840")
# Try to get available endpoints
print("Getting available endpoints...")
endpoints = await client.get_endpoints()
print(f"Found {len(endpoints)} endpoints:")
for i, endpoint in enumerate(endpoints):
print(f"\nEndpoint {i+1}:")
print(f" Endpoint URL: {endpoint.EndpointUrl}")
print(f" Security Mode: {endpoint.SecurityMode}")
print(f" Security Policy URI: {endpoint.SecurityPolicyUri}")
print(f" Transport Profile URI: {endpoint.TransportProfileUri}")
await client.disconnect()
except Exception as e:
print(f"Error getting endpoints: {e}")
async def main():
"""Run the test."""
print("=" * 50)
print("OPC UA Endpoints Test")
print("=" * 50)
await test_opcua_endpoints()
print("\n" + "=" * 50)
print("Test completed")
print("=" * 50)
if __name__ == "__main__":
asyncio.run(main())