NOTE: This is the documentation for the new version of the Huygens Loadable Modules interface, used in recent versions of Huygens (20.04 and newer). Documentation for the old interface (up to Huygens 15.10) can be found here.
Huygens Loadable Modules
Table of contents
1 Introduction
Huygens Loadable Modules allows you to create modules that extend Huygens Professional. It allows you define new Tcl commands, create user interfaces, and provides low-level access to the Huygens images. 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 one or more 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 The module source file
A loadable module can consist of one or more C files, which all should include the HuExtern.h include file. Before including the HuExtern.h file, a unique global variable name should be defined, in this way:
In one of the source files the following macro should be called:
4.3 The initialization function
Every Huygens Loadable Module should implement the InitHuygensExtension fuction:
This initialization function is called when a module is loaded by Huygens at start-up. It should contain a call to the following macro, before any other plugin functions are called:
4.4 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:
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:This adds an operation with name ‘opName’ that can be applied to an image by calling the function that is passed by ‘imgOpFuncPtr’.
4.5 Error handling
Most functions that are provided by HuExtern.h return an error that can have the value 'HUEXT_OK" or "HUEXT_ERROR". Functions you add with 'HuExt_CreateTclCmd' or 'HuExt_ImgOpFuncType' should also return HUEXT_OK when succesful, or HUEXT_ERROR otherwise.
To report an error message you can set the Tcl result to an error message using:
4.6 GUI communication
Communication with a Tcl/Tk GUI is handled with a String token. A String token can be created and destroyed using the following functions:
Text can be added to the string token using the following command:
To set the result of a Tcl command that you added you can call the following function:
You can also print to the Huygens report window using:
4.7 Accessing Huygens images
A number of functions are availabe for low-level access to Huygens images:
The definitions of the various C types needed to use these functions can be found in HuExtern.h.
5 Examples
Here is a simple example of a minimal Huygens Module which implements a Tcl command that just prints its arguments to the Huygens report window and an image command which just returns the image dimensions in the Tcl result string of the command:
Download the FRAP simulator to see what a more complex 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 typing7 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 http://www.gnu.org/licenses/.