set_on_rt_log_alarm

This function registers a callback for the messages the controller sends about the RT session: an unsupported version, RT input not received within the set time, a missing heartbeat, and another RT client already connected.

Motion warnings and errors during RT control, including rejected RT commands, are reported through set_on_log_alarm. Register both callbacks.

Definition
DRFLEx.h within class CDRFLEx, public section

void set_on_rt_log_alarm(TOnLogAlarmCB pCallbackFunc) {
    _set_on_rt_log_alarm(_rbtCtrlUDP, pCallbackFunc);
};

Parameter

Parameter Name

Data Type

Description

pCallbackFunc

TOnLogAlarmCB

Function pointer to user-defined callback that handles
log or alarm messages sent from the robot controller.

Note

Example

#include <chrono>
#include <thread>

// Define callback for alarm and log monitoring
void OnRTLogAlarm(LPLOG_ALARM pLogAlarm) {
    printf("[RT LOG/ALARM] group %d, index %d: %s\n",
           pLogAlarm->_iGroup, pLogAlarm->_iIndex, pLogAlarm->_szParam[0]);
}

drfl.connect_rt_control("192.168.137.100", 12347);

// Register real-time log and alarm callback
drfl.set_on_rt_log_alarm(OnRTLogAlarm);

// Configure and start RT control
string version = "v1.0";
float period = 0.001f;
int losscount = 4;

drfl.set_rt_control_input(version, period, losscount);
drfl.set_rt_control_output(version, period, losscount);
drfl.start_rt_control();

// Keep the RT session open for 60 s; the callback runs when a message arrives
const auto tEnd = std::chrono::steady_clock::now() + std::chrono::seconds(60);
while (std::chrono::steady_clock::now() < tEnd) {
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

drfl.disconnect_rt_control();

In this example, OnRTLogAlarm() prints each RT session message the controller sends.

Tips

  • Useful for detecting RT input timeouts and session problems during live control.

  • Integrate with a GUI or network logger to visualize alarm states in real time.

  • When the controller ends the RT session, it reports an alarm to the set_on_rt_log_alarm callback, and RT data stops.

  • Do not call get_rt_control_input_version_list, get_rt_control_output_version_list, get_rt_control_input_data_list, get_rt_control_output_data_list or disconnect_rt_control from an RT callback; the call does not return. connect_rt_control called from an RT callback returns false and prints connect_rt_control() cannot be called from an RT callback.