Interface File
An interface file gives the types of a procedure’s parameters outside the procedure. Use it when a procedure is not documented in HDevelop, when you do not want to change the procedure, or before you protect it. It lies next to the procedure in the script folder and is named after it: count_blobs.interface.json for count_blobs.hdvp.
v1/<module>/script/interface shows the same format for the interface the module actually uses, with the field typeSource for each parameter.
Example
{
"format": 1,
"procedure": "count_blobs",
"parameters": [
{ "group": "output_iconic", "name": "Binary", "position": 1, "dimension": 0,
"objectClass": "image", "pixelTypes": ["byte"],
"description": "the blobs white (255) on black, the size of the image" },
{ "group": "input_ctrl", "name": "ImageFile", "position": 1, "dimension": 0,
"semType": "filename.read", "elementTypes": ["string"],
"default": "blobs.png", "description": "an image file in the script folder" },
{ "group": "input_ctrl", "name": "MinGray", "position": 2, "dimension": 0,
"elementTypes": ["integer"], "default": "128", "min": "0", "max": "255",
"description": "the lowest gray value of a blob" },
{ "group": "output_ctrl", "name": "Areas", "position": 2, "dimension": 0,
"elementTypes": ["integer"], "multivalue": "true", "unit": "px",
"description": "each blob's area" }
]
}
Top level
| Key | Type | Meaning |
|---|---|---|
|
integer |
Required. |
|
string |
The procedure’s name. |
|
array |
Required. One entry per parameter of the procedure, see Parameter entry. |
|
array of strings |
Optional. The HALCON modules the procedure needs, for example |
|
string |
Optional. The interface hash of the content ( |
Parameter entry
| Key | Type | Meaning |
|---|---|---|
|
string |
Required. |
|
string |
Required. The parameter’s name as in the procedure. |
|
integer |
1-based position within its group. Display order only. |
|
integer |
|
|
string |
Free label, for example |
|
array of strings |
Control parameters: |
|
string |
Control parameters: |
|
boolean |
Control parameters: |
|
string |
Iconic parameters: |
|
array of strings |
Images: the accepted pixel types, for example |
|
string |
Images: |
|
string |
Shown in the node’s description. |
|
string |
The default value (the input node’s first value) and the range of a number. An input outside |
|
array |
The suggested values, as in HALCON’s documentation. |
Type names outside the closed type set refuse the procedure and name the parameter. An iconic parameter must not have elementTypes, a control parameter must not have objectClass or pixelTypes.
Building one over the Data Layer
The Script Runner can build the file for you. Under v1/system/ it serves six functions, each with the handshake of a module’s run (Run Handshake): write the inputs, set request, wait for done or has-error, read the outputs, set request back to false. Every input is a STRING node; every function has output/status-code, output/status-text and output/package-identifier.
| Function | Inputs | What it does |
|---|---|---|
|
|
Starts the procedure’s draft, if there is none yet, and writes it to |
|
|
Sets one parameter’s type in the draft. |
|
|
Takes an interface file’s JSON into the draft, with the rules of How it is merged with the procedure. |
|
|
Writes the draft as file content to |
|
|
Refused while a parameter has no type. Writes |
|
|
Drops the draft. |
There is one draft per procedure. It starts with the first function that names the procedure, from the procedure’s HDevelop documentation merged with its interface file, and lives until interface-save or interface-discard (or until the app stops). An interface file that no longer fits the procedure is left out of the draft: interfaceFile.used is false, and interfaceFile.issues says why.
A refused call ends with has-error and changes nothing. status-code is -3 for a wrong input (a procedure that is not in the script folder, a type outside the closed type set, a parameter in another group, a file that does not fit, a save with a type missing) and -10002 for a procedure HDevEngine cannot load; status-text says which.
Example: sum_values is not documented in HDevelop and has no interface file.
-
Write
sum_valuestointerface-scan/input/procedureand callinterface-scan.status-text:sum_values: 4 parameter(s) still need a type: A, B, Sum, Text. -
Call
interface-set-parameteronce per parameter, for example withgroupinput_ctrl,parameterAandtype{"elementTypes":["integer","real"]}, then withparameter2forB. Each call says which types are still missing. -
Call
interface-save.status-text:saved sum_values.interface.json (sha256:…); acceptedInterfaceHash of module(s) sum set to it; restart the application …. -
The app cannot load the new file while it runs yet:
v1/system/restart-requiredistrue, and every module reports-5. Restart the app. The module is built with the new interface:status/codeis0,script/interface-sourceisinterface-file, andscript/accepted-interface-hashequalsscript/interface-hash.
A module that does not exist yet when you save gets the hash when you add it: status-text gives it.
Writing one from the procedure’s shape
Without the functions above you can still write the file by hand. You do not have to type it from scratch. The Script Runner reads a procedure’s shape by itself: each parameter’s name, group, position and dimension. Only the types are missing. Start from that shape:
-
Copy the procedure into the script folder, add a module for it to the application file, and restart the app, see Add a Module. The module is refused (
-10005or-10002), but itsscript/nodes are there. -
Read
v1/<module>/script/interface. It holds the shape in the format of an interface file, each parameter without a type marked"typeSource": "missing":{ "format": 1, "procedure": "multiply_values", "interfaceHash": "sha256:0d4aae06…", "parameters": [ { "group": "input_ctrl", "name": "A", "position": 1, "dimension": 0, "typeSource": "missing" }, { "group": "input_ctrl", "name": "B", "position": 2, "dimension": 0, "typeSource": "missing" }, { "group": "output_ctrl", "name": "Product", "position": 1, "dimension": 0, "typeSource": "missing" } ] } -
Save it as
<procedure>.interface.jsonnext to the procedure, then:-
keep
group,name,positionanddimensionas they are; -
delete every
typeSource(a copiedmissingis kept and reported as such) and the top-levelinterfaceHash(a stale one only gives a warning); -
add the type of each parameter:
elementTypes(andmultivalue) for a control parameter,objectClass(andpixelTypes) for an iconic one.{ "format": 1, "procedure": "multiply_values", "parameters": [ { "group": "input_ctrl", "name": "A", "position": 1, "dimension": 0, "elementTypes": ["real"] }, { "group": "input_ctrl", "name": "B", "position": 2, "dimension": 0, "elementTypes": ["real"] }, { "group": "output_ctrl", "name": "Product", "position": 1, "dimension": 0, "elementTypes": ["real"] } ] }
-
-
Restart the app. The types changed the interface, so the module reports
-10005, and itsstatus/textgives the new hash (… now sha256:…). Copy that hash into the module’sacceptedInterfaceHashand restart again.status/codeis now0, andscript/interface-sourceisinterface-file.
You cannot rename a parameter in the interface file: the procedure gets its parameters by name, and each node’s name is made from it. To get another node name, rename the parameter in HDevelop.
How it is merged with the procedure
The file is matched to the procedure by group and name:
-
Parameters in another order: fine, positions come from the procedure.
-
A parameter missing in the file or in the procedure, a rename, a changed group or a changed dimension: the procedure is refused with
-10002, and the text names the parameter. -
Where the file gives a type, it wins. If the procedure’s documentation says something else, a warning is logged.
-
semType,description,unit,default,min,maxandvaluesof the file replace those of the documentation where the file gives them.
| Write the interface file from the open procedure before you protect it with a password, and ship both files. |