FSMDEV_INIT callback function
The FSMDEV_INIT callback function is invoked immediately after the plugin module is loaded and is intended to provide an opportunity for module-level initialization for a Lua script execution.
During this callback, a handle representing the fsmapper runtime environment is provided to the plugin, which may be used to interact with fsmapper through runtime service functions, depending on the plugin’s implementation.
Syntax
typedef bool (*FSMDEV_INIT)(
FSMAPPER_HANDLE mapper
);
Parameters
| Parameter | Type | Description |
|---|---|---|
mapper | FSMAPPER_HANDLE | A handle representing the fsmapper runtime instance associated with the current Lua script execution. This handle is passed to fsmapper runtime service functions and serves as the plugin’s primary interface to fsmapper. |
Return Values
Returns true if the plugin module was successfully initialized.
Returns false if initialization failed. In this case, fsmapper will treat the plugin as unusable for the current Lua script execution and will unload the module.
Remarks
-
The
FSMDEV_INITcallback is invoked once each time the plugin module is loaded. Plugin modules are loaded and unloaded per Lua script execution, not once at fsmapper startup. As a result, this callback may be called multiple times during the lifetime of the fsmapper process. -
The
mapperparameter is an opaque handle that represents the fsmapper runtime itself from the plugin’s point of view. The internal structure of this handle is not exposed and must not be accessed directly by the plugin. -
The
mapperhandle must be passed to fsmapper runtime service functions in order to perform operations such as message output, event notification, or context association. -
Plugins may associate plugin-specific context data with the
FSMAPPER_HANDLEby using the fsmapper runtime service functionfsmapper_setContext. This callback is the recommended place to allocate and initialize module-level dynamic resources and attach them to the handle. -
Context data associated with the
FSMAPPER_HANDLEcan later be retrieved by thefsmapper_getContextfunction and used by other callback functions invoked for the same plugin module, allowing shared state to be maintained across callbacks. -
Any resources allocated during
FSMDEV_INITshould be released in the correspondingFSMDEV_TERMcallback.