OPC UA Server Module¶
🌐 Expose Your Data
The OPC UA Server Module manages PyAutomation's embedded OPC UA Server, which exposes your automation data (tags, alarms, and state machines) to external OPC UA clients such as SCADA systems, HMIs, and other industrial automation applications.
What is an OPC UA Server?¶
An OPC UA Server in PyAutomation is an embedded server that makes your process data available to external systems through the OPC UA (Open Platform Communications Unified Architecture) protocol. This enables seamless integration with third-party applications that need to read tag values, monitor alarm states, or access machine information.
Key Features¶
- Embedded Server: Runs as a state machine within PyAutomation, automatically updating exposed data
- Three Main Folders: Organizes data into CVT (Current Value Table), Alarms, and Engines (State Machines)
- Real-Time Updates: Continuously publishes current values, alarm states, and machine statuses
- Access Control: Configure read/write permissions for each exposed variable
- Standard Protocol: Uses industry-standard OPC UA for maximum compatibility
Module Overview¶
The OPC UA Server Module provides a user interface to:
- View all exposed variables and their current values
- Configure access permissions (Read, Write, ReadWrite) for each variable
- Monitor server status and connection information
- Manage the server's address space structure
Understanding the Address Space¶
PyAutomation's OPC UA Server organizes data into three main folders:
CVT Folder¶
Contains all tags from the Current Value Table (CVT), representing process variables, sensor readings, and control parameters.
- Structure: Each tag is exposed as a variable node
- Updates: Values update in real-time as tags change
- Namespace Format: Tags are organized by their namespace identifiers
Alarms Folder¶
Contains all active alarms and their current states.
- Structure: Each alarm is exposed as a variable node
- Updates: Alarm states update automatically when alarms transition
- Information: Includes alarm name, state, and associated tag information
Engines Folder¶
Contains all state machines (engines) running in the system.
- Structure: Each machine is exposed with its current state
- Updates: Machine states update as state transitions occur
- Information: Includes machine name, current state, and execution interval
Accessing the OPC UA Server Module¶
- Navigate to OPC UA Server from the main menu
- The dashboard displays all exposed attributes in a paginated table
- Each row shows an attribute's namespace, name, current value, and access type
Viewing Exposed Attributes¶
The main table displays all variables exposed by the OPC UA Server:
Table Columns¶
- Namespace: The OPC UA Node ID in format
ns=<namespace>;i=<identifier>orns=<namespace>;s=<string> - Name: The display name of the variable (tag name, alarm name, or machine name)
- Value: The current value of the variable (updated in real-time)
- Access Type: Current permission level (Read, Write, or ReadWrite)
- Actions: Dropdown menu to change the access type
Configuring Access Types¶
Access types determine what operations external OPC UA clients can perform on each variable:
Read¶
- Permission: External clients can only read the variable value
- Use Case: For tags and alarms that should be monitored but not modified externally
- Security: Prevents accidental or unauthorized changes to process variables
Write¶
- Permission: External clients can only write to the variable (typically not used for tags)
- Use Case: For control parameters that external systems need to set
- Note: Write-only access is rarely used in practice
ReadWrite¶
- Permission: External clients can both read and write the variable
- Use Case: For setpoints, control parameters, or configuration values that external systems need to read and modify
- Security Consideration: Use with caution; ensure proper access control in external systems
Changing Access Type¶
To modify the access type for a variable:
- Locate the variable in the attributes table
- Click on the Access Type dropdown in the Actions column
- Select the desired access type (Read, Write, or ReadWrite)
- A confirmation dialog will appear showing:
- Variable name
- Current access type
- New access type
- Click Confirm to apply the change
- The change takes effect immediately
Server Configuration¶
Endpoint Information¶
The OPC UA Server runs on a configurable endpoint:
- Default Endpoint:
opc.tcp://0.0.0.0:53530/OPCUAServer/ - Port: Configurable via environment variable
OPCUA_SERVER_PORT(default: 53530) - Network Interface:
0.0.0.0means the server listens on all network interfaces
Connecting External Clients¶
To connect an external OPC UA client to PyAutomation's server:
- Obtain Server Address: Use the IP address or hostname of the machine running PyAutomation
- Use Correct Port: Ensure the port matches your configuration (default: 53530)
- Endpoint URL: Use format
opc.tcp://<server_address>:<port>/OPCUAServer/ - Example:
opc.tcp://192.168.1.100:53530/OPCUAServer/
Pagination¶
When many attributes are exposed, the table uses pagination:
- Items Per Page: 10 attributes per page (default)
- Navigation: Use Previous/Next buttons or page numbers to navigate
- Current Page Indicator: Shows current page and total pages
Real-Time Updates¶
The OPC UA Server continuously updates exposed values:
- Tag Values: Update as tags receive new data from OPC UA clients or internal processes
- Alarm States: Update when alarms transition between states
- Machine States: Update when state machines change states
- Update Frequency: Matches the execution interval of the OPCUAServer state machine
Best Practices¶
Access Type Configuration¶
- Default to Read: Most tags and alarms should be Read-only to prevent unauthorized modifications
- Use ReadWrite Sparingly: Only enable ReadWrite for variables that external systems legitimately need to modify
- Document Changes: Keep records of access type changes for audit purposes
- Review Regularly: Periodically review access types to ensure they match current requirements
Security Considerations¶
- Network Security: Ensure the OPC UA Server port is protected by firewall rules
- Access Control: Use Read-only access for most variables to prevent unauthorized changes
- Monitoring: Monitor access type changes through the Events module
- Documentation: Document which external systems require write access and why
Performance¶
- Limit Exposed Variables: Only expose variables that external systems actually need
- Update Frequency: The server updates at its configured interval; adjust if needed
- Network Bandwidth: Consider network capacity when exposing many variables
Troubleshooting¶
External Client Cannot Connect¶
If an external OPC UA client cannot connect to the server:
- Verify Server Status: Check that the OPCUAServer state machine is running
- Check Network: Ensure the server machine is accessible on the network
- Verify Port: Confirm the port number matches your configuration
- Firewall: Check that firewall rules allow connections on the OPC UA port
- Endpoint URL: Verify the endpoint URL format is correct
Values Not Updating¶
If exposed values are not updating:
- Check State Machine: Verify the OPCUAServer state machine is in "Running" state
- Verify Source Data: Ensure tags/alarms/machines are active and updating
- Check Interval: Review the OPCUAServer execution interval in the Machines module
Access Type Changes Not Applied¶
If access type changes don't take effect:
- Refresh Page: Reload the OPC UA Server page
- Check Permissions: Verify you have permission to modify server configuration
- Review Events: Check the Events module for error messages
Integration with Other Modules¶
The OPC UA Server integrates with:
- Tags Module: Exposes all CVT tags to external clients
- Alarms Module: Exposes alarm states and information
- Machines Module: The OPCUAServer itself is a state machine that can be monitored
- Events Module: Access type changes are logged as events
Getting Started¶
To begin using the OPC UA Server:
-
Verify Server Status:
- Navigate to the Machines module
- Confirm the "OPCUAServer" machine is in "Running" state
-
Access the Module:
- Navigate to OPC UA Server from the main menu
- Review the list of exposed attributes
-
Configure Access Types:
- Review each attribute's access type
- Modify access types as needed for your integration requirements
-
Connect External Clients:
- Use the endpoint URL to connect external OPC UA clients
- Browse the CVT, Alarms, and Engines folders
- Subscribe to or read variables as needed
-
Monitor and Maintain:
- Regularly review exposed attributes
- Monitor access type changes through Events
- Ensure server remains in Running state