TOnMonitoringCtrlIOExCB

이 콜백 함수로 로봇 컨트롤러의 컨트롤 박스에 설치된 I/O의 상태 데이터를 확인합니다. DRCF 버전 2를 지원하는 컨트롤러에서 확장된 I/O 정보(디지털 및 아날로그)를 제공합니다.
TOnMonitoringCtrlIOCB보다 I/O 메타데이터가 더 많습니다.

콜백 함수 규칙을 참고하세요.

정의 위치: DRFLEx.h

// typedef 정의(DRFLEx.h)
typedef void (*TOnMonitoringCtrlIOExCB)(const LPMONITORING_CTRLIO_EX);

// 등록 API(내부 + 래퍼)
DRFL_API void _set_on_monitoring_ctrl_io_ex(LPROBOTCONTROL pCtrl, TOnMonitoringCtrlIOExCB pCallbackFunc);
void set_on_monitoring_ctrl_io_ex(TOnMonitoringCtrlIOExCB pCallbackFunc)
{
    _set_on_monitoring_ctrl_io_ex(_rbtCtrl, pCallbackFunc);
};

매개변수

매개변수 이름

자료형

기본값

설명

pCtrlIO

MONITORING_CTRLIO_EX

확장된 디지털/아날로그 I/O 상태 데이터를 담은 구조체의 포인터입니다.

반환값
없음

예제

#include "DRFLEx.h"
#include <iostream>
#include <thread>
#include <chrono>

using namespace DRAFramework;
using namespace std;

// 확장 I/O 데이터가 갱신되면 호출되는 콜백 함수(DRCF_VERSION == 2 필요)
void OnMonitoringCtrlIOExCB(const LPMONITORING_CTRLIO_EX pCtrlIO)
{
    cout << "[I/O EX] GPIO state data" << endl;

    // 디지털 입력
    for (int i = 0; i < NUM_DIGITAL; ++i)
        cout << "DI#" << i << " : " << static_cast<int>(pCtrlIO->_tInput._iActualDI[i]) << endl;

    // 디지털 출력
    for (int i = 0; i < NUM_DIGITAL; ++i)
        cout << "DO#" << i << " : " << static_cast<int>(pCtrlIO->_tOutput._iTargetDO[i]) << endl;

    // 예: 아날로그 I/O(지원하는 경우)
    cout << "AI[0]: " << pCtrlIO->_tInput._fActualAI[0]
         << " | AO[0]: " << pCtrlIO->_tOutput._fTargetAO[0] << endl;
}

int main()
{
#if DRCF_VERSION == 2
    CDRFLEx drfl;

    // 로봇 컨트롤러에 연결
    if (!drfl.open_connection("192.168.137.100")) {
        cout << "Failed to connect to controller." << endl;
        return -1;
    }

    // 연결 후 확장 모니터링 데이터(버전 1) 선택
    drfl.setup_monitoring_version(1);

    // 확장 I/O 모니터링 콜백 함수 등록
    drfl.set_on_monitoring_ctrl_io_ex(OnMonitoringCtrlIOExCB);

    // 이벤트를 수신하도록 프로그램 실행 유지
    while (true)
        this_thread::sleep_for(chrono::seconds(1));

    drfl.close_connection();
#else
    cout << "[INFO] TOnMonitoringCtrlIOExCB requires DRCF_VERSION == 2" << endl;
#endif

    return 0;
}

참고

  • 이 콜백은 DRCF 버전 2를 사용하는 컨트롤러에서만 지원됩니다.

  • 고급 진단을 위해 아날로그 값과 상태 비트를 포함한 더 자세한 I/O 정보를 제공합니다.

  • 실시간 I/O 대시보드, 진단 도구, 공장 통합 시스템에 적합합니다.

  • 콜백은 호출될 때마다 가장 최근 데이터를 받습니다. 콜백 실행 시간이 데이터 주기(DRCF 3.5 이전 100 ms, DRCF 3.5부터 20 ms)보다 길면 그 사이의 샘플은 전달되지 않습니다. 모든 샘플을 받는다고 가정하지 마세요(예: 적분이나 미분).