SIENTIAPDE-2202
SIENTIAPDE-2202-escrita-opc-timestamp-qualidade: Enable granular control over OPC UA SourceTimestamp and StatusCode in write commands. This implements write_timestamp and write_quality flags (command > env > default true) for DataValue construction. Upgraded asyncua to 2.0+ to fix StatusCode field naming. Enhanced README.md with new gateway environment variables and detailed write command behavior. Added comprehensive unit and E2E tests for this feature, and removed obsolete planning documents.
This commit is contained in:
40
README.md
40
README.md
@@ -67,9 +67,8 @@ Gateway for on-demand and command-driven interactions with OPC UA servers:
|
||||
(`opc_certificates`), named in the slot and downloaded from MinIO
|
||||
(`ingestor/connection/certs.py`) rather than shipped in the image.
|
||||
|
||||
See `docs/deploy-notes.md` for the deployment-facing details (env vars,
|
||||
health probe, NetworkPolicy, cert cache) and the `# OPC Gateway` block in
|
||||
`.env.example` for the full list of new environment variables.
|
||||
See [Gateway environment variables](#gateway-environment-variables) and the
|
||||
`# OPC Gateway` blocks in `.env.example` for the new environment variables.
|
||||
|
||||
### Write commands (C2) and `write_status` (C3)
|
||||
|
||||
@@ -78,10 +77,16 @@ The Laborious publishes one command per tag (SIENTIAPDE-1975):
|
||||
```json
|
||||
{"server_id": "1", "addr": "ns=2;s=Pred", "value": 1.25, "data_type": "float",
|
||||
"model_id": "2", "model_name": "sin-approx", "schema": "sientia_data",
|
||||
"table_name": "predictions", "timestamp": "2026-10-13T12:00:00-03:00",
|
||||
"write_timestamp": false, "write_quality": false}
|
||||
"table_name": "predictions", "timestamp": "2026-10-13T12:00:00-03:00"}
|
||||
```
|
||||
|
||||
- **Written `DataValue`** (SIENTIAPDE-2202): the value, plus the prediction
|
||||
`timestamp` as `SourceTimestamp` and a Good `StatusCode`. Timestamp and quality can be
|
||||
turned off separately; the value is always written. Each flag is taken from the
|
||||
command (`write_timestamp` / `write_quality`) when present, else from the env
|
||||
(`WRITE_TIMESTAMP` / `WRITE_QUALITY`), else `true`. The envs apply to every server of
|
||||
the gateway (per-server config is a future SIENTIAPDE-2276 card).
|
||||
|
||||
- **Server connection**: the command carries only `server_id`. The connection is
|
||||
resolved by `ServerConfigResolver` (`ingestor/connection/servers.py`): the live
|
||||
pooled connection opened by the reads, else the `connectors` document (`type: opc_ua`,
|
||||
@@ -342,9 +347,28 @@ The OPC Ingestor exposes comprehensive Prometheus metrics for monitoring:
|
||||
| `MONGODB_PASSWORD` | MongoDB password | `sientia` | No |
|
||||
| `HTTP_METRICS_PORT` | Prometheus metrics port | `9090` | No |
|
||||
|
||||
See the `# OPC Gateway` block in `.env.example` (`NATS_URL`, `GRPC_ENABLED`,
|
||||
`CERT_CACHE_DIR`, `WRITE_TIMESTAMP`, ...) and `docs/deploy-notes.md` for the
|
||||
gateway-specific environment variables.
|
||||
#### Gateway environment variables
|
||||
|
||||
Read by `GatewayConfig` (`ingestor/config.py`). Booleans accept `true`/`1`/`yes`
|
||||
(case-insensitive); anything else is `false`.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `NATS_URL` | NATS server for write commands (C2) | `nats://localhost:4222` |
|
||||
| `NATS_WRITE_SUBJECT` | Subject of the write commands | `opc.write` |
|
||||
| `NATS_QUEUE` | Queue group shared by the gateway pods | `gateway-writers` |
|
||||
| `GRPC_ENABLED` | Starts the on-demand `ReadTag` gRPC server | `false` |
|
||||
| `GRPC_PORT` | gRPC server port | `50051` |
|
||||
| `CERT_CACHE_DIR` | Local cache of the client certificates downloaded from MinIO | `/tmp/opc-certs` |
|
||||
| `WRITE_TIMESTAMP` | Writes the prediction `timestamp` as `SourceTimestamp` when the command has no `write_timestamp` | `true` |
|
||||
| `WRITE_QUALITY` | Writes a Good `StatusCode` when the command has no `write_quality` | `true` |
|
||||
| `WRITE_MIN_PAUSE_S` | Minimum pause between two OPC writes (seconds) | `0.0` |
|
||||
| `IDLE_CONN_MAX_S` | Idle time before an unpinned pool connection is closed (seconds) | `300.0` |
|
||||
|
||||
`WRITE_TIMESTAMP` / `WRITE_QUALITY` are independent and apply to every OPC server of
|
||||
the gateway; the value is always written. See [Write commands](#write-commands-c2-and-write_status-c3)
|
||||
for the precedence (command → env → `true`). MinIO (`MINIO_*`) and Postgres
|
||||
(`POSTGRES_*`) settings are listed in `.env.example`.
|
||||
|
||||
### OPC Server Configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user