---
title: "Modules, Groups and the Store"
description: "How LumiScan Script Runner organises procedures: one module per procedure, groups with one worker thread, the group's store for handles, and bindings."
product: "LumiScan Script Runner"
component: "lumiscan-script-runner"
version: "1.0.0"
display_version: "1.0.0.2"
latest_version: true
language: "en"
url: "https://docs.hdvisionsystems.com/en/lumiscan-script-runner/modules-groups-and-store.html"
---

# Modules, Groups and the Store – LumiScan Script Runner

## Modules

A **module** is one procedure with its own nodes. Each entry of `modules` in the [application file](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/application-file.html) is one module. Several modules may run the same procedure, each with its own bindings.

How a module is started is its `trigger`:

| Trigger | Meaning |
| --- | --- |
| `handshake` (default) | The module has a `run` function. A client starts a run with the [run handshake](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/run-handshake.html). |
| `start` | The module runs once when its group starts, before the group serves any request. It has no `run` function and no input or output nodes. Use it to read a model, open a dictionary or set up any state that the group’s other modules use. |

## Groups

A **group** is one worker thread and one store. The modules of a group run one at a time, in the order their requests arrive. A module without `group` is a group of its own.

- Modules that share a handle **must** be in one group: HALCON handles are not safe to use from two threads at once.
- Modules without shared state should be in groups of their own: different groups run in parallel.
- While one module of a group runs, the other modules of the group stay `ready`. A request to them is acknowledged (`running` turns `true`) and waits in the group’s queue until it is its turn.

`v1/system/groups` lists every group with its modules and the keys in its store.

## The store

The **store** of a group maps a key to a HALCON value: a control tuple (a handle is one) or an iconic object such as an image. Values never cross the Data Layer: a client can see which keys exist (`v1/system/groups`), never their content.

- An output bound to the store is written only after a successful run whose outputs passed the output check.
- An input bound to the store that finds its key empty ends the run with `-10004`; the status text names the key and the modules that write it.
- Before each run every handle taken from the store is checked: still valid, and of the semantic type the interface declares, if it declares one. A mismatch ends the run with `-3`; the procedure does not run.
- The store lives in memory only. It is empty after a restart; `start` modules fill it again.

## Bindings {#bindings}

Every parameter has a binding: where an input comes from, where an output goes. Set them under `inputs` and `outputs` of a module, keyed by the parameter name.

| Direction | Binding | Meaning |
| --- | --- | --- |
| Input | `node` (default for values and images) | A node under `run/input/`. The client writes it. |
| Input | `store` | Read from the group’s store under `key` (the parameter name when `key` is left out). No node. Required for a handle input. |
| Input | `value` | A fixed value from the settings. No node. A file name is resolved in the script folder. |
| Output | `node` (default for values and images) | A node under `run/output/`. |
| Output | `store` (default for handles) | Written to the group’s store under `key` (the parameter name when left out). No node. |
| Output | `both` | Node and store. |
| Output | `none` | Dropped. |

## A value carried from run to run {#carried-value}

A procedure cannot use one name for an input and an output. To carry a value from one run to the next, give the procedure an output and an input and bind both to the same store key:

```json
"inputs":  { "TrackState":    { "from": "store", "key": "track" } },
"outputs": { "TrackStateOut": { "to": "store",   "key": "track" } }
```

The first run finds the key empty and ends with `-10004`, unless a `start` module of the group fills it first.

## Two modules in a row {#chain}

Two handshake modules of one group can pass values by name: module A’s output `{"to": "store"}` and module B’s input `{"from": "store"}`, both without a key, use the parameter name. B takes A’s last value of that name. This only works inside one group, whose single worker keeps the runs in order.
