TOnLogAlarmCB
This is a callback function that is triggered whenever an alarm or log event is generated by the robot controller.
It provides detailed information such as the alarm group, level, and parameters that describe the nature of the warning, error, or system message.
Since the callback function is executed automatically upon a specific event, any process that requires excessive execution time (within 50 msec) should not be performed inside the callback.
Defined in: DRFL.h
// typedef (DRFL.h)
typedef void (*TOnLogAlarmCB)(LPLOG_ALARM);
// registration API (internal + wrapper)
DRFL_API void _set_on_log_alarm(LPROBOTCONTROL pCtrl, TOnLogAlarmCB pCallbackFunc);
// robot alarm data callback
void set_on_log_alarm(TOnLogAlarmCB pCallbackFunc)
{
_set_on_log_alarm(_rbtCtrl, pCallbackFunc);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
pLogAlarm |
Pointer to the structure containing alarm group, level, index, and parameter details. |
Return
None
Example
#include "DRFL.h"
#include <iostream>
using namespace DRAFramework;
using namespace std;
// Callback function that handles alarm and log messages
void OnLogAlarmCB(LPLOG_ALARM pLogAlarm)
{
if (!pLogAlarm) return;
cout << "\n[ROBOT ALARM CALLBACK]" << endl;
cout << "Group : " << pLogAlarm->_iGroup << " ("
<< ((pLogAlarm->_iGroup == LOG_GROUP_SYSTEMFMK) ? "System" : "Other") << ")" << endl;
cout << "Level : " << pLogAlarm->_iLevel << endl;
cout << "Index : " << pLogAlarm->_iIndex << endl;
cout << "Parameters : ";
for (int i = 0; i < 3; ++i)
cout << pLogAlarm->_szParam[i] << (i < 2 ? ", " : "");
cout << endl;
// Example filtering: handle only critical alarms
if (pLogAlarm->_iLevel == LOG_LEVEL_SYSINFO)
cout << "[INFO] System message logged." << endl;
}
int main()
{
CDRFL drfl;
// Connect to the robot controller
if (!drfl.open_connection("192.168.137.100")) {
cout << "Failed to connect to controller." << endl;
return -1;
}
// Register the alarm/log callback
drfl.set_on_log_alarm(OnLogAlarmCB);
// Keep program alive to monitor logs
while (true)
std::this_thread::sleep_for(std::chrono::seconds(1));
drfl.close_connection();
return 0;
}
Notes
Triggered automatically when a system log or alarm is generated.
The LOG_ALARM structure provides details such as alarm group, level, index, and parameters.
Common uses:
- Logging or displaying alarm history
- Detecting critical errors or warnings
- Implementing custom fault-recovery logicKeep callback execution lightweight (execution time < 50 ms).