Skip to content

Commit 553f25c

Browse files
Merge pull request #10 from ISISComputingGroup/OPCUA
Create OPCUA.md
2 parents 63aa907 + 42d478c commit 553f25c

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# MAPS Vacuum System
2+
MAPS vacuum system is set up as two TPGs communicating via a single OMRON [OPC UA](OPCUA) PLC
3+
4+
## OPI
5+
As this system is two TPG300s, one to measure the pressure tank, and another for other miscellaneous readings, the OPI for this system is two linking containers to a modified TPG300 OPI. Sunil Patel, the vacuum specialist, made a requirement that TPG (and likely other pressure controllers) cannot have their pressure, nor any other setpoint, set by the OPI. This means that for this OPI, those changes have already been made, and all values are read-only, except for the units which can be set between mbar, Torr, and Pa.
6+
7+
## Contacts
8+
The main contact for information about this system is the Instrumentation and Control Systems Group, under Tim Carter

doc/specific_iocs/plcs/OPCUA.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# OPC UA
2+
## General / What is OPC UA
3+
OPC UA is a cross-platform, open-source, IEC62541 standard for data exchange from sensors to cloud applications developed by the OPC Foundation. It is characterised by:
4+
5+
* Standardized data models freely available for over 60 types of industrial equipment, published by the OPC Foundation via Companion Specifications
6+
* Extensible security profiles, including authentication, authorization, encryption and checksums
7+
* Extensible security key management, including X.509, token and password
8+
* Support for both client-server and publish-subscribe communication patterns
9+
* Communication protocol independent. Mappings to several communication protocols like TCP/IP, UDP/
10+
IP, WebSockets, AMQP and MQTT are specified
11+
* Initially successful in standardized data exchange with industrial equipment (discrete manufacturing, process manufacturing, energy) and systems for data collection and control, but now also leveraged in building automation, weighing and kitchen equipment and cloud applications
12+
* [Open](https://en.wikipedia.org/wiki/Open_standard) – open-source reference implementations freely available to OPC Foundation members, non members under GPL 2.0 license[2]
13+
* [Cross-platform](https://en.wikipedia.org/wiki/Cross-platform) – not tied to one operating system or programming language
14+
* [Service-oriented architecture](https://en.wikipedia.org/wiki/Service-oriented_architecture) (SOA)
15+
* The specification is freely available on the OPC Foundation website and is split into several parts
16+
to ease implementation, but only OPC UA stack vendors need to read them, end users simply leverage
17+
existing commercial and/or open-source stacks available in all popular programming languages
18+
19+
More info can be found [here on Wikipedia for a general overview](https://en.wikipedia.org/wiki/OPC_Unified_Architecture), or for a more detailed description from [OPC Foundation](https://opcfoundation.org/about/what-is-opc/).
20+
21+
## Authentication
22+
### How is authentication handled?
23+
Currently, the IOC does not seem to be able to support encrypted message security policy. It does, however, support “None” security mode, and connecting with a username and password, which also appears to require sending the password encrypted with Basic256 (username and password connection works with None security mode, but does not work if there is no certificate and private key provided via the `opcuaCLientCertificate` option in the `st-common.cmd` or `st.cmd` file, which loads the IOC with some other options, such as IP address, node configuration, namespace address, etc. More information on the EPICS OPC UA module can be found here: [EPICS OPC UA Documentation](https://github.com/epics-modules/opcua?tab=readme-ov-file#documentation).
24+
25+
Authentication configurations in Windows only seem to work with username and password. This is likely due to functionality missing from the `open62541` library, the open source library that we use in conjunction with `opcua` EPICS module. A username and password is set on the PLC itself, and those values can be read at IOC startup to authenticate, and sent via Basic256 encryption to the PLC to sign in. When implementing/installing onto a new instrument, the `client_private_key.pem` (which needs to either be generated, or gotten from the appropriate instrument's `OPCUA` folder from the private network shares), `cert.txt` (which will need to be edited to reflect current username and password for the target PLC/server), and `OPCUA_01.cmd` should be moved from the Experiment Controls private network share `OPCUA` folder, to the instrument's configurations area, in a new folder that should be named `opcua`. If done properly, the `opcua` EPICS module should be able to pick up the user name and password, log in to the OPC server properly, and begin a connection.
26+
27+
## Communication
28+
### Do any settings in the PLC side need to be adjusted to get communicating properly?
29+
On occasion, a client certificate needs to be trusted manually, from the PLC technician side. However, things *_should_* be set up on our PLCs currently deployed; this step is done in deployment/implementation. A security policy might be set that is not what the IOC is trying to use, if everything else seems fine but you are unable to connect. Lastly, another person might be connected to the server (perhaps testing an IOC or something), and they would need to be kicked off in order for the IOC to communicate properly. Speak with Tim Carter or a member of the team, Instrumentation and Control Systems Group, to see if this is the case.
30+
31+
## Configuration
32+
### Where are instrument-specific configs loaded from
33+
We load instrument specific configs from the $(INSTRUMENT)/configurations/opcua/ folder. This `opcua` folder is created at implementation time, on the `NDX` machine. It should contain a `OPCUA_01.cmd` file, which contains any `dbLoadRecords` calls, and where paths are specified to the `db` files for that `NDX`'s specific `OPCUA` IOC. If an `NDX` is missing an `opcua` folder, create one; if you cannot find it's `OPCUA_01.cmd` file, it _should_ be placed in the Experiment Controls private network share, in the `OPCUA` folder, in a folder specific to that `NDX`. For example, `NDXMAPS`'s `OPCUA_01.cmd` file is in `<network share>/OPCUA/MAPS_OPCUA/`.
34+
35+
### Where are instrument-specific DBs defined
36+
Instrument specific `db` files are currently defined in `ioc/master/OPCUA/OPCUA-IOC-01App/Db`. Hence, the `db` files should have somewhat specific names so as to avoid confusion.
37+
38+
## Troubleshooting
39+
As always, be sure to check the IOC log first, if something isn't working properly. If the IOC has connected properly to the server, the IOC log should print out something like the following:
40+
```
41+
# namespace 4 urn:OMRON:SomeOpcUaServer:FactoryAutomation
42+
43+
Structure TPG_Gauge { # binaryEncodingId: ns=4;i=5002
44+
Float Pressure # mandatory opc:Float
45+
# memberSize=4 alignment=4 padding=0 memSize=4
46+
Float Lower_Threshold # mandatory opc:Float
47+
# memberSize=4 alignment=4 padding=0 memSize=8
48+
Float Upper_Threshold # mandatory opc:Float
49+
# memberSize=4 alignment=4 padding=0 memSize=12
50+
String Measured_Value_Status # mandatory opc:CharArray
51+
# memberSize=16 alignment=8 padding=4 memSize=32
52+
String Measuring_Circuit_Status # mandatory opc:CharArray
53+
# memberSize=16 alignment=8 padding=0 memSize=48
54+
String Switching_Function_Assignment # mandatory opc:CharArray
55+
# memberSize=16 alignment=8 padding=0 memSize=64
56+
String Switching_Function_Status # mandatory opc:CharArray
57+
# memberSize=16 alignment=8 padding=0 memSize=80
58+
String Filter_Time_Constant # mandatory opc:CharArray
59+
# memberSize=16 alignment=8 padding=0 memSize=96
60+
}; # alignment=8 memSize=96 8 members
61+
# adding type TPG_Gauge to known types
62+
```
63+
Which means that the IOC has read data properly from the server and has a good connection.
64+
65+
You will then see output like this, near the bottom of the IOC log:
66+
67+
```
68+
** Session OPC1: (readComplete) getting data for item ns=4;s=Opc_TPG2_Sensor_B2.Measuring_Circuit_Status = "No measuring channel" (String) Good
69+
** Session OPC1: (readComplete) getting data for item ns=4;s=Opc_TPG2_Sensor_B1.Switching_Function_Assignment = "No assignment" (String) Good
70+
** Session OPC1: (readComplete) getting data for item ns=4;s=Opc_TPG2_Sensor_B1.Switching_Function_Status = "Off" (String) Good
71+
** Session OPC1: (readComplete) getting data for item ns=4;s=Opc_TPG2_Sensor_B1.Filter_Time_Constant = "Slow" (String) Good
72+
```
73+
74+
If you don't see this sort of read out at the end of the IOC log, you'll know that something has gone wrong, and likely there is a repeated output that signifies attempts to connect to the server.
75+
76+
An example of BadInternalError IOC output, which can usually be caused by username and password not being read properly, or the paths not being set properly in the `OPCUA_01.cmd` file, looks like this:
77+
78+
```
79+
OPC UA: Autoconnecting sessions
80+
Session OPC1: (initClientSecurity) loading client certificate C:/Instrument/Settings/config/<NDX###>/configurations/opcua/client_cert.der
81+
Session OPC1: (initClientSecurity) loading client private key C:/Instrument/Settings/config/<NDX###>/configurations/opcua/client_private_key.pem
82+
[2025-05-06 08:48:55.699 (UTC+0100)] warn/userland AcceptAll Certificate Verification. Any remote certificate will be accepted.
83+
[2025-05-06 08:48:55.705 (UTC+0100)] info/securitypolicy The Basic128Rsa15 security policy with openssl is added.
84+
[2025-05-06 08:48:55.711 (UTC+0100)] info/securitypolicy The basic256 security policy with openssl is added.
85+
[2025-05-06 08:48:55.716 (UTC+0100)] info/securitypolicy The basic256sha256 security policy with openssl is added.
86+
[2025-05-06 08:48:55.723 (UTC+0100)] info/securitypolicy The Aes128Sha256RsaOaep security policy with openssl is added.
87+
OPC UA session OPC1: cannot open credentials file C
88+
OPC UA session OPC1: credentials file C does not contain settings for Username token (user + pass) or Certificate token (cert + key [+ pass])
89+
Session OPC1: (setupSecurity) no security configured
90+
[2025-05-06 08:48:55.736 (UTC+0100)] warn/client The configured ApplicationURI does not match the URI specified in the certificate for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None
91+
[2025-05-06 08:48:55.743 (UTC+0100)] warn/client The configured ApplicationURI does not match the URI specified in the certificate for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15
92+
[2025-05-06 08:48:55.751 (UTC+0100)] warn/client The configured ApplicationURI does not match the URI specified in the certificate for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#Basic256
93+
[2025-05-06 08:48:55.759 (UTC+0100)] warn/client The configured ApplicationURI does not match the URI specified in the certificate for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
94+
[2025-05-06 08:48:55.766 (UTC+0100)] warn/client The configured ApplicationURI does not match the URI specified in the certificate for the SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep
95+
Session OPC1: secure channel state changed from Closed to HelSent
96+
Session OPC1: secure channel state changed from HelSent to AckReceived
97+
Session OPC1: secure channel state changed from AckReceived to OPNSent
98+
[2025-05-06 08:48:55.785 (UTC+0100)] info/channel Connection 1704 | SecureChannel 140237378 | SecureChannel opened with SecurityPolicy http://opcfoundation.org/UA/SecurityPolicy#None and a revised lifetime of 600.00s
99+
[2025-05-06 08:48:55.792 (UTC+0100)] info/client Client Status: ChannelState: Open, SessionState: Closed, ConnectStatus: Good
100+
Session OPC1: secure channel state changed from OPNSent to Open
101+
[2025-05-06 08:48:55.801 (UTC+0100)] info/client The initially defined EndpointURL opc.tcp://0.0.0.0:4080is valid for the server
102+
[2025-05-06 08:48:55.810 (UTC+0100)] info/client Rejecting UserTokenPolicy 0 (username) in endpoint 0: configuration doesn't match
103+
[2025-05-06 08:48:55.813 (UTC+0100)] info/client Rejecting endpoint 1: security mode doesn't match
104+
[2025-05-06 08:48:55.818 (UTC+0100)] info/client Rejecting endpoint 2: security mode doesn't match
105+
[2025-05-06 08:48:55.822 (UTC+0100)] error/client No suitable UserTokenPolicy found for the possible endpoints
106+
[2025-05-06 08:48:55.825 (UTC+0100)] info/client Client Status: ChannelState: Closed, SessionState: Closed, ConnectStatus: BadInternalError
107+
Session OPC1 irrecoverably failed: BadInternalError
108+
OPC UA session OPC1: connect service failed with status BadInternalError
109+
```
110+
This output will often repeat, as the client/IOC continually tries to connect to the server/PLC.
111+
112+
You'll see that the IOC gets quite close to connecting, as it goes from `Closed` to `HelSent`, or "hello sent", then from `HelSent` to `AckReceived`, meaning it receives an acknowledgement, and then moves to `OPNSent`, sending a message to open the connection, which then fails on configuration mismatch. More information about the [OPC UA Connection protocol can be found here](https://reference.opcfoundation.org/Core/Part6/v105/docs/7.1).

doc/spelling_wordlist.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Chakraborty
113113
checkboxes
114114
checkRelease
115115
checkstyle
116+
checksums
116117
Chell
117118
Chrono
118119
Chronus
@@ -580,6 +581,8 @@ Omron
580581
onboarding
581582
Onenote
582583
onwards
584+
opc
585+
opcua
583586
openjfx
584587
openssl
585588
openwire
@@ -798,6 +801,7 @@ subVI
798801
Sudeepta
799802
sudo
800803
Sumitomo
804+
Sunil
801805
Superlogics
802806
supermirror
803807
supermirrors
@@ -857,6 +861,7 @@ TTi
857861
Turbotronik
858862
TwinCAT
859863
txt
864+
ua
860865
uA
861866
uamps
862867
UC

0 commit comments

Comments
 (0)