TOnMonitoringCtrlIOEx2CB
DRCF 버전 3용 최신 확장 컨트롤러 I/O 모니터링 콜백입니다. TOnMonitoringCtrlIOCB, TOnMonitoringCtrlIOExCB와 달리 v3 형식의 I/O 데이터(MONITORING_CTRLIO_EX2)를 전달하며, 새 모니터링 형식을 활성화한 뒤에만 호출됩니다.
콜백 함수 규칙을 참고하세요.
정의 위치: DRFLEx.h
// typedef 정의(DRFLEx.h)
typedef void (*TOnMonitoringCtrlIOEx2CB)(const LPMONITORING_CTRLIO_EX2);
// 등록 API(내부 + 래퍼)
DRFL_API void _set_on_monitoring_ctrl_io_ex2(LPROBOTCONTROL pCtrl, TOnMonitoringCtrlIOEx2CB pCallbackFunc);
#elif DRCF_VERSION == 3
/* 최신 버전. setup_monitoring_version(1) 이후 호출되는 콜백 함수 */
void set_on_monitoring_ctrl_io_ex(TOnMonitoringCtrlIOEx2CB pCallbackFunc)
{
_set_on_monitoring_ctrl_io_ex2(_rbtCtrl, pCallbackFunc);
};
매개변수
매개변수 이름 |
자료형 |
기본값 |
설명 |
|---|---|---|---|
pCtrlIOEx2 |
v3 확장 I/O 구조체(디지털/아날로그 I/O와 v3 메타데이터)의 포인터입니다. |
반환값
없음
예제
#include "DRFLEx.h"
#include <iostream>
#include <thread>
#include <chrono>
using namespace DRAFramework;
// EX2 I/O 모니터링 콜백 함수(DRCF v3)
void OnMonitoringCtrlIOEx2CB(const LPMONITORING_CTRLIO_EX2 pEx2)
{
// 예시로 처음 몇 개의 디지털 입력/출력 출력
std::cout << "[I/O EX2] DI0..3: "
<< (int)pEx2->_tInput._iActualDI[0] << ", "
<< (int)pEx2->_tInput._iActualDI[1] << ", "
<< (int)pEx2->_tInput._iActualDI[2] << ", "
<< (int)pEx2->_tInput._iActualDI[3] << std::endl;
std::cout << "[I/O EX2] DO0..3: "
<< (int)pEx2->_tOutput._iTargetDO[0] << ", "
<< (int)pEx2->_tOutput._iTargetDO[1] << ", "
<< (int)pEx2->_tOutput._iTargetDO[2] << ", "
<< (int)pEx2->_tOutput._iTargetDO[3] << std::endl;
}
int main()
{
#if DRCF_VERSION == 3
CDRFLEx drfl;
if (!drfl.open_connection("192.168.137.100")) {
std::cout << "Failed to connect.\n";
return -1;
}
// v3 모니터링 데이터 활성화. 이후 EX2 콜백 함수가 호출됩니다
drfl.setup_monitoring_version(1);
// EX2 콜백 함수 등록
drfl.set_on_monitoring_ctrl_io_ex(OnMonitoringCtrlIOEx2CB);
// 실행 유지 루프
while (true) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
drfl.close_connection();
#else
std::cout << "TOnMonitoringCtrlIOEx2CB requires DRCF_VERSION == 3.\n";
#endif
return 0;
}
참고
더 풍부한 I/O 텔레메트리가 필요한 v3 컨트롤러를 대상으로 할 때 사용하세요.
호환 범위를 넓히려면 TOnMonitoringCtrlIOExCB(v2)나 TOnMonitoringCtrlIOCB(레거시)로 대체하는 경로를 마련하세요.
콜백은 호출될 때마다 가장 최근 데이터를 받습니다. 콜백 실행 시간이 데이터 주기(DRCF 3.5 이전 100 ms, DRCF 3.5부터 20 ms)보다 길면 그 사이의 샘플은 전달되지 않습니다. 모든 샘플을 받는다고 가정하지 마세요(예: 적분이나 미분).