diff --git a/mxaccesscli/docs/usage.md b/mxaccesscli/docs/usage.md index 984397b..920a033 100644 --- a/mxaccesscli/docs/usage.md +++ b/mxaccesscli/docs/usage.md @@ -131,8 +131,9 @@ Verified end-to-end against the live `ZB` galaxy (System Platform 2017 Express, | `MxQualifiedStruct` (14) | – | – | – | Access via dotted member names: `..`. | | `MxInternationalizedString` (15) | ❓ | ❓ | (likely string) | No accessible instance. | | `MxBigString` (16) | ❓ | ❓ | JSON string | No accessible instance. | -| **Array (any type), bulk read** | ❌ | – | — | `MxAccess.AddItem()` → `MxCategoryCommunicationError, Detail=1003`. Bulk array reads are not supported by this LMX client API. | -| **Array element by index** | ✅ | ✅ | scalar of element type | Reference syntax `.[]`. **1-based** indexing. Verified on `MESReceiver_001.MoveInPartNumbers[2]` (String[]). `[0]` is invalid. | +| **Array (any type), bulk read** | ✅ | – | JSON array of element type | Reference syntax `.[]` — **empty square brackets**. Verified on `MESReceiver_001.MoveInPartNumbers[]` (String[50]) and `MoveOutWorkOrderNumbers[]`. Returns the entire array as a single value with `MxCategoryOk`. | +| **Array (bare reference)** | ❌ | – | — | The plain `.` (no brackets) returns `MxCategoryCommunicationError, Detail=1003`. Use `[]` instead. | +| **Array element by index** | ✅ | ✅ | scalar of element type | Reference syntax `.[]`. **1-based**, runs from `[1]` to `[NumElements]`. `[0]` is invalid. | Legend: ✅ verified live, ⚠️ wiring present but no live instance to write, ❓ wiring present but no live instance found, ❌ not supported by MxAccess at this layer, – not applicable. @@ -160,18 +161,51 @@ Common failure shapes: ## Reading arrays -MxAccess does not return array attributes as a single rowset. Bulk `AddItem(".")` returns `MxCategoryCommunicationError, Detail=1003`. Read elements individually: +MxAccess accepts **two** reference forms for arrays — pick by what you need: + +### Whole array — `.[]` (empty brackets) ```powershell -mxa read 'MESReceiver_001.MoveInPartNumbers[1]' \ - 'MESReceiver_001.MoveInPartNumbers[2]' \ - 'MESReceiver_001.MoveInPartNumbers[3]' \ - --llm-json +mxa read 'MESReceiver_001.MoveInPartNumbers[]' --llm-json ``` -- Array indices are **1-based** (`[1]`, `[2]`, …). `[0]` is invalid and returns a configuration error. -- The CLI does not (yet) auto-discover the array length; combine with [`../../grdb/queries/attributes.sql`](../../grdb/queries/attributes.sql) (`array_dimension` column) to know how many elements to fetch. -- Writing an element uses the same indexed reference: `mxa write '.[N]' `. +Returns the full array as a single JSON value: + +```jsonc +{ + "tag": "MESReceiver_001.MoveInPartNumbers[]", + "ok": true, + "value": ["", "11111", "", "", /* ... 50 elements total ... */], + "quality": 192, + "statuses": [{"Success":-1,"Category":"MxCategoryOk", ...}] +} +``` + +The array is fixed-length (sized at deploy time per the template's `array_dimension`). Empty string elements are unset slots, not gaps. + +### Single element — `.[N]` + +```powershell +mxa read 'MESReceiver_001.MoveInPartNumbers[2]' --llm-json +``` + +Indices are **1-based**: `[1]` is the first element, `[NumElements]` is the last. `[0]` is invalid. Single-element reads are also writeable: `mxa write '.[N]' `. + +### What does *not* work + +```powershell +mxa read 'MESReceiver_001.MoveInPartNumbers' # bare ref, no brackets +# → MxCategoryCommunicationError, Detail=1003 +``` + +The plain reference (no `[]`, no `[N]`) is rejected by the proxy. Always include the brackets — empty for whole-array, indexed for element. + +### Discovering array length + +The CLI doesn't (yet) auto-discover element count. Two ways to find it: + +1. Read with `[]` and count the returned values. +2. Query the Galaxy Repository's [`../../grdb/queries/attributes.sql`](../../grdb/queries/attributes.sql) — the `array_dimension` column reports the configured size from the template. ## Picking a tag for a smoke test