![]() | ![]() | ![]() | Adding commands | ![]() |
Readout supports extending the command interpreter. This allows you to integrate application specific commands into the Readout program. To add a command extension you must:
Deriving a class from CDAQTCLProcessor requires that you implement a constructor, that defines the command keyword, and an operator() that executes the command when the interpreter decodes it. The call sequence for operator() is:
virtual int operator()(CTCLInterpreter& rInterp, CTCLResult& rResult, int argc, char** argv)
Where:
The code below implements a command class that echoes its input parameters (including the command keyword itself) to the result string:
class Echo : public DAQTCLCommand { public: Echo(const char* keyword, CTCLInterpreter& rInterp) : DAQTCLCommand(char* keyword, CTCLInterpreter& rInterp) {} virtual int operator()(CTCLInterpreter& rInterp, CTCLResult& rResult, int argc, char** argv) { while(argc) { rResult.AppendElement(*argv); argv++; argc--; } return TCL_OK; } };
Once the command has been created, it must be registered on the interpreter that runs in the readout program. This is done by adding code to AddUserCommands. Note that this function will be called in the context of the interpreter's execution thread.
The sample code below registers the command "Echo" to execute as defined in the Echo object.
void CMyReadout::AddUserCommands(CExperiment& rExperiment, CInterpreterStartup& rStartup, CInterpreterCore& rCore) { CTCLInterpreter* pInterp = rStartup.getInterpreter(); Echo* pCommand = new Echo("Echo", *pInterp); pCommand->Register(); }
![]() | ![]() | ![]() | Adding commands | ![]() |