The remote interface provides additional support for controlling the interaction of the Tcl and ECLiPSe sides, such as explicit transfer of control between ECLiPSe and Tcl, and the disconnection of the Tcl and ECLiPSe sides. The interface also provides support for special user-defined commands to be executed during these events.
In an application, after the Tcl side has been attached, typically some application specific initialisation needs to be performed, such as setting up various data queues between the two sides, and defining the actions to take when the two sides are disconnected. On both sides, these initialisations can be performed immediately after attachment. On the Tcl side, such actions can be specified in the optional init_command argument of ec_remote_init. On the ECLiPSe side, such actions can be specified in the ‘InitGoal’ (last) argument of remote_connect/3. InitGoal can be a built-in, or a user-defined goal.
Disconnection should normally be performed when the ECLiPSe application has finished using the GUI provided by the particular attached remote process. The disconnection may be initiated from either side. In addition to cleaning up and closing all the remote queues connecting the two sides, the disconnection would trigger the execution of user definable procedures on both sides (through an event on the ECLiPSe side, and a call-back on the Tcl side), which can be used to perform extra application specific cleanup and shutdown routines.
For the transfer of control from Tcl to ECLiPSe and vice versa, user-definable call-backs are made. This is to enable to define application specific restrictions on what the GUI is allowed to do when the ECLiPSe side has the control (for example, the GUI may have a button that sends an rpc goal to ECLiPSe when pressed. Such a button could be disabled by the call-back when control is transferred to ECLiPSe and reenabled when control is transferred back to Tcl).
Note that there are two types of transfer of control from ECLiPSe to Tcl: 1) when the control is implicitly yielded (e.g. initiating I/O from ECLiPSe with Tcl, or returning after an rpc call); 2) when the control is handed over by yielding explicitly (e.g. by calling remote_yield/1 in ECLiPSe). With implicit yield, the Tcl side is expected to eventually handed back control implicitly to ECLiPSe, and not to explicitly hand control over to ECLiPSe before this. Thus two call-backs are provided when control is yield to Tcl: one is executed whenever the control is yielded, and the other is only executed when the control is explicitly yielded. Thus when control is explicitly yielded, both call-backs are executed. This can be useful for example by defining the explicit yield call-back to enable a button on the Tcl side that will explicitly transfer control back to ECLiPSe when pressed, which should only be enabled when ECLiPSe explicitly yielded to Tcl.
On the ECLiPSe side, an event is raised when the two sides disconnect. The event’s name is the control stream’s name. The user can define a handler for this event to allow user-defined action to take place on the ECLiPSe side on disconnection. The simplest way to define this handler is to do it during the connection, via the last argument of remote_connect/3.
The default for each command is that no command will be called.
Note that if the ECLiPSe process is halted normally, then ECLiPSe will try to disconnect from every remote side it may be connected to.