Add a Module

A module runs one procedure and gets its own nodes under v1/<module>/. This guide adds a module find that runs a procedure find_pattern.

You need a procedure prepared as described in Prepare a HALCON Procedure.

1. Copy the procedure

Copy find_pattern.hdvp, and its interface file find_pattern.interface.json if it has one, into the script folder, see Settings Folder. Copy any file the procedure reads there too.

2. Add the module to the application file

Open lumiscan-script-runner.json in the settings folder and add an entry to modules:

{
    "name": "find",
    "procedure": "find_pattern",
    "trigger": "handshake"
}
  • name is the module’s name on the Data Layer: lower case, only a-z, 0-9, - and _. system, api-version and v followed by digits are reserved.

  • procedure is the file name without .hdvp.

  • Without inputs and outputs every value and image parameter gets a node. To give a parameter a fixed value, or to take it from the group’s store, add a binding, see Bindings.

  • Without group the module is a group of its own. Modules that share a model go into one group, see Share a Model Between Scripts.

Alternatively write the whole application file to v1/system/settings over the Data Layer: it is checked and saved, and v1/system/restart-required turns true.

3. Start the app and read the interface hash

  1. Restart LumiScan Script Runner.

  2. Read v1/find/status/code. Expected: -10005. A new module has no accepted interface hash yet, so its nodes are not built; status/text says so.

    If the code is -10002 instead, the procedure did not load or its interface cannot be mapped: status/text names the parameter. Correct the procedure or its interface file, then restart. See Troubleshooting. When the text says a parameter has no type, write an interface file from the shape script/interface shows, see Writing one from the procedure’s shape.

  3. Read v1/find/script/interface. Check the parameters, their types and where the types come from (typeSource).

  4. Read v1/find/script/interface-hash, for example sha256:4f1c….

4. Accept the interface

The accepted hash says: this is the interface my PLC program is written for.

  1. Copy the hash into the module’s entry:

    {
        "name": "find",
        "procedure": "find_pattern",
        "trigger": "handshake",
        "acceptedInterfaceHash": "sha256:4f1c…"
    }
  2. Restart the app.

  3. Read v1/find/status/code. Expected: 0. The module’s input and output nodes are under v1/find/run/.

Note the accepted hash in your PLC project. Your PLC program can compare it with v1/find/script/accepted-interface-hash at its start.

5. Test the module

Run it once with the run handshake, as in Run Your First Script. Then connect your PLC function block, see The run Handshake.

Removing a module

Delete its entry from modules and restart the app. Its nodes are gone after the restart. The procedure file can stay in the script folder.