Modules, Groups and the Store

Modules

A module is one procedure with its own nodes. Each entry of modules in the application file 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.

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

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.

store

Read from the group’s store under key (the parameter name when key is left out). No node. Required for a handle 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/.

store (default for handles)

Written to the group’s store under key (the parameter name when left out). No node.

both

Node and store.

none

Dropped.

A value carried from run to run

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:

"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

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.