-static char rcsId[] = "$Id: daq_lib.c,v 6.2 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Id: daq_lib.c,v 6.3 2000-11-08 07:53:22 hades Exp $";
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <lvme.h>
-#include <p.h>
+#include <allParam.h>
#include "worker.h"
#include "daq_lib.h"
-typedef struct OurParamsS {
- char file[PARAM_MAX_VALUE_LEN];
- char args[PARAM_MAX_VALUE_LEN];
-} OurParams;
-
-static OurParams *getParams(const char *n, const Param *p) {
- static OurParams *pa = NULL;
-
- if (pa == NULL) {
- int i;
-
- pa = malloc(sizeof(OurParams));
-
- if (pa == NULL
- || -1 == Param_getString(p, n, "file", &i, pa->file) || i == 0
- || -1 == Param_getString(p, n, "args", &i, pa->args) || i == 0
- ) {
- free(pa);
- pa = NULL;
- }
- }
-
- return pa;
-}
-
int Daq_reset(const char *n, const Param *p)
{
Daq_stop(n, p);
int Daq_start(const char *n, const Param *p)
{
- char *argv[512];
int i;
- char *s;
- OurParams *pa;
+ char file[PARAM_MAX_VALUE_LEN];
- pa = getParams(n, p);
+ Param_getString(p, n, "file", &i, file);
- i = 0;
- s = malloc(strlen(pa->args) + 1);
- strcpy(s, pa->args);
- while((argv[i++] = strtok(s, " \t\n")) != NULL) {
- s = NULL;
- }
- free(s);
- return Worker_start(pa->file, argv);
+ return Worker_start(file, &n);
}
int Daq_stop(const char *n, const Param *p)
{
- char *s;
- OurParams *pa;
-
- pa = getParams(n, p);
- s = malloc(strlen(pa->args) + 1);
- strcpy(s, pa->args);
- strtok(s, " \t\n");
- Worker_stop(s, 15);
- free(s);
+ Worker_stop(n, 15);
return 0;
}
int Daq_status(const char *n, const Param *p)
{
- char *s;
- OurParams *pa;
-
- pa = getParams(n, p);
- s = malloc(strlen(pa->args) + 1);
- strcpy(s, pa->args);
- strtok(s, " \t\n");
- puts(Worker_status(s));
- free(s);
+ puts(Worker_status(n));
return 0;
}
#ifndef Daq_LIB_H
#define Daq_LIB_H
-#include <param.h>
+#include <allParam.h>
int Daq_init(const char *name, const Param *param);
int Daq_reset(const char *name, const Param *param);
-static char rcsId[] = "$Id: daqctrl.c,v 6.2 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Id: daqctrl.c,v 6.3 2000-11-08 07:53:22 hades Exp $";
#include <stdlib.h>
#include <stddef.h>
#include <strings.h>
#include <signal.h>
-#include <param.h>
+#include <allParam.h>
#include "daq_lib.h"
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.18 2000-10-10 10:33:38 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.19 2000-11-08 07:53:22 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <time.h>
#include <hadesstd.h>
+#include <allParam.h>
#include "worker.h"
#include "evt.h"
#include "shmtrans.h"
#include "ansiTape.h"
+typedef struct TheArgsS {
+ unsigned long nrOfMsgs;
+ char outPath[PARAM_MAX_VALUE_LEN];
+ char outDev[PARAM_MAX_VALUE_LEN];
+ unsigned long runNr;
+ char expId[PARAM_MAX_VALUE_LEN];
+ char *slowCtrlFiles[PARAM_MAX_ARRAY_LEN];
+ char slowCtrlFilesS[PARAM_MAX_ARRAY_LEN][PARAM_MAX_NAME_LEN];
+ int slowCtrlFileCnt;
+ unsigned long isStandalone;
+ unsigned long priority;
+ unsigned long queueSize;
+ char verbosity[PARAM_MAX_VALUE_LEN];
+} TheArgs;
+
static jmp_buf terminateJmp;
void sigHandler(int sig)
msglog_usage();
}
-/* BUGBUG bailOut not proper yet */
-int main(int argc, char *argv[])
-{
+static void argsDefault(TheArgs *my) {
int i;
- ShmTrans **shmTrans;
- HadTuQueue **hadTuQueue;
- Worker *worker;
- int isStandalone;
- int nrOfMsgs;
- void *evt;
- char outPath[_POSIX_PATH_MAX] = "";
- char fileName[_POSIX_PATH_MAX];
- char *outDev;
- int priority;
- FILE *outFile;
- AnsiTape *outTape;
- void *subEvt;
- UInt4 nrOfSubEvts;
- time_t t;
- UInt4 runNr;
- char expId[3] = "xx";
- char **slowCtrlFiles;
- int slowCtrlFileCnt;
- size_t queueSize;
-
- int scanWasSuccessful;
- int currNrOfSubEvts;
- UInt4 currTrigNr;
- unsigned long *evtsDiscarded;
- unsigned long *evtsComplete;
- unsigned long *bytesWritten;
-
- t = time(NULL);
+ my->nrOfMsgs = 0;
+ for (i = 0; i < PARAM_MAX_ARRAY_LEN; i++) {
+ my->slowCtrlFiles[i] = my->slowCtrlFilesS[i];
+ }
+ my->slowCtrlFileCnt = 0;
+ strcpy(my->outPath, "");
+ strcpy(my->outDev, "null");
+ my->runNr = time(NULL);
+ strcpy(my->expId, "xx");
+ my->priority = 0;
+ my->isStandalone = 1;
+ my->queueSize = 1 * 1024 * 1024;
+ strcpy(my->verbosity, "info");
+}
- msglog_setlevel(argv[0], "info");
- isStandalone = 1;
- nrOfMsgs = 0;
- slowCtrlFiles = NULL;
- slowCtrlFileCnt = 0;
- outDev = "null";
- priority = 0;
- runNr = t;
- queueSize = 1 * 1024 * 1024;
+static int argsFromCL(TheArgs *my, int argc, char *argv[]) {
+ int i;
while ((i = getopt(argc, argv, "am:f:s:r:o:d:p:v:x:")) != -1) {
switch (i) {
- case 'a':
- isStandalone = 0;
- break;
case 'm':
- nrOfMsgs = atoi(optarg);
+ my->nrOfMsgs = atoi(optarg);
break;
case 'f':
- slowCtrlFiles = realloc(slowCtrlFiles, sizeof(char *) * (slowCtrlFileCnt + 1));
-
- slowCtrlFiles[slowCtrlFileCnt++] = optarg;
+ strcpy(my->slowCtrlFiles[my->slowCtrlFileCnt++], optarg);
break;
case 'r':
- runNr = atoi(optarg);
+ my->runNr = atoi(optarg);
break;
case 's':
msglog(LOG_WARNING,
"-s option obsolete, will be removed in a future version\n");
break;
case 'o':
- strcpy(outPath, optarg);
+ strcpy(my->outPath, optarg);
break;
case 'd':
- outDev = optarg;
+ strcpy(my->outDev, optarg);
+ break;
+ case 'x':
+ strcpy(my->expId, optarg);
+ break;
+ case 'a':
+ my->isStandalone = 0;
break;
case 'p':
- priority = atoi(optarg);
+ my->priority = atoi(optarg);
break;
- case 'v':
- if (msglog_setlevel(argv[0], optarg) != 1) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
+ case 'q':
+ my->queueSize = atoi(optarg);
break;
- case 'x':
- expId[0] = tolower(optarg[0]);
- expId[1] = tolower(optarg[1]);
- expId[2] = '\0';
+ case 'v':
+ strcpy(my->verbosity, optarg);
break;
default:
- usage(argv[0]);
- exit(EXIT_FAILURE);
+ return -1;
break;
}
}
+ return 0;
+}
+
+static int argsFromParam(TheArgs *my, int argc, char *argv[]) {
+ Param paramS, *param = ¶mS;
+ int paramWasFound;
+
+ conParam(param);
+ Param_getInt(param, argv[0], "nrofmsgs", ¶mWasFound, &my->nrOfMsgs);
+ Param_getStringArray(param, argv[0], "slwctrlfile",
+ PARAM_MAX_ARRAY_LEN, &my->slowCtrlFileCnt, my->slowCtrlFiles);
+ Param_getString(param, argv[0], "outpath", ¶mWasFound, my->outPath);
+ Param_getString(param, argv[0], "outdev", ¶mWasFound, my->outDev);
+ Param_getInt(param, argv[0], "runnr", ¶mWasFound, &my->runNr);
+ Param_getString(param, argv[0], "expid", ¶mWasFound, my->expId);
+ Param_getInt(param, argv[0], "stndln", ¶mWasFound, &my->isStandalone);
+ Param_getInt(param, argv[0], "prio", ¶mWasFound, &my->priority);
+ Param_getInt(param, argv[0], "qsize", ¶mWasFound, &my->queueSize);
+ Param_getString(param, argv[0], "verb", ¶mWasFound, my->verbosity);
+ desParam(param);
+}
+
+/* BUGBUG bailOut not proper yet */
+int main(int argc, char *argv[])
+{
+ int i;
+ TheArgs theArgsS, *theArgs = &theArgsS;
+ ShmTrans **shmTrans;
+ HadTuQueue **hadTuQueue;
+ Worker *worker;
+ char fileName[_POSIX_PATH_MAX];
+ FILE *outFile;
+ AnsiTape *outTape;
+ unsigned long nrOfSubEvts;
+ void *evt;
+ void *subEvt;
+
+ int scanWasSuccessful;
+ int currNrOfSubEvts;
+ UInt4 currTrigNr;
+
+ unsigned long *evtsDiscarded;
+ unsigned long *evtsComplete;
+ unsigned long *bytesWritten;
+
+ argsDefault(theArgs);
+ argsFromParam(theArgs, argc, argv);
+ if (0 > argsFromCL(theArgs, argc, argv)) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (msglog_setlevel(argv[0], theArgs->verbosity) != 1) {
+ msglog_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ /* normalize experiment id */
+ theArgs->expId[0] = tolower(theArgs->expId[0]);
+ theArgs->expId[1] = tolower(theArgs->expId[1]);
+ theArgs->expId[2] = '\0';
/* construct a default filename */
- strcpy(fileName, expId);
- strftime(fileName + strlen(fileName), 18, "%y%j%H%M%S.hld", localtime(&t));
+ strcpy(fileName, theArgs->expId);
+ strftime(fileName + strlen(fileName), 18, "%y%j%H%M%S.hld", localtime(&theArgs->runNr));
/* construct the output path */
- if (strcmp(outPath, "") == 0) {
- strcpy(outPath, fileName);
+ if (strcmp(theArgs->outPath, "") == 0) {
+ strcpy(theArgs->outPath, fileName);
} else {
struct stat bufS, *buf = &bufS;
- stat(outPath, buf);
+ stat(theArgs->outPath, buf);
if (S_ISDIR(buf->st_mode)) {
- strcat(outPath, "/");
- strcat(outPath, fileName);
+ strcat(theArgs->outPath, "/");
+ strcat(theArgs->outPath, fileName);
}
}
- if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, priority, isStandalone))) {
+ if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
- if (strcmp(outDev, "null") == 0) {
+
+ if (strcmp(theArgs->outDev, "null") == 0) {
outFile = NULL;
- } else if (strcmp(outDev, "stdout") == 0) {
+ } else if (strcmp(theArgs->outDev, "stdout") == 0) {
outFile = stdout;
- } else if (strcmp(outDev, "file") == 0) {
- if (NULL == (outFile = fopen(outPath, "wb"))) {
+ } else if (strcmp(theArgs->outDev, "file") == 0) {
+ if (NULL == (outFile = fopen(theArgs->outPath, "wb"))) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
- } else if (strcmp(outDev, "tape") == 0) {
- if (NULL == (outTape = openAnsiTape(outPath))) {
+ } else if (strcmp(theArgs->outDev, "tape") == 0) {
+ if (NULL == (outTape = openAnsiTape(theArgs->outPath))) {
msglog(LOG_NOTICE, "Opening of tape failed (no tape available?): Writing to /dev/null.\n");
- outDev = "null";
+ strcpy(theArgs->outDev, "null");
outFile = NULL;
}
} else {
- msglog(LOG_ERR, "unknown outputDev \"%s\"\n", outDev);
+ msglog(LOG_ERR, "unknown outputDev \"%s\"\n", theArgs->outDev);
usage(argv[0]);
exit(EXIT_FAILURE);
}
msglog(LOG_ERR, "unable to initialize online service\n");
exit(EXIT_FAILURE);
}
- if (nrOfMsgs == 0) {
+ if (theArgs->nrOfMsgs == 0) {
/*
no '-m' option was on command line, we assume that the
readout task (daq_readout) is running on the same node and
shmTrans = allocMem(sizeof(ShmTrans *));
hadTuQueue = allocMem(sizeof(HadTuQueue *));
- shmTrans[0] = ShmTrans_create("subevtqueue", 2 * queueSize);
+ shmTrans[0] = ShmTrans_create("subevtqueue", 2 * theArgs->queueSize);
hadTuQueue[0] = NULL;
- nrOfMsgs = 1;
+ theArgs->nrOfMsgs = 1;
} else {
- shmTrans = allocMem(nrOfMsgs * sizeof(ShmTrans *));
- hadTuQueue = allocMem(nrOfMsgs * sizeof(HadTuQueue *));
+ shmTrans = allocMem(theArgs->nrOfMsgs * sizeof(ShmTrans *));
+ hadTuQueue = allocMem(theArgs->nrOfMsgs * sizeof(HadTuQueue *));
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
char buf[_POSIX_PATH_MAX];
sprintf(buf, "netqueue%d", i);
- shmTrans[i] = ShmTrans_create(buf, 2 * queueSize);
+ shmTrans[i] = ShmTrans_create(buf, 2 * theArgs->queueSize);
hadTuQueue[i] = NULL;
}
}
bytesWritten = Worker_addStatistic(worker, "bytesWritten");
Worker_initEnd(worker);
- evt = newEvt(EvtDecoding_64bitAligned, EvtId_runStart, runNr, expId);
- for (i = 0; i < slowCtrlFileCnt; i++) {
- evt = appendFile(evt, slowCtrlFiles[i]);
+ evt = newEvt(EvtDecoding_64bitAligned, EvtId_runStart, theArgs->runNr, theArgs->expId);
+ for (i = 0; i < theArgs->slowCtrlFileCnt; i++) {
+ evt = appendFile(evt, theArgs->slowCtrlFiles[i]);
}
if (outFile != NULL) {
- if (strcmp(outDev, "file") == 0) {
+ if (strcmp(theArgs->outDev, "file") == 0) {
fwrite(evt, 1, Evt_paddedSize(evt), outFile);
- } else if (strcmp(outDev, "tape") == 0) {
+ } else if (strcmp(theArgs->outDev, "tape") == 0) {
writeAnsiTape(outTape, evt, Evt_paddedSize(evt));
}
}
deleteEvt(evt);
- nrOfSubEvts = nrOfMsgs;
+ nrOfSubEvts = theArgs->nrOfMsgs;
currTrigNr = 0xffffffff;
while (setjmp(terminateJmp) == 0) {
int tryNext;
i = 0;
tryNext = 0;
- evt = newEvt(EvtDecoding_64bitAligned, EvtId_data, runNr, expId);
+ evt = newEvt(EvtDecoding_64bitAligned, EvtId_data, theArgs->runNr, theArgs->expId);
currNrOfSubEvts = 0;
- while (i < nrOfMsgs) {
+ while (i < theArgs->nrOfMsgs) {
if (hadTuQueue[i] == NULL) {
void *storage;
}
if (currNrOfSubEvts == nrOfSubEvts) {
if (outFile != NULL) {
- if (strcmp(outDev, "file") == 0) {
+ if (strcmp(theArgs->outDev, "file") == 0) {
fwrite(evt, 1, Evt_paddedSize(evt), outFile);
- } else if (strcmp(outDev, "tape") == 0) {
+ } else if (strcmp(theArgs->outDev, "tape") == 0) {
writeAnsiTape(outTape, evt, Evt_paddedSize(evt));
}
}
}
Worker_dump(worker, 0);
- evt = newEvt(EvtDecoding_64bitAligned, EvtId_runStop, runNr, expId);
- for (i = 0; i < slowCtrlFileCnt; i++) {
- evt = appendFile(evt, slowCtrlFiles[i]);
+ evt = newEvt(EvtDecoding_64bitAligned, EvtId_runStop, theArgs->runNr, theArgs->expId);
+ for (i = 0; i < theArgs->slowCtrlFileCnt; i++) {
+ evt = appendFile(evt, theArgs->slowCtrlFiles[i]);
}
if (outFile != NULL) {
- if (strcmp(outDev, "file") == 0) {
+ if (strcmp(theArgs->outDev, "file") == 0) {
fwrite(evt, 1, Evt_paddedSize(evt), outFile);
- } else if (strcmp(outDev, "tape") == 0) {
+ } else if (strcmp(theArgs->outDev, "tape") == 0) {
writeAnsiTape(outTape, evt, Evt_paddedSize(evt));
}
}
deleteEvt(evt);
- free(slowCtrlFiles);
-
if (outFile != NULL) {
- if (strcmp(outDev, "tape") == 0) {
+ if (strcmp(theArgs->outDev, "tape") == 0) {
if (-1 == closeAnsiTape(outTape)) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
msglog(LOG_NOTICE, "%s, line %d:\n", __FILE__, __LINE__, strerror(errno));
}
}
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
ShmTrans_remove(shmTrans[i]);
}
Worker_fini(worker);
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwdtu.c,v 1.4 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwdtu.c,v 1.5 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include "subevt.h"
-#include <param.h>
+#include <allParam.h>
#include "hwdtu.h"
int conHwDtu(HwDtu *my, const char *name, const Param *param)
#include <lvme.h>
#include "rc.h"
-#include <param.h>
+#include <allParam.h>
typedef struct HwDtuS {
char name[16];
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwmdc.c,v 6.5 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwmdc.c,v 6.6 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "hwsam.h"
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrace.c,v 6.8 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrace.c,v 6.9 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include "subevt.h"
-#include <param.h>
+#include <allParam.h>
#include "rc.h"
#include "hwrace.h"
#include <lvme.h>
#include "rc.h"
-#include <param.h>
+#include <allParam.h>
typedef struct HwRaceS {
char name[16];
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.9 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.10 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include "dtu_defs.h"
#endif
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "hwrace.h"
#include <hadesstd.h>
#include <lvme.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "sam_defs.h"
#include <lvme.h>
-#include <param.h>
+#include <allParam.h>
typedef struct HwSamS {
char name[16];
#include <hadesstd.h>
#include <lvme.h>
-#include <param.h>
+#include <allParam.h>
#include "ipc_basis.h"
#include "hwship.h"
#include <lvme.h>
-#include <param.h>
+#include <allParam.h>
typedef struct HwShipS {
char name[16];
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.8 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.9 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "hwship.h"
#include <sys/time.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtbus.c,v 1.4 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtbus.c,v 1.5 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "hwdtu.h"
#if 1
#include "subevt.h"
#endif
-#include <param.h>
+#include <allParam.h>
#include "tof_defs.h"
#include "hwtip.h"
#include <lvme.h>
-#include <param.h>
+#include <allParam.h>
typedef struct HwTipS {
char name[16];
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtof.c,v 1.13 2000-09-21 09:28:47 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtof.c,v 1.14 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
-#include <param.h>
+#include <allParam.h>
#include "subevt.h"
#include "hwtip.h"
#include <lvme.h>
#include "subevt.h"
-#include <param.h>
+#include <allParam.h>
#define MU_EVT_COUNT 0x0e8014UL
#define MU_FIFO 0x0000UL
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/memnet.c,v 6.3 2000-05-30 07:31:45 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/memnet.c,v 6.4 2000-11-08 07:53:23 hades Exp $";
#define _XOPEN_SOURCE
#include <unistd.h>
#include <strings.h>
#include <hadesstd.h>
+#include <allParam.h>
#include "shmtrans.h"
#include "nettrans.h"
#include "worker.h"
+typedef struct TheArgsS {
+ char outPath[PARAM_MAX_VALUE_LEN];
+ unsigned long bandWidth;
+ unsigned long isStandalone;
+ unsigned long priority;
+ unsigned long queueSize;
+ char verbosity[PARAM_MAX_VALUE_LEN];
+} TheArgs;
+
static jmp_buf terminateJmp;
void sigHandler(int sig)
static void usage(const char *progName)
{
- msglog(LOG_ERR, "Usage: %s -o outPath -w bandwidth\n", progName);
- msglog(LOG_ERR, "Usage: [-p priority]\n");
+ msglog(LOG_ERR, "Usage: %s [-a (agentCtrl)] -o outPath\n", progName);
+ msglog(LOG_ERR, "Usage: [-w bandwidth] [-p priority]\n");
msglog_usage();
}
-int main(int argc, char *argv[])
-{
+static void argsDefault(TheArgs *my) {
+ strcpy(my->outPath, "");
+ my->bandWidth = 0;
+ my->priority = 0;
+ my->isStandalone = 1;
+ my->queueSize = 1 * 1024 * 1024;
+ strcpy(my->verbosity, "info");
+}
+
+static int argsFromCL(TheArgs *my, int argc, char *argv[]) {
int i;
- int priority;
- char *outPath;
- int bandWidth;
- int isStandalone;
- Worker *worker;
- NetTrans *netTrans;
- ShmTrans *shmTrans;
- size_t queueSize = 1 * 1024 * 1024;
- int exitStat;
- msglog_setlevel(argv[0], "info");
- outPath = "-";
- bandWidth = -1;
- priority = 0;
- isStandalone = 1;
while ((i = getopt(argc, argv, "aw:o:p:v:")) != -1) {
switch (i) {
- case 'a':
- isStandalone = 0;
- break;
case 'w':
- bandWidth = atoi(optarg);
+ my->bandWidth = atoi(optarg);
break;
case 'o':
- outPath = optarg;
+ strcpy(my->outPath, optarg);
+ break;
+ case 'a':
+ my->isStandalone = 0;
break;
case 'p':
- priority = atoi(optarg);
+ my->priority = atoi(optarg);
+ break;
+ case 'q':
+ my->queueSize = atoi(optarg);
break;
case 'v':
- if (msglog_setlevel(argv[0], optarg) == 1) {
- break;
- } /* FALLTHROUGH to default */
+ strcpy(my->verbosity, optarg);
+ break;
default:
- usage(argv[0]);
- exit(EXIT_FAILURE);
+ return -1;
break;
}
}
- if (strcmp(outPath, "-") == 0 || bandWidth == -1) {
+ return 0;
+}
+
+static int argsFromParam(TheArgs *my, int argc, char *argv[]) {
+ Param paramS, *param = ¶mS;
+ int paramWasFound;
+
+ conParam(param);
+ Param_getString(param, argv[0], "outpath", ¶mWasFound, my->outPath);
+ Param_getInt(param, argv[0], "bdwidth", ¶mWasFound, &my->bandWidth);
+ Param_getInt(param, argv[0], "stndln", ¶mWasFound, &my->isStandalone);
+ Param_getInt(param, argv[0], "prio", ¶mWasFound, &my->priority);
+ Param_getInt(param, argv[0], "qsize", ¶mWasFound, &my->queueSize);
+ Param_getString(param, argv[0], "verb", ¶mWasFound, my->verbosity);
+ desParam(param);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ TheArgs theArgsS, *theArgs = &theArgsS;
+ Worker *worker;
+ NetTrans *netTrans;
+ ShmTrans *shmTrans;
+ int exitStat;
+
+ argsDefault(theArgs);
+ argsFromParam(theArgs, argc, argv);
+ if (0 > argsFromCL(theArgs, argc, argv)) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (msglog_setlevel(argv[0], theArgs->verbosity) != 1) {
+ msglog_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (strcmp(theArgs->outPath, "") == 0) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
- if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, priority, isStandalone))) {
+ if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
msglog(LOG_ERR, "initializing working process: %s\n"), strerror(errno);
exitStat = EXIT_FAILURE;
goto bailOut0;
}
- if (NULL == (shmTrans = ShmTrans_create("subevtqueue", 2 * queueSize))) {
+ if (NULL == (shmTrans = ShmTrans_create("subevtqueue", 2 * theArgs->queueSize))) {
msglog(LOG_ERR,
"creating shared memory \"subevtqueue\": %s\n"), strerror(errno);
exitStat = EXIT_FAILURE;
goto bailOut1;
}
- if (NULL == (netTrans = NetTrans_open(outPath, bandWidth, worker))) {
+ if (NULL == (netTrans = NetTrans_open(theArgs->outPath, theArgs->bandWidth, worker))) {
msglog(LOG_ERR,
- "opening network transport %s: %s\n", outPath, strerror(errno));
+ "opening network transport %s: %s\n", theArgs->outPath, strerror(errno));
exitStat = EXIT_FAILURE;
goto bailOut2;
}
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.8 2000-03-07 12:42:17 muench Stab $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.9 2000-11-08 07:53:23 hades Exp $";
#define _XOPEN_SOURCE
#include <unistd.h>
#include <string.h>
#include <hadesstd.h>
+#include <allParam.h>
#include "worker.h"
#include "nettrans.h"
#define MAXINPATH 32
+typedef struct TheArgsS {
+ char inPathS[MAXINPATH][PARAM_MAX_NAME_LEN];
+ char *inPath[MAXINPATH];
+ int inPathCnt;
+ unsigned long nrOfMsgs;
+ unsigned long isStandalone;
+ unsigned long priority;
+ unsigned long queueSize;
+ char verbosity[PARAM_MAX_VALUE_LEN];
+} TheArgs;
+
static jmp_buf terminateJmp;
void sigHandler(int sig)
msglog_usage();
}
-int main(int argc, char *argv[])
-{
+static void argsDefault(TheArgs *my) {
int i;
- Worker *worker;
- NetTrans **netTrans;
- ShmTrans **shmTrans;
- void **hadTu;
- size_t *hadTuSize;
- int priority;
- char *inPath[MAXINPATH];
- int inPathCnt;
- int isStandalone;
- int nrOfMsgs;
- size_t queueSize;
- msglog_setlevel(argv[0], "info");
- inPathCnt = 0;
- priority = 0;
- isStandalone = 1;
- nrOfMsgs = 0;
- queueSize = 1 * 1024 * 1024;
+ for (i = 0; i < MAXINPATH; i++) {
+ my->inPath[i] = my->inPathS + i * PARAM_MAX_NAME_LEN;
+ }
+ my->inPathCnt = 0;
+ my->nrOfMsgs = 0;
+ my->priority = 0;
+ my->isStandalone = 1;
+ my->queueSize = 1 * 1024 * 1024;
+ strcpy(my->verbosity, "info");
+}
+
+static int argsFromCL(TheArgs *my, int argc, char *argv[]) {
+ int i;
while ((i = getopt(argc, argv, "ai:m:p:v:")) != -1) {
switch (i) {
- case 'a':
- isStandalone = 0;
- break;
case 'm':
- nrOfMsgs = atoi(optarg);
+ my->nrOfMsgs = atoi(optarg);
break;
case 'i':
- inPath[inPathCnt++] = optarg;
+ strcpy(my->inPath[my->inPathCnt++], optarg);
+ break;
+ case 'a':
+ my->isStandalone = 0;
break;
case 'p':
- priority = atoi(optarg);
+ my->priority = atoi(optarg);
+ break;
+ case 'q':
+ my->queueSize = atoi(optarg);
break;
case 'v':
- if (msglog_setlevel(argv[0], optarg) == 1) {
- break;
- } /* FALLTHROUGH to default */
+ strcpy(my->verbosity, optarg);
+ break;
default:
- usage(argv[0]);
- exit(EXIT_FAILURE);
+ return -1;
break;
}
}
- if (inPathCnt == 0 || nrOfMsgs == 0 || inPathCnt != nrOfMsgs) {
+ return 0;
+}
+
+static int argsFromParam(TheArgs *my, int argc, char *argv[]) {
+ Param paramS, *param = ¶mS;
+ int paramWasFound;
+
+ conParam(param);
+ Param_getStringArray(param, argv[0], "inpath",
+ MAXINPATH, &my->inPathCnt, my->inPath);
+ Param_getInt(param, argv[0], "nrofmsgs", ¶mWasFound, &my->nrOfMsgs);
+ Param_getInt(param, argv[0], "stndln", ¶mWasFound, &my->isStandalone);
+ Param_getInt(param, argv[0], "prio", ¶mWasFound, &my->priority);
+ Param_getInt(param, argv[0], "qsize", ¶mWasFound, &my->queueSize);
+ Param_getString(param, argv[0], "verb", ¶mWasFound, my->verbosity);
+ desParam(param);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ TheArgs theArgsS, *theArgs = &theArgsS;
+ Worker *worker;
+ NetTrans **netTrans;
+ ShmTrans **shmTrans;
+ void **hadTu;
+ size_t *hadTuSize;
+
+ argsDefault(theArgs);
+ argsFromParam(theArgs, argc, argv);
+ if (0 > argsFromCL(theArgs, argc, argv)) {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (msglog_setlevel(argv[0], theArgs->verbosity) != 1) {
+ msglog_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (theArgs->inPathCnt == 0 || theArgs->nrOfMsgs == 0 || theArgs->inPathCnt != theArgs->nrOfMsgs) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
- netTrans = allocMem(nrOfMsgs * sizeof(NetTrans *));
- shmTrans = allocMem(nrOfMsgs * sizeof(ShmTrans *));
- hadTu = allocMem(nrOfMsgs * sizeof(void *));
- hadTuSize = allocMem(nrOfMsgs * sizeof(size_t));
+ netTrans = allocMem(theArgs->nrOfMsgs * sizeof(NetTrans *));
+ shmTrans = allocMem(theArgs->nrOfMsgs * sizeof(ShmTrans *));
+ hadTu = allocMem(theArgs->nrOfMsgs * sizeof(void *));
+ hadTuSize = allocMem(theArgs->nrOfMsgs * sizeof(size_t));
- if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, priority, isStandalone))) {
+ if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
char buf[80];
- netTrans[i] = NetTrans_create(inPath[i], 0, worker);
+ netTrans[i] = NetTrans_create(theArgs->inPath[i], 0, worker);
if (netTrans[i] == NULL) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
sprintf(buf, "netqueue%d", i);
- shmTrans[i] = ShmTrans_open(buf, 2 * queueSize);
+ shmTrans[i] = ShmTrans_open(buf, 2 * theArgs->queueSize);
if (shmTrans[i] == NULL) {
msglog(LOG_ERR, "%s, %d: %s\n", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
hadTu[i] = NULL;
- hadTuSize[i] = queueSize - HadTu_hdrSize();
+ hadTuSize[i] = theArgs->queueSize - HadTu_hdrSize();
}
Worker_initEnd(worker);
Worker_dump(worker, 1);
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
if (hadTu[i] == NULL) {
ShmTrans_requestSpace(shmTrans[i]);
hadTu[i] = ShmTrans_tryAlloc(shmTrans[i], hadTuSize[i]);
}
}
- msgsCompleted = NetTrans_multiRecv(netTrans, hadTu, hadTuSize, nrOfMsgs);
+ msgsCompleted = NetTrans_multiRecv(netTrans, hadTu, hadTuSize, theArgs->nrOfMsgs);
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
if ((msgsCompleted & (1 << i)) != 0) {
ShmTrans_send(shmTrans[i]);
hadTu[i] = NULL;
}
Worker_dump(worker, 0);
- for (i = 0; i < nrOfMsgs; i++) {
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
ShmTrans_remove(shmTrans[i]);
NetTrans_remove(netTrans[i]);
}
set evtbuild(file) ./daq_evtbuild
-set evtbuild(args) "daq_evtbuild -s 1 -a"
+set evtbuild(stndln) 0
+#set evtbuild(nrofmsgs) 1
set netmem(file) ./daq_netmem
-set netmem(args) "daq_netmem -a -i UDP:0.0.0.0:3000 -m 1"
+set netmem(stndln) 0
+set netmem(nrofmsgs) 1
+set netmem(inpath0) UDP:0.0.0.0:3000
set memnet(file) ./daq_memnet
-set memnet(args) "daq_memnet -a -o UDP:129.187.154.22:3000 -w 0"
+set memnet(stndln) 0
+set memnet(outpath) UDP:140.181.110.27:3000
set readout(file) ./daq_readout
-set readout(args) "daq_readout -a"
+set readout(stndln) 0
set sam0(cardbase) 0x9C000000
set soft(size) 10240
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.9 2000-02-03 18:06:04 muench Stab $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.10 2000-11-08 07:53:23 hades Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <sys/types.h>
#include <hadesstd.h>
+#include <allParam.h>
#include "hardware.h"
#include "shmtrans.h"
#include "hadtuqueue.h"
#include "worker.h"
+typedef struct TheArgsS {
+ unsigned long isStandalone;
+ unsigned long priority;
+ unsigned long queueSize;
+ char verbosity[PARAM_MAX_VALUE_LEN];
+} TheArgs;
+
static jmp_buf terminateJmp;
void sigHandler(int sig)
msglog_usage();
}
-void main(int argc, char *argv[])
-{
- Hardware *hw;
- void *subEvt;
- Worker *worker;
- ShmTrans *shmTrans;
- int i;
- int isStandalone;
- char *outPath;
- int priority;
- size_t queueSize;
- unsigned long *trigAccepted;
- unsigned long *subevtsRead;
- unsigned long *subevtsDataErr;
+static void argsDefault(TheArgs *my) {
+ my->priority = 0;
+ my->isStandalone = 1;
+ my->queueSize = 1 * 1024 * 1024;
+ strcpy(my->verbosity, "info");
+}
- isStandalone = 1;
- outPath = "subevtqueue";
- priority = 0;
- queueSize = 1 * 1024 * 1024;
- msglog_setlevel(argv[0], "info");
+static int argsFromCL(TheArgs *my, int argc, char *argv[]) {
+ int i;
- while ((i = getopt(argc, argv, "ap:v:")) != -1) {
+ while ((i = getopt(argc, argv, "ap:q:v:")) != -1) {
switch (i) {
case 'a':
- isStandalone = 0;
+ my->isStandalone = 0;
break;
case 'p':
- priority = atoi(optarg);
+ my->priority = atoi(optarg);
+ break;
+ case 'q':
+ my->queueSize = atoi(optarg);
break;
case 'v':
- if (msglog_setlevel(argv[0], optarg) != 1) {
- usage(argv[0]);
- goto bailOut0;
- }
+ strcpy(my->verbosity, optarg);
break;
default:
- usage(argv[0]);
- goto bailOut0;
+ return -1;
break;
}
}
+ return 0;
+}
+
+static int argsFromParam(TheArgs *my, int argc, char *argv[]) {
+ Param paramS, *param = ¶mS;
+ int paramWasFound;
+
+ conParam(param);
+ Param_getInt(param, argv[0], "stndln", ¶mWasFound, &my->isStandalone);
+ Param_getInt(param, argv[0], "prio", ¶mWasFound, &my->priority);
+ Param_getInt(param, argv[0], "qsize", ¶mWasFound, &my->queueSize);
+ Param_getString(param, argv[0], "verb", ¶mWasFound, my->verbosity);
+ desParam(param);
+}
+
+void main(int argc, char *argv[])
+{
+ TheArgs theArgsS, *theArgs = &theArgsS;
+ Hardware *hw;
+ void *subEvt;
+ Worker *worker;
+ ShmTrans *shmTrans;
+ unsigned long *trigAccepted;
+ unsigned long *subevtsRead;
+ unsigned long *subevtsDataErr;
+
+ argsDefault(theArgs);
+ argsFromParam(theArgs, argc, argv);
+ if (0 > argsFromCL(theArgs, argc, argv)) {
+ usage(argv[0]);
+ goto bailOut0;
+ }
+
+ if (msglog_setlevel(argv[0], theArgs->verbosity) != 1) {
+ msglog_usage();
+ goto bailOut0;
+ }
- if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, priority, isStandalone))) {
+ if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
msglog(LOG_ERR, "connecting to agent: %s\n", strerror(errno));
goto bailOut0;
}
msglog(LOG_ERR, "initializing hardware: %s\n", strerror(errno));
goto bailOut1;
}
- if (NULL == (shmTrans = ShmTrans_open(outPath, 2 * queueSize))) {
+ if (NULL == (shmTrans = ShmTrans_open("subevtqueue", 2 * theArgs->queueSize))) {
msglog(LOG_ERR,
- "opening shared memory \"%s\": %s\n", outPath, strerror(errno));
+ "opening shared memory \"%s\": %s\n", "subevtqueue", strerror(errno));
goto bailOut2;
}
trigAccepted = Worker_addStatistic(worker, "trigAccepted");