.. _cb_tontpinitializingcompletedcb: TOnTpInitializingCompletedCB ------------------------------------------ This callback function is used to check whether **initialization has been completed** when the robot controller is initialized by the **Teach Pendant (T/P)** application after the controller boots. See :ref:`Rules for callback functions `. **Defined in:** ``DRFLEx.h`` .. code-block:: cpp // typedef (DRFL.h) typedef void (*TOnTpInitializingCompletedCB)(); // registration API (internal + wrapper) DRFL_API void _set_on_tp_initializing_completed(LPROBOTCONTROL pCtrl, TOnTpInitializingCompletedCB pCallbackFunc); void set_on_tp_initializing_completed(TOnTpInitializingCompletedCB pCallbackFunc) { _set_on_tp_initializing_completed(_rbtCtrl, pCallbackFunc); }; **Parameter** |br| None **Return** |br| None **Example** .. code-block:: cpp #include "DRFLEx.h" #include #include #include #include using namespace DRAFramework; using namespace std; CDRFLEx drfl; std::atomic g_bTpInitCompleted(false); // Callback function triggered when TP initialization is completed void OnTpInitializingCompletedCB() { // Request control authority from the main loop g_bTpInitCompleted = true; } int main() { // Register TP initialization completion callback before connecting drfl.set_on_tp_initializing_completed(OnTpInitializingCompletedCB); // Connect to the controller if (!drfl.open_connection("192.168.137.100")) { cout << "Failed to connect to controller." << endl; return -1; } // Main loop: call manage_access_control outside the callback while (true) { if (g_bTpInitCompleted) { g_bTpInitCompleted = false; cout << "[TP INIT] Teach Pendant initialization completed." << endl; drfl.manage_access_control(MANAGE_ACCESS_CONTROL_REQUEST); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } drfl.close_connection(); return 0; } **Notes** - The callback is called once, the first time a robot state other than STATE_NOT_READY or STATE_INITIALIZING is received after registration, and is then unregistered. The controller reports the robot state when the connection is opened and whenever it changes. Register this callback before open_connection: if the controller is already initialized it is then called during connection. A callback registered after connecting to an idle controller is called at the next state change. Register it again after every open_connection. - Common usage includes **requesting control authority** (`MANAGE_ACCESS_CONTROL_REQUEST`) or performing application startup routines.