diff --git a/src/.vuepress/public/img/opc-ua-new-1-en.png b/src/.vuepress/public/img/opc-ua-new-1-en.png new file mode 100644 index 000000000..f6b1f8a0e Binary files /dev/null and b/src/.vuepress/public/img/opc-ua-new-1-en.png differ diff --git a/src/.vuepress/public/img/opc-ua-new-1.png b/src/.vuepress/public/img/opc-ua-new-1.png new file mode 100644 index 000000000..d050e0f24 Binary files /dev/null and b/src/.vuepress/public/img/opc-ua-new-1.png differ diff --git a/src/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md b/src/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md index a638f0f6d..47a6ce5b2 100644 --- a/src/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md +++ b/src/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md @@ -21,55 +21,19 @@ # OPC UA Protocol -## 1. OPC UA +## 1. OPC UA Subscription Data -OPC UA is a technical specification used in the automation field for communication between different devices and systems, enabling cross platform, cross language, and cross network operations, providing a reliable and secure data exchange foundation for the Industrial Internet of Things. IoTDB supports OPC UA protocol, and IoTDB OPC Server supports both Client/Server and Pub/Sub communication modes. +This feature allows users to subscribe to data from IoTDB using the OPC UA protocol. The communication modes for subscription data support both Client/Server and Pub/Sub. -### 1.1 OPC UA Client/Server Mode +Note: This feature is not about collecting data from external OPC Servers and writing it into IoTDB. -- **Client/Server Mode**:In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. +![](/img/opc-ua-new-1-en.png) -
- -
- - -- Features: - - - OPC UA will organize the device information received from Sink into folders under the Objects folder according to a tree model. - - - Each measurement point is recorded as a variable node and the latest value in the current database is recorded. - -### 1.2 OPC UA Pub/Sub Mode - -- **Pub/Sub Mode**: In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. - -
- -
- -- Features: - - - Each measurement point is wrapped as an Event Node in OPC UA. - - - - The relevant fields and their meanings are as follows: - - | Field | Meaning | Type (Milo) | Example | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | Timestamp | DateTime | 1698907326198 | - | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | - | SourceNode | Data type of the measurement point | NodeId | Int32 | - | Message | Data | LocalizedText | 3.0 | - - - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. - - -## 2. IoTDB OPC Server Startup method +## 2. OPC Service Startup Method ### 2.1 Syntax -The syntax for creating the Sink is as follows: +The syntax to start the OPC UA protocol: ```SQL @@ -110,31 +74,29 @@ start pipe p1; ### 2.4 Usage Limitations -1. **DataRegion Requirement**: The OPC UA server will only start if there is a DataRegion in IoTDB. For an empty IoTDB, a data entry is necessary for the OPC UA server to become effective. - -2. **Data Availability**: Clients subscribing to the server will not receive data written to IoTDB before their connection. +1. After starting the protocol, data needs to be written to establish a connection. Only data after the connection is established can be subscribed to. +2. Recommended for use in standalone mode. In distributed mode, each IoTDB DataNode acts as an independent OPC Server providing data and requires separate subscription. -3. **Multiple DataNodes may have scattered sending/conflict issues**: +## 3. Examples of Two Communication Modes - - For IoTDB clusters with multiple dataRegions and scattered across different DataNode IPs, data will be sent in a dispersed manner on the leaders of the dataRegions. The client needs to listen to the configuration ports of the DataNode IP separately.。 - - - Suggest using this OPC UA server under 1C1D. - -4. **Does not support deleting data and modifying measurement point types:** In Client Server mode, OPC UA cannot delete data or change data type settings. In Pub Sub mode, if data is deleted, information cannot be pushed to the client. +### 3.1 Client / Server Mode -## 3. IoTDB OPC Server Example +In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. -### 3.1 Client / Server Mode +* Features: + * OPC UA organizes device information received from the Sink into folders under the Objects folder according to a tree model. + * Each measurement point is recorded as a variable node, storing the latest value from the current database. + * OPC UA cannot delete data or change data type settings. -#### Preparation Work +#### 3.1.1 Preparation Work 1. Take UAExpert client as an example, download the UAExpert client: https://www.unified-automation.com/downloads/opc-ua-clients.html 2. Install UAExpert and fill in your own certificate information. -#### Quick Start +#### 3.1.2 Quick Start -1. Use the following SQL to create and start the OPC UA Sink in client-server mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](#syntax) +1. Use the following SQL to create and start the OPC UA Sink in client-server mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](./Programming-OPC-UA_timecho.md#_2-1-syntax) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink'); @@ -176,7 +138,26 @@ insert into root.test.db(time, s2) values(now(), 2) ### 3.2 Pub / Sub Mode -#### Preparation Work +In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. + +- Features: + + - Each measurement point is wrapped as an Event Node in OPC UA. + + - The relevant fields and their meanings are as follows: + + | Field | Meaning | Type (Milo) | Example | + | :--------- | :--------------- | :------------ | :-------------------- | + | Time | Timestamp | DateTime | 1698907326198 | + | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | + | SourceNode | Data type of the measurement point | NodeId | Int32 | + | Message | Data | LocalizedText | 3.0 | + + - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. + - If data is deleted, the information cannot be pushed to clients. + + +#### 3.2.1 Preparation Work The code is located in the [opc-ua-sink package](https://github.com/apache/iotdb/tree/rc/2.0.1/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)under the iotdb-example package. @@ -187,7 +168,7 @@ The code includes: - Client configuration and startup logic(ClientExampleRunner) - The parent class of ClientTest(ClientExample) -### 3.3 Quick Start +#### 3.2.2 Quick Start The steps are as follows: @@ -199,7 +180,7 @@ insert into root.a.b(time, c, d) values(now(), 1, 2); ​ The metadata is automatically created and enabled here. -2. Use the following SQL to create and start the OPC UA Sink in Pub-Sub mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](#syntax) +2. Use the following SQL to create and start the OPC UA Sink in Pub-Sub mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](./Programming-OPC-UA_timecho.md#_2-1-syntax) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink', diff --git a/src/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md b/src/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md index 3c1c026b0..31890ac50 100644 --- a/src/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md +++ b/src/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md @@ -18,56 +18,19 @@ # OPC UA Protocol -## OPC UA +## OPC UA Subscription Data -OPC UA is a technical specification used in the automation field for communication between different devices and systems, enabling cross platform, cross language, and cross network operations, providing a reliable and secure data exchange foundation for the Industrial Internet of Things. IoTDB supports OPC UA protocol, and IoTDB OPC Server supports both Client/Server and Pub/Sub communication modes. +This feature allows users to subscribe to data from IoTDB using the OPC UA protocol. The communication modes for subscription data support both Client/Server and Pub/Sub. -### OPC UA Client/Server Mode +Note: This feature is not about collecting data from external OPC Servers and writing it into IoTDB. -- **Client/Server Mode**:In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. +![](/img/opc-ua-new-1-en.png) -::: center - - - -::: - -- Features: - - - OPC UA will organize the device information received from Sink into folders under the Objects folder according to a tree model. - - - Each measurement point is recorded as a variable node and the latest value in the current database is recorded. - -### OPC UA Pub/Sub Mode - -- **Pub/Sub Mode**: In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. - -::: center - - - -::: - -- Features: - - - Each measurement point is wrapped as an Event Node in OPC UA. - - - The relevant fields and their meanings are as follows: - - | Field | Meaning | Type (Milo) | Example | - | :--------- | :--------------------------------- | :------------ | :-------------------- | - | Time | Timestamp | DateTime | 1698907326198 | - | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | - | SourceNode | Data type of the measurement point | NodeId | Int32 | - | Message | Data | LocalizedText | 3.0 | - - - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. - -## IoTDB OPC Server Startup method +## OPC Service Startup Method ### Syntax -The syntax for creating the Sink is as follows: +The syntax to start the OPC UA protocol: ```sql create pipe p1 @@ -95,7 +58,7 @@ create pipe p1 | sink.user | User for OPC UA, specified in the configuration | String | Optional | root | | sink.password | Password for OPC UA, specified in the configuration | String | Optional | root | -### 示例 +### Example ```Bash create pipe p1 @@ -107,21 +70,20 @@ start pipe p1; ### Usage Limitations -1. **DataRegion Requirement**: The OPC UA server will only start if there is a DataRegion in IoTDB. For an empty IoTDB, a data entry is necessary for the OPC UA server to become effective. - -2. **Data Availability**: Clients subscribing to the server will not receive data written to IoTDB before their connection. - -3. **Multiple DataNodes may have scattered sending/conflict issues**: +1. After starting the protocol, data needs to be written to establish a connection. Only data after the connection is established can be subscribed to. +2. Recommended for use in standalone mode. In distributed mode, each IoTDB DataNode acts as an independent OPC Server providing data and requires separate subscription. - - For IoTDB clusters with multiple dataRegions and scattered across different DataNode IPs, data will be sent in a dispersed manner on the leaders of the dataRegions. The client needs to listen to the configuration ports of the DataNode IP separately.。 - - Suggest using this OPC UA server under 1C1D. +## Examples of Two Communication Modes -4. **Does not support deleting data and modifying measurement point types:** In Client Server mode, OPC UA cannot delete data or change data type settings. In Pub Sub mode, if data is deleted, information cannot be pushed to the client. +### Client / Server Mode -## IoTDB OPC Server Example +In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. -### Client / Server Mode +* Features: + * OPC UA organizes device information received from the Sink into folders under the Objects folder according to a tree model. + * Each measurement point is recorded as a variable node, storing the latest value from the current database. + * OPC UA cannot delete data or change data type settings. #### Preparation Work @@ -181,11 +143,30 @@ start pipe p1; ::: -### Pub / Sub Mode +### Pub / Sub Mode + +In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. + +- Features: + + - Each measurement point is wrapped as an Event Node in OPC UA. + + - The relevant fields and their meanings are as follows: + + | Field | Meaning | Type (Milo) | Example | + | :--------- | :--------------------------------- | :------------ | :-------------------- | + | Time | Timestamp | DateTime | 1698907326198 | + | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | + | SourceNode | Data type of the measurement point | NodeId | Int32 | + | Message | Data | LocalizedText | 3.0 | + + - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. + - If data is deleted, the information cannot be pushed to clients. + #### Preparation Work -The code is located in the [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/1.3.3/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua) under the iotdb-example package. +The code is located in the [opc-ua-sink](https://github.com/apache/iotdb/tree/rc/1.3.5/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua) under the iotdb-example package. The code includes: @@ -194,7 +175,7 @@ The code includes: - Client configuration and startup logic(ClientExampleRunner) - The parent class of ClientTest(ClientExample) -### Quick Start +#### Quick Start The steps are as follows: diff --git a/src/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md b/src/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md index cb98a3bd8..31890ac50 100644 --- a/src/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md +++ b/src/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md @@ -18,56 +18,19 @@ # OPC UA Protocol -## OPC UA +## OPC UA Subscription Data -OPC UA is a technical specification used in the automation field for communication between different devices and systems, enabling cross platform, cross language, and cross network operations, providing a reliable and secure data exchange foundation for the Industrial Internet of Things. IoTDB supports OPC UA protocol, and IoTDB OPC Server supports both Client/Server and Pub/Sub communication modes. +This feature allows users to subscribe to data from IoTDB using the OPC UA protocol. The communication modes for subscription data support both Client/Server and Pub/Sub. -### OPC UA Client/Server Mode +Note: This feature is not about collecting data from external OPC Servers and writing it into IoTDB. -- **Client/Server Mode**:In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. +![](/img/opc-ua-new-1-en.png) -::: center - - - -::: - -- Features: - - - OPC UA will organize the device information received from Sink into folders under the Objects folder according to a tree model. - - - Each measurement point is recorded as a variable node and the latest value in the current database is recorded. - -### OPC UA Pub/Sub Mode - -- **Pub/Sub Mode**: In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. - -::: center - - - -::: - -- Features: - - - Each measurement point is wrapped as an Event Node in OPC UA. - - - The relevant fields and their meanings are as follows: - - | Field | Meaning | Type (Milo) | Example | - | :--------- | :--------------------------------- | :------------ | :-------------------- | - | Time | Timestamp | DateTime | 1698907326198 | - | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | - | SourceNode | Data type of the measurement point | NodeId | Int32 | - | Message | Data | LocalizedText | 3.0 | - - - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. - -## IoTDB OPC Server Startup method +## OPC Service Startup Method ### Syntax -The syntax for creating the Sink is as follows: +The syntax to start the OPC UA protocol: ```sql create pipe p1 @@ -95,7 +58,7 @@ create pipe p1 | sink.user | User for OPC UA, specified in the configuration | String | Optional | root | | sink.password | Password for OPC UA, specified in the configuration | String | Optional | root | -### 示例 +### Example ```Bash create pipe p1 @@ -107,21 +70,20 @@ start pipe p1; ### Usage Limitations -1. **DataRegion Requirement**: The OPC UA server will only start if there is a DataRegion in IoTDB. For an empty IoTDB, a data entry is necessary for the OPC UA server to become effective. - -2. **Data Availability**: Clients subscribing to the server will not receive data written to IoTDB before their connection. - -3. **Multiple DataNodes may have scattered sending/conflict issues**: +1. After starting the protocol, data needs to be written to establish a connection. Only data after the connection is established can be subscribed to. +2. Recommended for use in standalone mode. In distributed mode, each IoTDB DataNode acts as an independent OPC Server providing data and requires separate subscription. - - For IoTDB clusters with multiple dataRegions and scattered across different DataNode IPs, data will be sent in a dispersed manner on the leaders of the dataRegions. The client needs to listen to the configuration ports of the DataNode IP separately.。 - - Suggest using this OPC UA server under 1C1D. +## Examples of Two Communication Modes -4. **Does not support deleting data and modifying measurement point types:** In Client Server mode, OPC UA cannot delete data or change data type settings. In Pub Sub mode, if data is deleted, information cannot be pushed to the client. +### Client / Server Mode -## IoTDB OPC Server Example +In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. -### Client / Server Mode +* Features: + * OPC UA organizes device information received from the Sink into folders under the Objects folder according to a tree model. + * Each measurement point is recorded as a variable node, storing the latest value from the current database. + * OPC UA cannot delete data or change data type settings. #### Preparation Work @@ -181,11 +143,30 @@ start pipe p1; ::: -### Pub / Sub Mode +### Pub / Sub Mode + +In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. + +- Features: + + - Each measurement point is wrapped as an Event Node in OPC UA. + + - The relevant fields and their meanings are as follows: + + | Field | Meaning | Type (Milo) | Example | + | :--------- | :--------------------------------- | :------------ | :-------------------- | + | Time | Timestamp | DateTime | 1698907326198 | + | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | + | SourceNode | Data type of the measurement point | NodeId | Int32 | + | Message | Data | LocalizedText | 3.0 | + + - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. + - If data is deleted, the information cannot be pushed to clients. + #### Preparation Work -The code is located in the [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/master/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua) under the iotdb-example package. +The code is located in the [opc-ua-sink](https://github.com/apache/iotdb/tree/rc/1.3.5/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua) under the iotdb-example package. The code includes: @@ -194,7 +175,7 @@ The code includes: - Client configuration and startup logic(ClientExampleRunner) - The parent class of ClientTest(ClientExample) -### Quick Start +#### Quick Start The steps are as follows: diff --git a/src/UserGuide/latest/API/Programming-OPC-UA_timecho.md b/src/UserGuide/latest/API/Programming-OPC-UA_timecho.md index a638f0f6d..47a6ce5b2 100644 --- a/src/UserGuide/latest/API/Programming-OPC-UA_timecho.md +++ b/src/UserGuide/latest/API/Programming-OPC-UA_timecho.md @@ -21,55 +21,19 @@ # OPC UA Protocol -## 1. OPC UA +## 1. OPC UA Subscription Data -OPC UA is a technical specification used in the automation field for communication between different devices and systems, enabling cross platform, cross language, and cross network operations, providing a reliable and secure data exchange foundation for the Industrial Internet of Things. IoTDB supports OPC UA protocol, and IoTDB OPC Server supports both Client/Server and Pub/Sub communication modes. +This feature allows users to subscribe to data from IoTDB using the OPC UA protocol. The communication modes for subscription data support both Client/Server and Pub/Sub. -### 1.1 OPC UA Client/Server Mode +Note: This feature is not about collecting data from external OPC Servers and writing it into IoTDB. -- **Client/Server Mode**:In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. +![](/img/opc-ua-new-1-en.png) -
- -
- - -- Features: - - - OPC UA will organize the device information received from Sink into folders under the Objects folder according to a tree model. - - - Each measurement point is recorded as a variable node and the latest value in the current database is recorded. - -### 1.2 OPC UA Pub/Sub Mode - -- **Pub/Sub Mode**: In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. - -
- -
- -- Features: - - - Each measurement point is wrapped as an Event Node in OPC UA. - - - - The relevant fields and their meanings are as follows: - - | Field | Meaning | Type (Milo) | Example | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | Timestamp | DateTime | 1698907326198 | - | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | - | SourceNode | Data type of the measurement point | NodeId | Int32 | - | Message | Data | LocalizedText | 3.0 | - - - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. - - -## 2. IoTDB OPC Server Startup method +## 2. OPC Service Startup Method ### 2.1 Syntax -The syntax for creating the Sink is as follows: +The syntax to start the OPC UA protocol: ```SQL @@ -110,31 +74,29 @@ start pipe p1; ### 2.4 Usage Limitations -1. **DataRegion Requirement**: The OPC UA server will only start if there is a DataRegion in IoTDB. For an empty IoTDB, a data entry is necessary for the OPC UA server to become effective. - -2. **Data Availability**: Clients subscribing to the server will not receive data written to IoTDB before their connection. +1. After starting the protocol, data needs to be written to establish a connection. Only data after the connection is established can be subscribed to. +2. Recommended for use in standalone mode. In distributed mode, each IoTDB DataNode acts as an independent OPC Server providing data and requires separate subscription. -3. **Multiple DataNodes may have scattered sending/conflict issues**: +## 3. Examples of Two Communication Modes - - For IoTDB clusters with multiple dataRegions and scattered across different DataNode IPs, data will be sent in a dispersed manner on the leaders of the dataRegions. The client needs to listen to the configuration ports of the DataNode IP separately.。 - - - Suggest using this OPC UA server under 1C1D. - -4. **Does not support deleting data and modifying measurement point types:** In Client Server mode, OPC UA cannot delete data or change data type settings. In Pub Sub mode, if data is deleted, information cannot be pushed to the client. +### 3.1 Client / Server Mode -## 3. IoTDB OPC Server Example +In this mode, IoTDB's stream processing engine establishes a connection with the OPC UA Server via an OPC UA Sink. The OPC UA Server maintains data within its Address Space, from which IoTDB can request and retrieve data. Additionally, other OPC UA Clients can access the data on the server. -### 3.1 Client / Server Mode +* Features: + * OPC UA organizes device information received from the Sink into folders under the Objects folder according to a tree model. + * Each measurement point is recorded as a variable node, storing the latest value from the current database. + * OPC UA cannot delete data or change data type settings. -#### Preparation Work +#### 3.1.1 Preparation Work 1. Take UAExpert client as an example, download the UAExpert client: https://www.unified-automation.com/downloads/opc-ua-clients.html 2. Install UAExpert and fill in your own certificate information. -#### Quick Start +#### 3.1.2 Quick Start -1. Use the following SQL to create and start the OPC UA Sink in client-server mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](#syntax) +1. Use the following SQL to create and start the OPC UA Sink in client-server mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](./Programming-OPC-UA_timecho.md#_2-1-syntax) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink'); @@ -176,7 +138,26 @@ insert into root.test.db(time, s2) values(now(), 2) ### 3.2 Pub / Sub Mode -#### Preparation Work +In this mode, IoTDB's stream processing engine sends data change events to the OPC UA Server through an OPC UA Sink. These events are published to the server's message queue and managed through Event Nodes. Other OPC UA Clients can subscribe to these Event Nodes to receive notifications upon data changes. + +- Features: + + - Each measurement point is wrapped as an Event Node in OPC UA. + + - The relevant fields and their meanings are as follows: + + | Field | Meaning | Type (Milo) | Example | + | :--------- | :--------------- | :------------ | :-------------------- | + | Time | Timestamp | DateTime | 1698907326198 | + | SourceName | Full path of the measurement point | String | root.test.opc.sensor0 | + | SourceNode | Data type of the measurement point | NodeId | Int32 | + | Message | Data | LocalizedText | 3.0 | + + - Events are only sent to clients that are already listening; if a client is not connected, the Event will be ignored. + - If data is deleted, the information cannot be pushed to clients. + + +#### 3.2.1 Preparation Work The code is located in the [opc-ua-sink package](https://github.com/apache/iotdb/tree/rc/2.0.1/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)under the iotdb-example package. @@ -187,7 +168,7 @@ The code includes: - Client configuration and startup logic(ClientExampleRunner) - The parent class of ClientTest(ClientExample) -### 3.3 Quick Start +#### 3.2.2 Quick Start The steps are as follows: @@ -199,7 +180,7 @@ insert into root.a.b(time, c, d) values(now(), 1, 2); ​ The metadata is automatically created and enabled here. -2. Use the following SQL to create and start the OPC UA Sink in Pub-Sub mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](#syntax) +2. Use the following SQL to create and start the OPC UA Sink in Pub-Sub mode. For detailed syntax, please refer to: [IoTDB OPC Server Syntax](./Programming-OPC-UA_timecho.md#_2-1-syntax) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink', diff --git a/src/zh/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md b/src/zh/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md index f37cfc625..eea7e97fd 100644 --- a/src/zh/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md +++ b/src/zh/UserGuide/Master/Tree/API/Programming-OPC-UA_timecho.md @@ -21,52 +21,18 @@ # OPC UA 协议 -## 1. OPC UA +## 1. OPC UA 订阅数据 -OPC UA 是一种在自动化领域用于不同设备和系统之间进行通信的技术规范,用于实现跨平台、跨语言和跨网络的操作,为工业物联网提供一个可靠和安全的数据交换基础。IoTDB 中支持 OPC UA协议, IoTDB OPC Server 支持 Client/Server 和 Pub/Sub 两种通信模式。 +本功能支持用户以 OPC UA 协议从 IoTDB 中订阅数据,订阅数据的通信模式支持 Client/Server 和 Pub/Sub 两种。 -### 1.1 PC UA Client/Server 模式 +注意:本功能并非从外部 OPC Server 中采集数据写入 IoTDB -- **Client/Server 模式**:在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 - -
- -
- - -- 特性: - - - OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 - - 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 - -### 1.2 OPC UA Pub/Sub 模式 - -- **Pub/Sub 模式**:在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 - -
- -
- -- 特性: - - - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 - - - 相关字段及其对应含义如下: - - | 字段 | 含义 | 类型(Milo) | 示例 | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | 时间戳 | DateTime | 1698907326198 | - | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | - | SourceNode | 测点数据类型 | NodeId | Int32 | - | Message | 数据 | LocalizedText | 3.0 | - - - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 - -## 2. IoTDB OPC Server 启动方式 +![](/img/opc-ua-new-1.png) +## 2. OPC 服务启动方式 ### 2.1 语法 -创建该 Sink 的语法如下: +启动 OPC UA 协议的语法: ```SQL create pipe p1 @@ -83,16 +49,16 @@ create pipe p1 ### 2.2 参数 -| **参数** | **描述** | **取值范围** | **是否必填** | **默认值** | -| ---------------------------------- | ------------------------------ | -------------------------------- | ------------ |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| sink | OPC UA SINK | String: opc-ua-sink | 必填 | | -| sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | pub-sub | -| sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | -| sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | -| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 / | -| sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | -| sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | -| sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | TimechoDB@2021 //V2.0.6.x 之前默认密码为root | +| **参数** | **描述** | **​ 取值范围 ​** | **是否必填** | **默认值** | +| ------------------------------------ | -------------------------------- | ---------------------------------- | -------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------| +| sink | OPC UA SINK | String: opc-ua-sink | 必填 | | +| sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | client-server | +| sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | +| sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | +| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | 1. iotdb 相关 DataNode 的 conf 目录下的 opc\_security 文件夹 / ``。2. 如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb\_opc\_security 文件夹 /``| +| sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | +| sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | +| sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | TimechoDB@2021 (V2.0.6.x 之前默认密码为root ) | ### 2.3 示例 @@ -100,36 +66,30 @@ create pipe p1 create pipe p1 with sink ('sink' = 'opc-ua-sink', 'sink.user' = 'root', - 'sink.password' = 'TimechoDB@2021'); //V2.0.6.x 之前默认密码为root + 'sink.password' = 'TimechoDB@2021');//V2.0.6.x 之前默认密码为root start pipe p1; ``` ### 2.4 使用限制 +1. 启动协议之后需要写入数据,才能建立连接,且仅能订阅建立连接之后的数据。 +2. 推荐在单机模式下使用。在分布式模式下,每一个 IoTDB DataNode 都作为一个独立的 OPC Server 提供数据,需要单独订阅。 -1. **必须存在 DataRegion**:在 IoTDB 有 dataRegion 时,OPC UA 的服务器才会启动。因此,对于一个空的 IoTDB,需要写入一条数据,OPC UA 的服务器才有效。 -2. **需连接才有数据**:每一个订阅该服务器的客户端,不会收到 OPC Server 在连接之前写入IoTDB的数据。 - -3. **多 DataNode 会有分散发送 / 冲突问题**: - - - 对于有多个 dataRegion,且分散在不同 DataNode ip上的 IoTDB 集群,数据会在 dataRegion 的 leader 上分散发送。客户端需要对 DataNode ip 的配置端口分别监听。 - - - 建议在 1C1D 下使用该 OPC UA 服务器。 - -4. **不支持删除数据和修改测点类型:**在Client Server模式下,OPC UA无法删除数据或者改变数据类型的设置。而在Pub Sub模式下,如果数据被删除了,信息是无法推送给客户端的。 - -## 3. IoTDB OPC Server 示例 - +## 3. 两种通信模式示例 ### 3.1 Client / Server 模式 -#### 准备工作 +在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 -1. 此处以UAExpert客户端为例,下载 UAExpert 客户端:https://www.unified-automation.com/downloads/opc-ua-clients.html +* 特性: + * OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 + * 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 + * OPC UA 无法删除数据或者改变数据类型的设置 +#### 3.1.1 准备工作 +1. 此处以UAExpert客户端为例,下载 UAExpert 客户端:https://www.unified-automation.com/downloads/opc-ua-clients.html 2. 安装 UAExpert,填写自身的证书等信息。 -#### 快速开始 - -1. 使用如下 sql,创建并启动 client-server 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](#语法) +#### 3.1.2 快速开始 +1. 使用如下 sql,启动 OPC UA 服务。详细语法参见上文:[IoTDB OPC Server语法](./Programming-OPC-UA_timecho.md#_2-1-语法) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink'); @@ -141,9 +101,7 @@ create pipe p1 with sink ('sink'='opc-ua-sink'); insert into root.test.db(time, s2) values(now(), 2) ``` -​ 此处自动创建元数据开启。 - -3. 在 UAExpert 中配置 iotdb 的连接,其中 password 填写为上述参数配置中 sink.password 中设定的密码(此处以密码root为例): +3. 在 UAExpert 中配置 iotdb 的连接,其中 password 填写为上述参数配置中 sink.password 中设定的密码(此处用户名、密码以2.3小节示例中配置的 root/root 为例):
@@ -171,9 +129,26 @@ insert into root.test.db(time, s2) values(now(), 2) ### 3.2 Pub / Sub 模式 -#### 准备工作 +在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 + +* 特性: + * 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 + * 相关字段及其对应含义如下: + + | 字段 | 含义 | 类型(Milo) | 示例 | + | ------------ | ------------------ | --------------- | ----------------------- | + | Time | 时间戳 | DateTime | 1698907326198 | + | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | + | SourceNode | 测点数据类型 | NodeId | Int32 | + | Message | 数据 | LocalizedText | 3.0 | + + - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 + - 如果数据被删除,信息则无法推送给客户端。 + + +#### 3.2.1 准备工作 -该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/2.0.1/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 +该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/master/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 代码中包含: @@ -182,7 +157,7 @@ insert into root.test.db(time, s2) values(now(), 2) - Client 的配置及启动逻辑(ClientExampleRunner) - ClientTest 的父类(ClientExample) -### 3.3 快速开始 +#### 3.2.2 快速开始 使用步骤为: @@ -194,11 +169,10 @@ insert into root.a.b(time, c, d) values(now(), 1, 2); ​ 此处自动创建元数据开启。 -2. 使用如下 sql,创建并启动 Pub-Sub 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](#语法) +2. 使用如下 sql,创建并启动 Pub-Sub 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](./Programming-OPC-UA_timecho.md#_2-1-语法) ```SQL -create pipe p1 with sink ('sink'='opc-ua-sink', - 'sink.opcua.model'='pub-sub'); +create pipe p1 with sink ('sink'='opc-ua-sink', 'sink.opcua.model'='pub-sub'); start pipe p1; ``` diff --git a/src/zh/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md b/src/zh/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md index 861fc5851..917b211ee 100644 --- a/src/zh/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md +++ b/src/zh/UserGuide/V1.3.x/API/Programming-OPC-UA_timecho.md @@ -21,52 +21,19 @@ # OPC UA 协议 -## OPC UA +## OPC UA 订阅数据 -OPC UA 是一种在自动化领域用于不同设备和系统之间进行通信的技术规范,用于实现跨平台、跨语言和跨网络的操作,为工业物联网提供一个可靠和安全的数据交换基础。IoTDB 中支持 OPC UA协议, IoTDB OPC Server 支持 Client/Server 和 Pub/Sub 两种通信模式。 +本功能支持用户以 OPC UA 协议从 IoTDB 中订阅数据,订阅数据的通信模式支持 Client/Server 和 Pub/Sub 两种。 -### OPC UA Client/Server 模式 +注意:本功能并非从外部 OPC Server 中采集数据写入 IoTDB -- **Client/Server 模式**:在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 +![](/img/opc-ua-new-1.png) -
- -
- - -- 特性: - - - OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 - - 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 - -### OPC UA Pub/Sub 模式 - -- **Pub/Sub 模式**:在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 - -
- -
- -- 特性: - - - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 - - - 相关字段及其对应含义如下: - - | 字段 | 含义 | 类型(Milo) | 示例 | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | 时间戳 | DateTime | 1698907326198 | - | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | - | SourceNode | 测点数据类型 | NodeId | Int32 | - | Message | 数据 | LocalizedText | 3.0 | - - - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 - -## IoTDB OPC Server 启动方式 +## OPC 服务启动方式 ### 语法 -创建该 Sink 的语法如下: +启动 OPC UA 协议的语法: ```SQL create pipe p1 @@ -89,7 +56,7 @@ create pipe p1 | sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | pub-sub | | sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | | sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | -| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 / | +| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /``。
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 /`` | | sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | | sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | | sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | root | @@ -106,20 +73,18 @@ start pipe p1; ### 使用限制 -1. **必须存在 DataRegion**:在 IoTDB 有 dataRegion 时,OPC UA 的服务器才会启动。因此,对于一个空的 IoTDB,需要写入一条数据,OPC UA 的服务器才有效。 -2. **需连接才有数据**:每一个订阅该服务器的客户端,不会收到 OPC Server 在连接之前写入IoTDB的数据。 - -3. **多 DataNode 会有分散发送 / 冲突问题**: - - - 对于有多个 dataRegion,且分散在不同 DataNode ip上的 IoTDB 集群,数据会在 dataRegion 的 leader 上分散发送。客户端需要对 DataNode ip 的配置端口分别监听。 - - - 建议在 1C1D 下使用该 OPC UA 服务器。 +1. 启动协议之后需要写入数据,才能建立连接,且仅能订阅建立连接之后的数据。 +2. 推荐在单机模式下使用。在分布式模式下,每一个 IoTDB DataNode 都作为一个独立的 OPC Server 提供数据,需要单独订阅。 -4. **不支持删除数据和修改测点类型:**在Client Server模式下,OPC UA无法删除数据或者改变数据类型的设置。而在Pub Sub模式下,如果数据被删除了,信息是无法推送给客户端的。 +## 两种通信模式示例 +### Client / Server 模式 -## IoTDB OPC Server 示例 +在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 -### Client / Server 模式 +* 特性: + * OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 + * 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 + * OPC UA 无法删除数据或者改变数据类型的设置 #### 准备工作 @@ -171,9 +136,27 @@ insert into root.test.db(time, s2) values(now(), 2) ### Pub / Sub 模式 +在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 + +- 特性: + + - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 + - 相关字段及其对应含义如下: + + | 字段 | 含义 | 类型(Milo) | 示例 | + | :--------- | :--------------- | :------------ | :-------------------- | + | Time | 时间戳 | DateTime | 1698907326198 | + | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | + | SourceNode | 测点数据类型 | NodeId | Int32 | + | Message | 数据 | LocalizedText | 3.0 | + + - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 + - 如果数据被删除,信息则无法推送给客户端。 + + #### 准备工作 -该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/1.3.3/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 +该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/1.3.5/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 代码中包含: @@ -182,7 +165,7 @@ insert into root.test.db(time, s2) values(now(), 2) - Client 的配置及启动逻辑(ClientExampleRunner) - ClientTest 的父类(ClientExample) -### 快速开始 +#### 快速开始 使用步骤为: diff --git a/src/zh/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md b/src/zh/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md index b0e9948b7..917b211ee 100644 --- a/src/zh/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md +++ b/src/zh/UserGuide/dev-1.3/API/Programming-OPC-UA_timecho.md @@ -21,52 +21,19 @@ # OPC UA 协议 -## OPC UA +## OPC UA 订阅数据 -OPC UA 是一种在自动化领域用于不同设备和系统之间进行通信的技术规范,用于实现跨平台、跨语言和跨网络的操作,为工业物联网提供一个可靠和安全的数据交换基础。IoTDB 中支持 OPC UA协议, IoTDB OPC Server 支持 Client/Server 和 Pub/Sub 两种通信模式。 +本功能支持用户以 OPC UA 协议从 IoTDB 中订阅数据,订阅数据的通信模式支持 Client/Server 和 Pub/Sub 两种。 -### OPC UA Client/Server 模式 +注意:本功能并非从外部 OPC Server 中采集数据写入 IoTDB -- **Client/Server 模式**:在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 +![](/img/opc-ua-new-1.png) -
- -
- - -- 特性: - - - OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 - - 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 - -### OPC UA Pub/Sub 模式 - -- **Pub/Sub 模式**:在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 - -
- -
- -- 特性: - - - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 - - - 相关字段及其对应含义如下: - - | 字段 | 含义 | 类型(Milo) | 示例 | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | 时间戳 | DateTime | 1698907326198 | - | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | - | SourceNode | 测点数据类型 | NodeId | Int32 | - | Message | 数据 | LocalizedText | 3.0 | - - - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 - -## IoTDB OPC Server 启动方式 +## OPC 服务启动方式 ### 语法 -创建该 Sink 的语法如下: +启动 OPC UA 协议的语法: ```SQL create pipe p1 @@ -89,7 +56,7 @@ create pipe p1 | sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | pub-sub | | sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | | sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | -| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 / | +| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /``。
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 /`` | | sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | | sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | | sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | root | @@ -106,20 +73,18 @@ start pipe p1; ### 使用限制 -1. **必须存在 DataRegion**:在 IoTDB 有 dataRegion 时,OPC UA 的服务器才会启动。因此,对于一个空的 IoTDB,需要写入一条数据,OPC UA 的服务器才有效。 -2. **需连接才有数据**:每一个订阅该服务器的客户端,不会收到 OPC Server 在连接之前写入IoTDB的数据。 - -3. **多 DataNode 会有分散发送 / 冲突问题**: - - - 对于有多个 dataRegion,且分散在不同 DataNode ip上的 IoTDB 集群,数据会在 dataRegion 的 leader 上分散发送。客户端需要对 DataNode ip 的配置端口分别监听。 - - - 建议在 1C1D 下使用该 OPC UA 服务器。 +1. 启动协议之后需要写入数据,才能建立连接,且仅能订阅建立连接之后的数据。 +2. 推荐在单机模式下使用。在分布式模式下,每一个 IoTDB DataNode 都作为一个独立的 OPC Server 提供数据,需要单独订阅。 -4. **不支持删除数据和修改测点类型:**在Client Server模式下,OPC UA无法删除数据或者改变数据类型的设置。而在Pub Sub模式下,如果数据被删除了,信息是无法推送给客户端的。 +## 两种通信模式示例 +### Client / Server 模式 -## IoTDB OPC Server 示例 +在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 -### Client / Server 模式 +* 特性: + * OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 + * 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 + * OPC UA 无法删除数据或者改变数据类型的设置 #### 准备工作 @@ -171,9 +136,27 @@ insert into root.test.db(time, s2) values(now(), 2) ### Pub / Sub 模式 +在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 + +- 特性: + + - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 + - 相关字段及其对应含义如下: + + | 字段 | 含义 | 类型(Milo) | 示例 | + | :--------- | :--------------- | :------------ | :-------------------- | + | Time | 时间戳 | DateTime | 1698907326198 | + | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | + | SourceNode | 测点数据类型 | NodeId | Int32 | + | Message | 数据 | LocalizedText | 3.0 | + + - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 + - 如果数据被删除,信息则无法推送给客户端。 + + #### 准备工作 -该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/master/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 +该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/1.3.5/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 代码中包含: @@ -182,7 +165,7 @@ insert into root.test.db(time, s2) values(now(), 2) - Client 的配置及启动逻辑(ClientExampleRunner) - ClientTest 的父类(ClientExample) -### 快速开始 +#### 快速开始 使用步骤为: diff --git a/src/zh/UserGuide/latest/API/Programming-OPC-UA_timecho.md b/src/zh/UserGuide/latest/API/Programming-OPC-UA_timecho.md index f37cfc625..eea7e97fd 100644 --- a/src/zh/UserGuide/latest/API/Programming-OPC-UA_timecho.md +++ b/src/zh/UserGuide/latest/API/Programming-OPC-UA_timecho.md @@ -21,52 +21,18 @@ # OPC UA 协议 -## 1. OPC UA +## 1. OPC UA 订阅数据 -OPC UA 是一种在自动化领域用于不同设备和系统之间进行通信的技术规范,用于实现跨平台、跨语言和跨网络的操作,为工业物联网提供一个可靠和安全的数据交换基础。IoTDB 中支持 OPC UA协议, IoTDB OPC Server 支持 Client/Server 和 Pub/Sub 两种通信模式。 +本功能支持用户以 OPC UA 协议从 IoTDB 中订阅数据,订阅数据的通信模式支持 Client/Server 和 Pub/Sub 两种。 -### 1.1 PC UA Client/Server 模式 +注意:本功能并非从外部 OPC Server 中采集数据写入 IoTDB -- **Client/Server 模式**:在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 - -
- -
- - -- 特性: - - - OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 - - 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 - -### 1.2 OPC UA Pub/Sub 模式 - -- **Pub/Sub 模式**:在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 - -
- -
- -- 特性: - - - 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 - - - 相关字段及其对应含义如下: - - | 字段 | 含义 | 类型(Milo) | 示例 | - | :--------- | :--------------- | :------------ | :-------------------- | - | Time | 时间戳 | DateTime | 1698907326198 | - | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | - | SourceNode | 测点数据类型 | NodeId | Int32 | - | Message | 数据 | LocalizedText | 3.0 | - - - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 - -## 2. IoTDB OPC Server 启动方式 +![](/img/opc-ua-new-1.png) +## 2. OPC 服务启动方式 ### 2.1 语法 -创建该 Sink 的语法如下: +启动 OPC UA 协议的语法: ```SQL create pipe p1 @@ -83,16 +49,16 @@ create pipe p1 ### 2.2 参数 -| **参数** | **描述** | **取值范围** | **是否必填** | **默认值** | -| ---------------------------------- | ------------------------------ | -------------------------------- | ------------ |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| sink | OPC UA SINK | String: opc-ua-sink | 必填 | | -| sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | pub-sub | -| sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | -| sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | -| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | iotdb 相关 DataNode 的 conf 目录下的 opc_security 文件夹 /
如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb_opc_security 文件夹 / | -| sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | -| sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | -| sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | TimechoDB@2021 //V2.0.6.x 之前默认密码为root | +| **参数** | **描述** | **​ 取值范围 ​** | **是否必填** | **默认值** | +| ------------------------------------ | -------------------------------- | ---------------------------------- | -------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------| +| sink | OPC UA SINK | String: opc-ua-sink | 必填 | | +| sink.opcua.model | OPC UA 使用的模式 | String: client-server / pub-sub | 选填 | client-server | +| sink.opcua.tcp.port | OPC UA 的 TCP 端口 | Integer: [0, 65536] | 选填 | 12686 | +| sink.opcua.https.port | OPC UA 的 HTTPS 端口 | Integer: [0, 65536] | 选填 | 8443 | +| sink.opcua.security.dir | OPC UA 的密钥及证书目录 | String: Path,支持绝对及相对目录 | 选填 | 1. iotdb 相关 DataNode 的 conf 目录下的 opc\_security 文件夹 / ``。2. 如无 iotdb 的 conf 目录(例如 IDEA 中启动 DataNode),则为用户主目录下的 iotdb\_opc\_security 文件夹 /``| +| sink.opcua.enable-anonymous-access | OPC UA 是否允许匿名访问 | Boolean | 选填 | true | +| sink.user | 用户,这里指 OPC UA 的允许用户 | String | 选填 | root | +| sink.password | 密码,这里指 OPC UA 的允许密码 | String | 选填 | TimechoDB@2021 (V2.0.6.x 之前默认密码为root ) | ### 2.3 示例 @@ -100,36 +66,30 @@ create pipe p1 create pipe p1 with sink ('sink' = 'opc-ua-sink', 'sink.user' = 'root', - 'sink.password' = 'TimechoDB@2021'); //V2.0.6.x 之前默认密码为root + 'sink.password' = 'TimechoDB@2021');//V2.0.6.x 之前默认密码为root start pipe p1; ``` ### 2.4 使用限制 +1. 启动协议之后需要写入数据,才能建立连接,且仅能订阅建立连接之后的数据。 +2. 推荐在单机模式下使用。在分布式模式下,每一个 IoTDB DataNode 都作为一个独立的 OPC Server 提供数据,需要单独订阅。 -1. **必须存在 DataRegion**:在 IoTDB 有 dataRegion 时,OPC UA 的服务器才会启动。因此,对于一个空的 IoTDB,需要写入一条数据,OPC UA 的服务器才有效。 -2. **需连接才有数据**:每一个订阅该服务器的客户端,不会收到 OPC Server 在连接之前写入IoTDB的数据。 - -3. **多 DataNode 会有分散发送 / 冲突问题**: - - - 对于有多个 dataRegion,且分散在不同 DataNode ip上的 IoTDB 集群,数据会在 dataRegion 的 leader 上分散发送。客户端需要对 DataNode ip 的配置端口分别监听。 - - - 建议在 1C1D 下使用该 OPC UA 服务器。 - -4. **不支持删除数据和修改测点类型:**在Client Server模式下,OPC UA无法删除数据或者改变数据类型的设置。而在Pub Sub模式下,如果数据被删除了,信息是无法推送给客户端的。 - -## 3. IoTDB OPC Server 示例 - +## 3. 两种通信模式示例 ### 3.1 Client / Server 模式 -#### 准备工作 +在这种模式下,IoTDB 的流处理引擎通过 OPC UA Sink 与 OPC UA 服务器(Server)建立连接。OPC UA 服务器在其地址空间(Address Space) 中维护数据,IoTDB可以请求并获取这些数据。同时,其他OPC UA客户端(Client)也能访问服务器上的数据。 -1. 此处以UAExpert客户端为例,下载 UAExpert 客户端:https://www.unified-automation.com/downloads/opc-ua-clients.html +* 特性: + * OPC UA 将从 Sink 收到的设备信息,按照树形模型整理到 Objects folder 下的文件夹中。 + * 每个测点都被记录为一个变量节点,并记录当前数据库中的最新值。 + * OPC UA 无法删除数据或者改变数据类型的设置 +#### 3.1.1 准备工作 +1. 此处以UAExpert客户端为例,下载 UAExpert 客户端:https://www.unified-automation.com/downloads/opc-ua-clients.html 2. 安装 UAExpert,填写自身的证书等信息。 -#### 快速开始 - -1. 使用如下 sql,创建并启动 client-server 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](#语法) +#### 3.1.2 快速开始 +1. 使用如下 sql,启动 OPC UA 服务。详细语法参见上文:[IoTDB OPC Server语法](./Programming-OPC-UA_timecho.md#_2-1-语法) ```SQL create pipe p1 with sink ('sink'='opc-ua-sink'); @@ -141,9 +101,7 @@ create pipe p1 with sink ('sink'='opc-ua-sink'); insert into root.test.db(time, s2) values(now(), 2) ``` -​ 此处自动创建元数据开启。 - -3. 在 UAExpert 中配置 iotdb 的连接,其中 password 填写为上述参数配置中 sink.password 中设定的密码(此处以密码root为例): +3. 在 UAExpert 中配置 iotdb 的连接,其中 password 填写为上述参数配置中 sink.password 中设定的密码(此处用户名、密码以2.3小节示例中配置的 root/root 为例):
@@ -171,9 +129,26 @@ insert into root.test.db(time, s2) values(now(), 2) ### 3.2 Pub / Sub 模式 -#### 准备工作 +在这种模式下,IoTDB的流处理引擎通过 OPC UA Sink 向OPC UA 服务器(Server)发送数据变更事件。这些事件被发布到服务器的消息队列中,并通过事件节点 (Event Node) 进行管理。其他OPC UA客户端(Client)可以订阅这些事件节点,以便在数据变更时接收通知。 + +* 特性: + * 每个测点会被 OPC UA 包装成一个事件节点(EventNode)。 + * 相关字段及其对应含义如下: + + | 字段 | 含义 | 类型(Milo) | 示例 | + | ------------ | ------------------ | --------------- | ----------------------- | + | Time | 时间戳 | DateTime | 1698907326198 | + | SourceName | 测点对应完整路径 | String | root.test.opc.sensor0 | + | SourceNode | 测点数据类型 | NodeId | Int32 | + | Message | 数据 | LocalizedText | 3.0 | + + - Event 仅会发送给所有已经监听的客户端,客户端未连接则会忽略该 Event。 + - 如果数据被删除,信息则无法推送给客户端。 + + +#### 3.2.1 准备工作 -该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/rc/2.0.1/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 +该代码位于 iotdb-example 包下的 [opc-ua-sink 文件夹](https://github.com/apache/iotdb/tree/master/example/pipe-opc-ua-sink/src/main/java/org/apache/iotdb/opcua)中 代码中包含: @@ -182,7 +157,7 @@ insert into root.test.db(time, s2) values(now(), 2) - Client 的配置及启动逻辑(ClientExampleRunner) - ClientTest 的父类(ClientExample) -### 3.3 快速开始 +#### 3.2.2 快速开始 使用步骤为: @@ -194,11 +169,10 @@ insert into root.a.b(time, c, d) values(now(), 1, 2); ​ 此处自动创建元数据开启。 -2. 使用如下 sql,创建并启动 Pub-Sub 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](#语法) +2. 使用如下 sql,创建并启动 Pub-Sub 模式的 OPC UA Sink。详细语法参见上文:[IoTDB OPC Server语法](./Programming-OPC-UA_timecho.md#_2-1-语法) ```SQL -create pipe p1 with sink ('sink'='opc-ua-sink', - 'sink.opcua.model'='pub-sub'); +create pipe p1 with sink ('sink'='opc-ua-sink', 'sink.opcua.model'='pub-sub'); start pipe p1; ```