get_last_alarm (Auto Mode)

This section explains how to use get_last_alarm during Auto (Run) operations to read the most recent alarm or log event generated by the robot controller.

This function is essential for diagnosing why a DRL program stopped, why a motion was interrupted, or whether a system/safety event occurred during automatic execution.

Typical usage

  • Check the cause of a task interruption after drl_stop.

  • Retrieve system or safety alarms triggered during DRL execution.

  • Log alarms to external systems (HMI, MES, databases) for traceability.

  • Use in recovery logic to decide whether the robot can safely resume operation.

Note

  • The function returns a pointer to the latest LOG_ALARM structure.

  • Always check for nullptr before accessing fields.

  • Values include group, level, index, and message parameters.

Example: Reading the Latest Alarm After a Stop Event

#include "DRFLEx.h"
#include <iostream>
using namespace DRAFramework;

int main() {
    CDRFLEx drfl;

    // 1) Retrieve last alarm information
    LPLOG_ALARM alarm = drfl.get_last_alarm();

    if (alarm == nullptr) {
        std::cout << "No alarm information available." << std::endl;
        return -1;
    }

    // 2) Print basic alarm info
    std::cout << "Alarm Group: " << alarm->_iGroup << std::endl;
    std::cout << "Alarm Level: " << alarm->_iLevel << std::endl;
    std::cout << "Alarm Index: " << alarm->_iIndex << std::endl;

    // 3) Print parameters (if available)
    std::cout << "Parameters: "
              << alarm->_szParam[0] << ", "
              << alarm->_szParam[1] << ", "
              << alarm->_szParam[2] << std::endl;

    return 0;
}

In this example, the external application retrieves the latest alarm from the controller and prints key fields such as group, level, index, and message parameters. This is useful for diagnosing faults or validating that a stop event was handled correctly.

Tips

  • Use immediately after motion or DRL interruptions to determine cause.

  • Integrate into logging systems for production traceability.

  • Helpful during debugging of Auto Mode workflows.

  • Combine with monitoring callbacks for real-time alarm responses.