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.

TOnMonitoringCtrlIOCB

This callback function is used to check the state data of the I/O installed in the control box of the robot controller. It provides access to digital and analog input/output values of the robot system in real time.

See Rules for callback functions.

Defined in: DRFLEx.h

// typedef (DRFL.h)
typedef void (*TOnMonitoringCtrlIOCB)(const LPMONITORING_CTRLIO);

// registration API (internal + wrapper)
DRFL_API void _set_on_monitoring_ctrl_io(LPROBOTCONTROL pCtrl, TOnMonitoringCtrlIOCB pCallbackFunc);
void set_on_monitoring_ctrl_io(TOnMonitoringCtrlIOCB pCallbackFunc)
{
    _set_on_monitoring_ctrl_io(_rbtCtrl, pCallbackFunc);
};

Parameter

Parameter Name

Data Type

Default Value

Description

pCtrlIO

MONITORING_CTRLIO

Pointer to structure containing digital and analog I/O state data.

Return
None

Example

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

// Callback function triggered when controller I/O state changes
void OnMonitoringCtrlIOCB(const LPMONITORING_CTRLIO pCtrlIO)
{
    cout << "[I/O MONITOR] Digital input state:" << endl;

    for (int i = 0; i < NUM_DIGITAL; ++i)
    {
        cout << "DI#" << i << " : " << static_cast<int>(pCtrlIO->_tInput._iActualDI[i]) << endl;
    }

    cout << "[I/O MONITOR] Digital output state:" << endl;
    for (int i = 0; i < NUM_DIGITAL; ++i)
    {
        cout << "DO#" << i << " : " << static_cast<int>(pCtrlIO->_tOutput._iTargetDO[i]) << 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 callback for I/O monitoring
    drfl.set_on_monitoring_ctrl_io(OnMonitoringCtrlIOCB);

    // Keep program alive to monitor I/O events
    while (true)
    {
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    drfl.close_connection();
    return 0;
}

Notes

  • The callback provides real-time digital/analog I/O values from the robot controller.

  • Commonly used to monitor sensor inputs, signal feedback, or tool I/O state.

  • For extended versions with more detailed data, refer to TOnMonitoringCtrlIOExCB and TOnMonitoringCtrlIOEx2CB.

  • Each callback receives the most recent data. If the callback takes longer than the data period (100 ms before DRCF 3.5, 20 ms from DRCF 3.5), intermediate samples are not delivered. Do not rely on receiving every sample (for example for integration or differentiation).