.. _cb_tonlogalarmcb: TOnLogAlarmCB ------------------------------------------ This callback 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. See :ref:`Rules for callback functions `. **Defined in:** ``DRFLEx.h`` .. code-block:: cpp // 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** .. list-table:: :header-rows: 1 :widths: 20 25 15 40 * - Parameter Name - Data Type - Default Value - Description * - pLogAlarm - :ref:`LOG_ALARM ` - - - Pointer to the structure containing alarm group, level, index, and parameter details. **Return** |br| None **Example** .. code-block:: cpp #include "DRFLEx.h" #include #include #include 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() { CDRFLEx 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 :ref:`LOG_ALARM ` structure provides details such as alarm **group**, **level**, **index**, and **parameters**. - Common uses: |br| - Logging or displaying alarm history |br| - Detecting critical errors or warnings |br| - Implementing custom fault-recovery logic |br| - An alarm index is unique only within its group. Always match the pair (group, index); the same index has different meanings in different groups. The controller identifies each alarm by its group and index. DART Studio shows the message of each alarm it receives while connected, and the alarm search on the Doosan Robotics `service portal `__ describes every alarm code.