You're reading the documentation for an older, but still supported version
(GL013300).
For information on the latest version, please have a look at GL013301.
For information on the latest version, please have a look at GL013301.
TOnMonitoringModbusCB
This is a callback function for checking Modbus I/O state data registered in the robot controller. As the callback function is executed automatically upon Modbus monitoring updates, a code that requires excessive execution time (within 50 msec) inside the callback function should not be made.
Defined in: DRFL.h
// typedef (DRFL.h)
typedef void (*TOnMonitoringModbusCB)(const LPMONITORING_MODBUS);
// registration API (internal + wrapper)
DRFL_API void _SetOnMonitoringModbus(LPROBOTCONTROL pCtrl, TOnMonitoringModbusCB pCallbackFunc);
void SetOnMonitoringModbus(TOnMonitoringModbusCB pCallbackFunc)
{
_SetOnMonitoringModbus(_rbtCtrl, pCallbackFunc);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
pModbus |
Pointer to structure containing Modbus register symbols and values. |
Return
None
Example
#include "DRFL.h"
#include <iostream>
using namespace DRAFramework;
using namespace std;
// Callback: invoked when Modbus monitoring data updates
void OnMonitoringModbusCB(const LPMONITORING_MODBUS pModbus)
{
if (!pModbus) return;
cout << "[MODBUS] register count = " << pModbus->_iRegCount << endl;
// Each entry contains a symbol (name) and its current value
for (int i = 0; i < pModbus->_iRegCount; ++i)
{
// Example fields based on structure naming
// _tRegister[i]._szSymbol → register name
// _tRegister[i]._iValue → register value
cout << " " << pModbus->_tRegister[i]._szSymbol
<< " : " << pModbus->_tRegister[i]._iValue << endl;
}
}
int main()
{
CDRFL drfl;
// Connect to the controller
if (!drfl.open_connection("192.168.137.100")) {
cout << "Failed to connect to controller." << endl;
return -1;
}
// Register Modbus monitoring callback
drfl.set_on_monitoring_modbus(OnMonitoringModbusCB);
// Keep process alive to receive Modbus updates
while (true)
std::this_thread::sleep_for(std::chrono::seconds(1));
drfl.close_connection();
return 0;
}
Notes
Use this callback to build Modbus dashboards, alarm rules, or data logging pipelines.
For I/O state (GPIO) monitoring, see TOnMonitoringCtrlIOCB and its EX variants.
Keep the callback lightweight (execution time < 50 ms) and avoid blocking operations.