Loading...
 
Skip to main content

NOTE: This is the documentation for an older version of the Huygens Loadable Modules interface, which was used up to version 15.10 of Huygens. Documentation for the new interface (Huygens 16.05 and newer) can be found here.

Huygens Modules

1 Introduction

Huygens Loadable Modules allows you to create modules that extend Huygens Professional. It provides access to internal functions for image processing. Modules are written in C and Tcl. Graphical User Interfaces can be written using the Tk-toolkit.

2 Requirements

To use loadable modules you need a working installation of Huygens Professional and a C compiler.

3 Usage

To make use of loadable modules Huygens should be started with the “-checkLoadMod” option. This option directs Huygens to search for modules in the SVI/PlugIn directory. Multiple loadable modules can be loaded simultaneously with or without configuration files.

4 Developing modules

4.1 Overview

A loadable module consists of at least a Makefile and C source files. Additionally a module can have a ‘gui’ folder with Tcl/Tk files for the GUI and a ‘doc’ folder for module documentation. The files in the GUI folder are automatically sourced on module initialization.

4.2 Initialization

Every Huygens Loadable Module includes the HuLoadableMod.h header file to access the loadable module functionality. A module is initialized in the HuLoad_Init function.

Copy to clipboard
void HuLoad_Init( void ) ;

This initialization function is called when a module is loaded by Huygens at start-up.

4.3 Commands and image operations

In the initialization function you can create Tcl commands and add image operations. With the following function you can create a Tcl command:

Copy to clipboard
int HuLoad_CreateTclCmd ( const char ∗comName , HuLoad CmdFuncType ∗ comFuncPtr );
After the Tcl command is registered you can type the command ‘comName’ in the Tcl interpreter to call the function where ‘comFuncPtr’ points to. To add an image operation this function should be called:
Copy to clipboard
HuExt ErrorTokenType HuLoad AddImgOpFunc const char ∗imgOpName , HuLoad ImgOpFuncType ∗imgOpFuncPtr );

This adds an operation with name ‘imgOpName’ that can be applied to images. The function where ‘imgOpFuncPtr’ points to will be applied to the images.

4.4 GUI communication

Communication with a Tcl/Tk GUI is handled with a String token. A String token can be created, destroyed using the following functions:

Copy to clipboard
HuExt ErrorTokenType huExt_CreateString ( const char ∗ callerName , HuExt StringTokenType ∗ token ); HuExt ErrorTokenType huExt_DestroyString ( const char ∗ callerName , HuExt StringTokenType token );

The module can add output to the String token using the following command:

Copy to clipboard
HuExt ErrorTokenType huExt AppendToString ( const char ∗ callerName , HuExt StringTokenType token , const char ∗ ptr );

To send the String to the Tcl interpreter to be handled you can call the following function:

Copy to clipboard
HuExt ErrorTokenType HuLoad StringToken2Tcl ( HuExt StringTokenType stringToken );

5 Example

Download the FRAP simulator from our download page to see what a Huygens Module looks like.

6 Building and executing the module

In the FRAP simulator one can see which files are necessary to build a module. Besides the C implementation of a particular function one needs to provide a Makefile that compiles the C code and copies the object files to the HOME/SVI/PlugIn directory.

After a successful build the module can be loaded into Huygens by using the checkLoadMod argument. The module can then be used as an extension command to the regular Huygens library. The command can perform any operation on the images and a GUI can be build around it.

For example, the FRAP simulator is equipped with a GUI which is launched by typing
Copy to clipboard
::FrapSimulator::create
at the Tcl shell of Huygens Professional.

7 Licensing

Huygens Loadable Modules is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License (as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty ; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses/.