Skip to content

About the main classes and methods of HDevEngine🔗

HDevEngine is provided as a C++ class library and a .NET assembly. The following classes form the main API for running HDevelop programs and procedures from an application.

Note

  • A program can contain many local and external procedures, and the same HDevelop logic can be used either as a complete program or as a set of callable procedures.
  • The engine is designed for embedded execution and direct integration of HDevelop algorithms into C++ or .NET applications.
  • Global configuration must be treated carefully in multithreaded code. Call instances are independent, but the shared engine state is not.
  • HDevEngine supports JIT compilation for suitable procedures, which can improve performance for repeated calls.

clHDevEngineName class🔗

This is the main HDevEngine class. It manages the global HDevEngine state, including:

  • the procedure path for loading external procedures
  • engine attributes and configuration
  • the registration of HDevelop operator implementations
  • the execution context for loaded programs and procedures
#include "HalconCpp.h"
#include "HDevEngineCpp.h"

using namespace HalconCpp;
using namespace HDevEngineCpp;

clHDevEngineName engine;

Typical configuration calls include:

  • SetProcedurePath(...) / AddProcedurePath(...)
  • SetEngineAttribute(...)
  • SetHDevOperatorImpl(...)
  • StartDebugServer() / StopDebugServer()

This class also owns the global configuration that is shared by all threads that use the same engine instance.


clHDevProgramName class🔗

This class loads an HDevelop program and provides general information about it.

clHDevProgramName program(engine, "my_program.hdev");

With this class you can:

  • load an HDevelop program from disk
  • inspect the program metadata
  • create a clHDevProgramCallName for execution
  • optionally compile used procedures with the JIT compiler

A program is conceptually the entry point for an HDevelop program, while the actual image-processing logic can still live in procedures used by that program.


clHDevProgramCallName class🔗

This class represents a program execution. It is used to run a program and retrieve the values of its variables.

clHDevProgramCallName program_call(program);
program_call.Execute();

Typical tasks are:

  • executing an HDevelop program
  • reading control and iconic variables after execution
  • handling exceptions via clHDevEngineExceptionName

This call object is independent of other call instances. The call objects are used as per-thread execution objects, while the global engine configuration remains shared.


clHDevProcedureName class🔗

This class loads one HDevelop procedure and provides metadata about it.

clHDevProcedureName proc(engine, "detect_fin");

Typical tasks include:

  • loading a procedure by name
  • checking the procedure signature and metadata
  • creating a clHDevProcedureCallName
  • compiling the procedure or its used procedures with JIT compilation

External procedures can be loaded by setting the procedure path; local procedures are loaded as part of a program and are then resolved by the engine.


clHDevProcedureCallName class🔗

This class represents a procedure execution from a single thread. It is used to pass input parameters, execute the procedure, and retrieve the output parameters.

clHDevProcedureCallName call(proc);
call.SetInputOutputParams(...);
call.Execute();

Typical tasks are:

  • setting input control and iconic parameters
  • executing the procedure
  • reading output control and iconic parameters
  • handling runtime errors and return values

Input and output parameters are stored in the call object and can be read back after execution using the procedure-call API.


clHDevOperatorImplName class🔗

This class is used to implement the internal HDevelop operators that the program uses, in particular the dev_* operators. HDevEngine does not provide a complete display implementation for all of HDevelop; instead, the application can provide an operator implementation that redirects calls like dev_display to application-specific visualization logic.

class MyHDevOperatorImpl : public clHDevOperatorImplName {
public:
    // override the required dev_* methods
};

This is essential when an HDevelop program uses display operators but the host application wants to control the visualization itself.


clHDevEngineExceptionName class🔗

This is the exception type raised by HDevEngine when an error occurs during loading, execution, or operator handling.

try {
    // load or execute the HDevelop logic
}
catch (const clHDevEngineExceptionName& ex) {
    // display or log the error
}

The exception contains the error category and a message that helps diagnose the cause of the failure.