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"
}
-
nameis the module’s name on the Data Layer: lower case, onlya-z,0-9,-and_.system,api-versionandvfollowed by digits are reserved. -
procedureis the file name without.hdvp. -
Without
inputsandoutputsevery 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
groupthe 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
-
Restart LumiScan Script Runner.
-
Read
v1/find/status/code. Expected:-10005. A new module has no accepted interface hash yet, so its nodes are not built;status/textsays so.If the code is
-10002instead, the procedure did not load or its interface cannot be mapped:status/textnames the parameter. Correct the procedure or its interface file, then restart. See Troubleshooting. When the text says a parameterhas no type, write an interface file from the shapescript/interfaceshows, see Writing one from the procedure’s shape. -
Read
v1/find/script/interface. Check the parameters, their types and where the types come from (typeSource). -
Read
v1/find/script/interface-hash, for examplesha256:4f1c….
4. Accept the interface
The accepted hash says: this is the interface my PLC program is written for.
-
Copy the hash into the module’s entry:
{ "name": "find", "procedure": "find_pattern", "trigger": "handshake", "acceptedInterfaceHash": "sha256:4f1c…" } -
Restart the app.
-
Read
v1/find/status/code. Expected:0. The module’s input and output nodes are underv1/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.