feat: add batch read support via UA_Client_Service_read#17
Open
juljimm wants to merge 2 commits intovaliot:masterfrom
Open
feat: add batch read support via UA_Client_Service_read#17juljimm wants to merge 2 commits intovaliot:masterfrom
juljimm wants to merge 2 commits intovaliot:masterfrom
Conversation
Implement read_node_values to read multiple OPC-UA nodes in a single request, reducing N round-trips to 1. Tested against real PLC: 17.6x speedup (916ms -> 52ms for 36 nodes). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
- Handle complex types (NodeId, QualifiedName, ExpandedNodeId) in
parse_batch_value by reusing parse_c_value
- Fix GOOD status without value returning {:error, "Good"} by using
encode_variant_struct for all GOOD statuses
- Reduce max batch node count from 200 to 100 and add buffer overflow
check before erlcmd_send
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement read_node_values to read multiple OPC-UA nodes in a single request, reducing N round-trips to 1. Tested against real PLC: 17.6x speedup (916ms -> 52ms for 36 nodes).
Description
Adds a new
read_node_values/2function that reads the 'value' attribute of multiple OPC-UA nodes in a single service call usingUA_Client_Service_read, instead of issuing one request per node.Motivation: When reading many nodes (e.g. 36 PLC tags), sequential reads cause significant latency due to per-request round-trip overhead. Batching all reads into one OPC-UA Read Service call eliminates this overhead.
Changes:
src/common.c: Newhandle_read_node_values()C NIF that builds aUA_ReadRequestwith multipleUA_ReadValueIdentries and callsUA_Client_Service_read. Results are encoded per-node as{:ok, value}or{:error, status}.src/common.h: Declaration forhandle_read_node_values.src/opc_ua_client.c: Registered"read_node_values"in the client request handler table.lib/opc_ua/common.ex: Newread_node_values/2public API,handle_callclause, and C response handler withparse_batch_value/1.test/client_tests/batch_read_test.exs: 5 test cases covering multiple values, nil/unset values, nonexistent nodes, single node, and mixed data types.Type of change
How Has This Been Tested?
test/client_tests/batch_read_test.exs(batch read multiple values, nil values, nonexistent node per-node error, single node, mixed data types)Test Configuration:
Checklist:
Note
Medium Risk
Introduces new C port handler and custom response encoding/decoding, so bugs could cause incorrect values or crashes under malformed inputs or large batches; scope is additive and gated to client reads.
Overview
Adds a new
read_node_values/2client API to batch-read theValueattribute for multiple nodes in one OPC-UA request, returning per-node success/error tuples and handlingnil/array/structured variant decoding in Elixir.Implements the C-side
handle_read_node_valueshandler usingUA_Client_Service_read, registers it in the client request handler table, exposes the new handler in headers, and adds an ExUnit suite covering multi-node reads, unset values, mixed types, and per-node errors.Written by Cursor Bugbot for commit ab85bf6. This will update automatically on new commits. Configure here.