Dynamic Driver API
About 364 wordsAbout 1 min
2026-05-20
Overview
CommunicationService provides dynamic lifecycle management of communication drivers within the system, as well as strongly-typed, reflective read/write interactions executed through a unified gateway. External applications can perform hot-plugging of device tags and achieve unified data integration via RESTful APIs.
Usage
Registered in the Dependency Injection (DI) container as a singleton, serving as the core processor for Minimal APIs or Controllers.
Parameters
1. Driver Registration (CreateDriverRequest)
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| DriverId | string | Global unique identifier (ID) of the driver | Yes |
| DriverType | string | Protocol type (S7, Modbus, OpcUa, Mqtt, OpcUaPubSub) | Yes |
| ConnectionString | string | Physical connection string | Yes |
2. Strongly-Typed Read (Read Tag)
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| address | string | Physical communication address | Yes |
| type | string | Target data type indicator (e.g., int, float, string) | No |
3. Strongly-Typed Write (WriteAddressRequest)
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| Address | string | Physical communication address | Yes |
| Value | object | Value to write (JSON format) | Yes |
| TypeHint | string | Strong type mapping hint (used for precise byte stream serialization) | No |
Returns
Data Read Structure (DataValue<object>)
| Property Name | Type | Description |
|---|---|---|
| Value | object? | The strongly-typed physical data read from the device |
| Status | string | Data status stamp (Good, Bad, Uncertain, Timeout) |
| Quality | string | OPC UA compatible 16-bit quality code |
| SourceTimestamp | DateTime | Timestamp generated by the data source / PLC |
| ServerTimestamp | DateTime | Timestamp when the data was received by the gateway |
Examples
Example 1: Dynamically Add and Connect an S7 Driver
POST /api/drivers
{
"driverId": "S7_CPU_01",
"driverType": "S7",
"connectionString": "CpuType=S71200;Ip=192.168.0.100;Rack=0;Slot=1"
}Example 2: Reflective Strongly-Typed Read
GET /api/drivers/S7_CPU_01/read?address=DB1.DBD0&type=float
{
"value": 45.28,
"status": 0,
"quality": 0,
"sourceTimestamp": "2026-05-18T00:46:12.345Z",
"serverTimestamp": "2026-05-18T00:46:12.350Z"
}Example 3: Reflective Strongly-Typed Write
POST /api/drivers/S7_CPU_01/write
{
"address": "DB1.DBX4.0",
"value": true,
"typeHint": "bool"
}Example 4: Subscription and Polling for Cached Data
Note: Subscriptions in CommunicationService will automatically update the injected IUniconCacheProvider caching mechanism during callbacks.
POST /api/drivers/S7_CPU_01/subscribe
{
"address": "DB1.DBD8"
}GET /api/drivers/S7_CPU_01/subscriptions(Extract the latest value from CacheProvider)
[
{
"driverId": "S7_CPU_01",
"address": "DB1.DBD8",
"value": 102.5,
"quality": "Good",
"timestamp": "2026-05-18T00:49:15.823Z"
}
]