feat(cli): historyupdate command (insert/replace/update/delete-raw/delete-at-time)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -221,6 +221,38 @@ otopcua-cli historyread -u opc.tcp://localhost:4840/OtOpcUa \
|
||||
| `--aggregate` | Aggregate function: Average, Minimum, Maximum, Count, Start, End, StandardDeviation |
|
||||
| `--interval` | Processing interval in milliseconds for aggregates (default: 3600000) |
|
||||
|
||||
### historyupdate
|
||||
|
||||
Inserts, replaces, updates or deletes stored history on a historized node via the OPC UA `HistoryUpdate`
|
||||
service (requires a server whose historian backend supports updates and a session holding the history-write
|
||||
permission). Prints one line per item (`index time StatusCodeName`) followed by the overall service
|
||||
result; any Bad item or service result exits non-zero.
|
||||
|
||||
```bash
|
||||
# Insert two values
|
||||
otopcua-cli historyupdate -u opc.tcp://localhost:4840/OtOpcUa -n "ns=2;s=Plant/Modbus/dev1/Speed" \
|
||||
--mode insert --value 1.5 --time 2026-01-15T08:00:00Z --value 2.5 --time 2026-01-15T09:00:00Z
|
||||
|
||||
# Replace an int64 value
|
||||
otopcua-cli historyupdate -u ... -n "..." --mode replace --type int64 --value 42 --time 2026-01-15T08:00:00Z
|
||||
|
||||
# Delete a raw range / specific timestamps
|
||||
otopcua-cli historyupdate -u ... -n "..." --mode delete-raw --start 2026-01-15T08:00:00Z --end 2026-01-15T10:00:00Z
|
||||
otopcua-cli historyupdate -u ... -n "..." --mode delete-at-time --time 2026-01-15T08:00:00Z
|
||||
```
|
||||
|
||||
| Flag | Description |
|
||||
|------|-------------|
|
||||
| `-n` / `--node` | Node ID to modify (required) |
|
||||
| `--mode` | `insert`, `replace`, `update`, `delete-raw` or `delete-at-time` (required) |
|
||||
| `--value` | Value to write; repeatable, paired positionally with `--time` (insert/replace/update) |
|
||||
| `--time` | ISO 8601 UTC timestamp; repeatable (insert/replace/update/delete-at-time) |
|
||||
| `--type` | `double` (default), `int64`, `bool`, `string`, `datetime` - how `--value` is parsed |
|
||||
| `--start` / `--end` | Range for `delete-raw` (both required; `--end` later than `--start`) |
|
||||
|
||||
`delete-raw` is sent with `IsDeleteModified=false`. Invalid or inconsistent options (unknown mode, unpaired
|
||||
value/time, unparsable value, options that do not apply to the mode) fail before any connection is made.
|
||||
|
||||
#### Aggregate mapping
|
||||
|
||||
| Name | Aliases | OPC UA Node ID |
|
||||
|
||||
Reference in New Issue
Block a user