.. _set_on_tp_popup: set_on_tp_popup ------------------------------------------ This function is used to register a callback function to check the popup message when the ``tp_popup`` command is used in DRL. Use it to run your own code automatically when this event occurs. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp void set_on_tp_popup(TOnTpPopupCB pCallbackFunc) { _set_on_tp_popup(_rbtCtrl, pCallbackFunc); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - pCallbackFunc - :ref:`TOnTpPopupCB ` - - - Refer to definition of callback function **Return** |br| None .. note:: See :ref:`Rules for callback functions `. **Example** .. code-block:: cpp // Callback function to handle popup events from TP void OnTpPopup(LPMESSAGE_POPUP tPopup) { printf("-------------------------------------------\n"); printf("[TP POPUP DETECTED]\n"); printf("Popup Message : %s\n", tPopup->_szText); printf("Message Level : %d\n", tPopup->_iLevel); printf("Button Type : %d\n", tPopup->_iBtnType); printf("-------------------------------------------\n"); // Example: handle based on popup message or level if (strcmp(tPopup->_szText, "Confirm Start?") == 0) { printf("[Host] Sending RESUME response to controller...\n"); drfl.tp_popup_response(POPUP_RESPONSE_RESUME); } else if (tPopup->_iLevel == MESSAGE_LEVEL_ALARM) // Alarm level popup { printf("[Host] Alarm received from TP. Logging event...\n"); // Log or take action (e.g., slow down motion) } else { printf("[Host] Display only popup - no action required.\n"); } } // Register the popup callback drfl.set_on_tp_popup(OnTpPopup); // Main program logic printf("Waiting for popup events from Teach Pendant...\n"); while (true) { // Maintain connection and check callbacks this_thread::sleep_for(chrono::seconds(1)); } When registered, this callback function executes automatically when a **popup message is triggered on the Teach Pendant (TP)** through DRL. It allows the user to **check popup content, message level, and button type**, and optionally **send a response back to the controller** (``POPUP_RESPONSE_RESUME`` or ``POPUP_RESPONSE_STOP``). This enables dynamic handling of TP-side prompts such as confirmations, warnings, or notifications during robot operation.