You're reading the documentation for an older, but still supported version (1.33.4).
For information on the latest version, please have a look at 1.33.5.

TOnMonitoringSafetyStateCB

This callback is called each time the controller reports the robot’s safety state. It receives the state as a SAFETY_STATE value. Compare it with the previous value to detect a change.

See Rules for callback functions.

Defined in: DRFLEx.h

// typedef (DRFLEx.h)
typedef void (*TOnMonitoringSafetyStateCB)(const SAFETY_STATE);

// registration API (internal + wrapper)
DRFL_API void _set_on_monitoring_safety_state(LPROBOTCONTROL pCtrl, TOnMonitoringSafetyStateCB pCallbackFunc);

// user-callable API
void set_on_monitoring_safety_state(TOnMonitoringSafetyStateCB pCallbackFunc)
{
    _set_on_monitoring_safety_state(_rbtCtrl, pCallbackFunc);
};

Parameter

Parameter Name

Data Type

Default Value

Description

eSafetyState

SAFETY_STATE

Indicates the current safety state reported by the robot controller.

Return
None

Example

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

// Callback triggered when the robot's safety state changes
void OnMonitoringSafetyStateCB(SAFETY_STATE eState)
{
    cout << "[SAFETY STATE UPDATED]" << endl;
    switch (eState)
    {
        case SAFETY_STATE_SW_RUN:
            cout << "Safety State: standalone workspace RUN." << endl;
            break;
        case SAFETY_STATE_CW_RUN:
            cout << "Safety State: collaborative workspace RUN." << endl;
            break;
        case SAFETY_STATE_VD_STO:
            cout << "Safety State: violation detected, STO." << endl;
            break;
        case SAFETY_STATE_RV_MOVE:
            cout << "Safety State: recovery MOVE." << endl;
            break;
        default:
            cout << "Safety State: UNKNOWN (" << (int)eState << ")" << endl;
            break;
    }
}

int main()
{
    CDRFLEx drfl;

    // Connect to robot controller
    if (!drfl.open_connection("192.168.137.100")) {
        cout << "Failed to connect to controller." << endl;
        return -1;
    }

    // Register callback for monitoring safety state
    drfl.set_on_monitoring_safety_state(OnMonitoringSafetyStateCB);

    // Keep monitoring continuously
    while (true)
        std::this_thread::sleep_for(std::chrono::seconds(1));

    drfl.close_connection();
    return 0;
}

Notes

  • The callback is triggered whenever the safety state changes due to:
    - Emergency stop (E-Stop)
    - Protective stop
    - Safety door/fence signal
    - Safety mode transition (e.g., Manual ↔ Auto)

  • The SAFETY_STATE enumeration defines the possible safety conditions.

  • Recommended usage:
    - Display real-time safety status
    - Log or alert operators upon stop or hazard events
    - Trigger robot recovery or safe-shutdown sequences