# Example ICCP/TASE.2 Explorer (TUI)

An interactive terminal UI for browsing and operating an ICCP/TASE.2 server,
built with [Bubble Tea](https://github.com/charmbracelet/bubbletea). It connects,
discovers the full object model, and lets you read, write, build datasets, and
watch transfer-set reports live.

Where the [`client`](../client) example runs a fixed script, the explorer is
driven entirely by the keyboard.

## Run

Start the [example server](../server) first, then:

```bash
tase2-explorer                                   # connect to 127.0.0.1:102
tase2-explorer --host 10.0.0.5 --port 102
tase2-explorer --port 10222 --password test      # ACSE authentication
tase2-explorer --log /tmp/iccp.log               # capture protocol logs
```

### Flags

| Flag | Default | Description |
|------|---------|-------------|
| `--host` | `127.0.0.1` | ICCP server host. |
| `--port` | `102` | ICCP server port. |
| `--local-ap` | `1.1.999.2` | Local (calling) AP title. |
| `--local-ae` | `12` | Local (calling) AE qualifier. |
| `--remote-ap` | `1.1.999.1` | Remote (called) AP title — must match the server. |
| `--remote-ae` | `12` | Remote (called) AE qualifier. |
| `--password` | `""` | ACSE authentication password to send. Required if the server was started with `--password`. |
| `--log` | `""` | Write protocol logs to this file (empty discards them — the TUI owns the screen, so logs must not go to stderr). |

## Features

- **Auto-read** — moving the selection automatically reads the value (and fetches
  its type), so the right pane always shows current data; toggle a 1-second
  auto-refresh with `f`.
- **Structure unpacking** — structured values (e.g. the whole DSTransferSet
  record, or a `DataSetName` `{Scope, DomainName, Name}`) are shown as indented,
  **named** fields, using the type returned by `GetVariableAccessAttributes`.
- **Bit-string decoding** — `DSConditionsRequested` is decoded into flag names
  (`Interval + Change`, …); other bit strings list their set bits.
- **Dynamic datasets** — mark variables while browsing (`m`), then create a
  `NamedVariableList` from them (`n`); delete a dataset with `x`.
- **Transfer sets** — activate (`a`) / deactivate (`d`) a DSTransferSet and watch
  its `InformationReport`s stream into the bottom pane.
- **Filtering** — `/` filters the tree to matching nodes and their ancestors.
- **Writes** — `w` writes a typed value to a control point.

## Key bindings (browse view)

| Key | Action |
|-----|--------|
| `↑/↓` `j/k` | move selection (auto-reads the value) |
| `Enter` `→/l` · `←/h` | expand · collapse |
| `e` / `c` | expand all / collapse all |
| `g` / `G` | jump to top / bottom |
| `r` | re-read the selected variable / dataset |
| `f` | toggle auto-refresh (1 s) of the selected value |
| `w` | write a value (control points only) |
| `m` | mark/unmark a variable for a new dataset |
| `n` | create a dataset from the marked variables |
| `x` | delete the selected dataset |
| `a` / `d` | activate / deactivate a DSTransferSet |
| `/` | filter the tree (Esc clears, Enter keeps) |
| `R` | rediscover the server model |
| `?` | toggle the key-binding overlay |
| `q` / `Ctrl+C` | quit |

## Notes

- The explorer's default identities line up with the [example server](../server)
  and its bilateral table; change the `--*-ap`/`--*-ae` flags to talk to other
  servers.
- Because the UI takes over the terminal, library logging is redirected: use
  `--log <file>` to inspect the ACSE/MMS protocol trace while the UI runs.
