A base framework for building NetLinx modules with standardized event handling and communication patterns.
ModuleBase provides the foundation for creating reusable NetLinx modules with consistent:
- Device state management
- SNAPI event processing
- Property and passthru event callbacks
- Communication buffer handling
The library is designed around the _NAVModule struct (defined in NAVFoundation.Core) and provides event-driven callbacks for module communication.
_NAVModulePropertyEvent: Handles property change events from SNAPI devices_NAVModulePassthruEvent: Handles passthru data events- Event Callbacks: Optional callback system for processing module events
Important: This version removes automatic module initialization. You must now manually declare and initialize your module.
- ❌ Removed: Global
_NAVModulevariable declaration - ❌ Removed: Automatic
NAVModuleInit()call inDEFINE_START - ✅ Added: Consumer must declare module variable and initialization
Before (Old Version):
#include 'NAVFoundation.ModuleBase.axi'
// Module was automatically declared and initializedAfter (New Version):
#include 'NAVFoundation.ModuleBase.axi'
// You must now declare the module variable
DEFINE_VARIABLE
_NAVModule myModule
// You must now initialize the module
DEFINE_START {
NAVModuleInit(myModule)
}#include 'NAVFoundation.ModuleBase.axi'In your main .axs file:
DEFINE_VARIABLE
_NAVModule myModuleDEFINE_START {
NAVModuleInit(myModule)
}Define the virtual device and enable callbacks:
#define USING_NAV_MODULE_BASE_CALLBACKS
#define USING_NAV_MODULE_BASE_PROPERTY_EVENT_CALLBACK
#define USING_NAV_MODULE_BASE_PASSTHRU_EVENT_CALLBACK
define_function NAVModulePropertyEventCallback(_NAVModulePropertyEvent event) {
switch (event.Name) {
case NAV_MODULE_PROPERTY_EVENT_IP_ADDRESS: {
// Handle IP address changes
}
case NAV_MODULE_PROPERTY_EVENT_PORT: {
// Handle port changes
}
}
}
define_function NAVModulePassthruEventCallback(_NAVModulePassthruEvent event) {
// Handle passthru data
}NAVModuleInit(_NAVModule module): Initialize module with default values
The library automatically handles data_event[vdvObject] for:
- Property Events: Device configuration changes (IP, port, credentials, etc.)
- Passthru Events: Raw data transmission through the module
- NAVFoundation.Core.h.axi (for _NAVModule struct)
- NAVFoundation.ArrayUtils.axi
- NAVFoundation.SnapiHelpers.axi