11 EXAMPLES
11.1 CONTROL SERVER EXTENSION
The following example for a derived server is also contained in the test directory of the iracq module:
#error This is a C++ include file and cannot be used from plain C
#define myFRAME_TYPE (sdmaFRAME_USER << 1)
void PrintUsage(const char *);
ccsCOMPL_STAT ParseInputPars(int, char **);
void Verbose(const char *, ...);
// data transfer task event callback
void DataHandler(iracqDATA_EVT *);
ccsCOMPL_STAT SetParam(const char *, const char *, vltLOGICAL *);
ccsCOMPL_STAT GetParam(const char *, char *, vltINT32 *,vltLOGICAL *);
ccsCOMPL_STAT SeqHandler(const char *, vltINT32 *, vltINT32 *);
evhCB_COMPL_STAT MyCB(msgMESSAGE &msg, void *udata);
// just some dummy variables to be added to FITS-header
// Uncomment this if you are using the VLT environment
static char *rcsId="@(#) $Id: myServer.C,v 1.54+ 2000/12/20 16:43:03 vltsccm Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);
static int serverProcess(int argc, char *argv[])
* parse command line arguments
if (server.ParseInputPars(argc, argv) == FAILURE)
fprintf(stdout, "\nmyServer: initialization failed\n");
server.Verbose("\nmyServer: entering main loop and waiting for commands!\n");
exitStatus = evhHandler->MainLoop();
int main(int argc, char *argv[])
memset(procName, 0, sizeof(procName));
iracqRtapEnv(argc, argv, procName);
if (ccsInit(procName, 0, NULL, NULL, &error) == FAILURE)
exitStatus = serverProcess(argc, argv);
static char *rcsId="@(#) $Id: mySERVER.C,v 1.54+ 2000/12/20 16:43:04 vltsccm Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);
* initialize dummy value to be added to FITS-header
strcpy(dummyString_, "dummy");
* initialize parameter list for callback
memset (¶mList_, `\0', sizeof(cmdPARAM_LIST));
iracqVB ("\nmyServer: terminating...");
cmdParamFree(¶mList_, stdErr);
void mySRV::PrintUsage(const char *argv0)
* print out additional options
fprintf(stdout, "\nmyOptions:");
ccsCOMPL_STAT mySRV::ParseInputPars(int argc, char *argv[])
* pass arguments first to control server
retValOrig = iracqEVH::ParseInputPars(argc, argv);
* now parse arguments for additional options
* and decide, whether to return the original
if (iracqEVH::Init() != SUCCESS)
* some dummy FITS-header additions
if (AddFits("MY.INT", &dummyInt_, "My int") == FAILURE)
if (AddFits("MY.FLOAT", &dummyFloat_, "My float") == FAILURE)
if (AddFits("MY.DOUBLE", &dummyDouble_, "My double") == FAILURE)
if (AddFits("MY.STRING", dummyString_, "My string") == FAILURE)
if (AddFits("My comment") == FAILURE)
* trace some dynamic parameters (if existing in read-out mode)
if (AddFitsDynPar("DET.NC.MYPARAM1", "My dynamic parameter1") == FAILURE)
if (AddFitsDynPar("DET.NC.MYPARAM2", "My dynamic parameter2") == FAILURE)
if (AddFrame(myFRAME_TYPE, "MY-FRAME",
FALSE, FALSE, TRUE, "DET.NC.MYFRAME") == FAILURE)
ErrAdd(iracqMOD_ID, iracqERR_INIT, __FILE_LINE__,
* initialize additional database values
iracqVB("\nmyServer: instance is %s...", Instance());
iracqVB("\nmyServer: adding my callback...");
cb_.Proc((evhCB_METHOD2) &mySRV::MyCB);
if (evhHandler->AddCallback(key.Command("MYCMD"), cb_) == FAILURE)
ErrAdd(iracqMOD_ID, iracqERR_INIT, __FILE_LINE__,
"unable to add MYCMD callback");
void mySRV::Verbose(const char *str, ...)
* here you can add your own verbose handler
void mySRV::StateHandler(int state, int subState)
iracqEVH::StateHandler(state, subState);
* here you can add your own status handler
void mySRV::DataHandler(iracqDATA_EVT *evt)
* here you can add your own data event handler
void mySRV::ExitHandler(int sig)
* here you can add your own exit handler
iracqVB("\nmyServer: exiting...");
ccsCOMPL_STAT mySRV::SeqHandler(const char *seqFile,
ErrAdd(iracqMOD_ID, iracqERR_SYSTEM, __FILE_LINE__,
"format of sequencer program is not supported");
ccsCOMPL_STAT mySRV::SetParam(const char *name,
if (strcmp(name, "DET.MYSETUP") == 0)
fprintf(stdout, "\nmyServer: doing MYSETUP (value = %s)...",
sprintf(tmpStr, "-myArg %s", value);
if (AcqParam(tmpStr) == FAILURE)
fprintf(stdout, "\nmyServer: MYSETUP done...");
* leave `handled' set to FALSE to apply the value also
* in sequence file or acq-process (if applicable)
else if (strcmp(name, "DET.MYVAL") == 0)
fprintf(stdout, "\nmyServer: MYVAL = %s...",
ccsCOMPL_STAT mySRV::GetParam(const char *name,
if (strcmp(name, "DET.MYVAL") == 0)
sprintf(value, "%d", dummyInt_);
evhCB_COMPL_STAT mySRV::MyCB(msgMESSAGE &msg, void *)
fprintf(stdout, "\nmyServer: handling MYCMD (buffer is <%s>)...",
if (cmdParamList("MYCMD", msg.Buffer(), msg.Buflen(), ¶mList_,
if (cmdParamGetByName(¶mList_, "myParam", ¶mNb, ¶mType,
¶mValues, stdErr) == FAILURE)
stringVal = (char **)paramValues;
fprintf(stdout, "\nmyServer: myParam = ");
fprintf(stdout, "<%s> ", stringVal[i]);
11.2 DATA TRANSFER TASK EXTENSION
The following example for a derived data transfer task is also contained in the test directory of the iracq module:
#error This is a C++ include file and cannot be used from plain C
class myDTT: public iracqDTT_EVH
virtual ~myDTT(); // destructor
evhCB_COMPL_STAT MyCB(msgMESSAGE &msg, void *udata);
// application specific frame processing
int ProcessFrame(sdmaFRAME_T *, char *);
// just some dummy variables to be added to FITS-header
static char *rcsId="@(#) $Id: myDtt.C,v 1.12+ 1999/12/14 11:42:19 vltsccm Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);
static int server(int argc, char *argv[])
* parse command line arguments
if (server.ParseInputPars(argc, argv) == FAILURE)
fprintf(stderr, "\nmyDtt: initialization failed\n");
iracqVB("\nmyDtt: entering the main loop and waiting for commands!");
exitStatus = evhHandler->MainLoop();
int main(int argc, char *argv[])
iracqRtapEnv(argc, argv, procName);
if (ccsInit(procName, 0, NULL, NULL, &error) == FAILURE)
exitStatus = server(argc, argv);
static char *rcsId="@(#) $Id: myDTT.C,v 1.54+ 2000/12/20 16:43:04 vltsccm Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);
* initialize dummy value to be added to FITS-header
strcpy(dummyString_, "dtt dummy");
* initialize parameter list for callback
memset (¶mList_, `\0', sizeof(cmdPARAM_LIST));
iracqVB ("\nmyDtt: terminating...");
cmdParamFree(¶mList_, stdErr);
if (iracqDTT_EVH::Init() != SUCCESS)
iracqVB("\nmyDtt: adding my callback...");
cb_.Proc((evhCB_METHOD2) &myDTT::MyCB);
if (evhHandler->AddCallback(key.Command("MYCMD"), cb_) == FAILURE)
ErrAdd(iracqMOD_ID, iracqERR_INIT, __FILE_LINE__,
"unable to add MYCMD callback");
* some dummy FITS-header additions
if (AddFits("MYDTT.INT", &dummyInt_, "My int") == FAILURE)
if (AddFits("MYDTT.FLOAT", &dummyFloat_, "My float") == FAILURE)
if (AddFits("MYDTT.DOUBLE", &dummyDouble_, "My double") == FAILURE)
if (AddFits("MYDTT.STRING", dummyString_, "My dtt string") == FAILURE)
if (AddFits("My dtt comment") == FAILURE)
evhCB_COMPL_STAT myDTT::MyCB(msgMESSAGE &msg, void *)
fprintf(stdout, "\nmyDtt: handling MYCMD (buffer is <%s>)...",
if (cmdParamList("MYCMD", msg.Buffer(), msg.Buflen(), ¶mList_,
if (cmdParamGetByName(¶mList_, "myParam", ¶mNb, ¶mType,
¶mValues, stdErr) == FAILURE)
stringVal = (char **)paramValues;
fprintf(stdout, "\nmyDtt: myParam = ");
fprintf(stdout, "<%s> ", stringVal[i]);
int myDTT::ProcessFrame(sdmaFRAME_T *frame, char *erms)
printf("\nmyDTT: processing frame...");
Quadralay Corporation http://www.webworks.com Voice: (512) 719-3399 Fax: (512) 719-3606 sales@webworks.com |