static char *rcsId =
- "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.85 2008-06-03 14:26:53 hadaq Exp $";
+ "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.86 2008-06-03 16:31:26 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
char lustrePath[PARAM_MAX_VALUE_LEN];
unsigned short buffStat;
unsigned short epicsCtrl;
+
+ char shmname[PARAM_MAX_VALUE_LEN];
} TheArgs;
typedef struct TheStatsS
syslog (LOG_ERR, "Usage: [-m nrOfMsgs] [-f slowCtrlFile ...]");
syslog (LOG_ERR, "Usage: [-o outPath] [-d null|tape|file|stdout]");
syslog (LOG_ERR, "Usage: [-q queueSize] [-r runNumber]");
+ syslog (LOG_ERR, "Usage: [--shmname shmem_name] extention of shared memory name to be opened");
syslog (LOG_ERR, "Usage: [-a (agent)] [-p priority] [-I evtId]");
syslog (LOG_ERR, "Usage: [-v debug|info|notice|warning|err|alert|crit|emerg]");
syslog (LOG_ERR, "Usage: [--norpc]");
syslog (LOG_ERR, "Usage: [--filesize maximum_size_of_output_file[in MB]]");
- syslog (LOG_ERR, "Usage: [--resdownscale resdownscale_factor] downscale factor for the res events");
+ syslog (LOG_ERR, "Usage: [--resdownscale downscale_factor] downscale factor for the res events");
syslog (LOG_ERR, "Usage: [--resnumevents evt_num] maximum number of events in a resfile");
syslog (LOG_ERR, "Usage: [--respath path] path for the res directory");
syslog (LOG_ERR, "Usage: [--secsizelimit max_size] maximum size of second directory with the mirrored data [in MB]");
syslog (LOG_DEBUG, "verbosity: %s", my->verbosity);
syslog (LOG_DEBUG, "evtId: %ld", my->evtId);
syslog (LOG_DEBUG, "maxFileSz: %ld", my->maxFileSz);
+ if( strcmp( my->shmname, "" ) != 0 ) {
+ syslog (LOG_DEBUG, "shmem name: %s", my->shmname);
+ }
if (my->resdownscale != 0) {
syslog (LOG_DEBUG, "resdownscale: %ld", my->resdownscale);
syslog (LOG_DEBUG, "resnumevents: %ld", my->resnumevents);
strcpy (my->outPath, "");
strcpy (my->outDev, "null");
strcpy (my->expId, "xx");
+ strcpy (my->shmname, "");
my->priority = 0;
my->isStandalone = 1;
my->queueSize = 4 * 1024 * 1024UL;
{"buffstat", 0, 0, 'b'},
{"epicsctrl", 0, 0, 'E'},
{"lustre", 1, 0, 'L'},
+ {"shmname", 1, 0, 'S'},
{0, 0, 0, 0}
};
i = getopt_long (argc, argv,
- "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:",
+ "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:S:",
long_options, &option_index);
if (i == -1)
break;
strcpy (my->sec_path, optarg);
break;
case 'R':
- strcpy (my->rfioRemotePath, optarg);
+ strcpy( my->rfioRemotePath, optarg );
break;
case 'L':
- strcpy (my->lustrePath, optarg);
+ strcpy( my->lustrePath, optarg );
+ break;
+ case 'S':
+ strcpy( my->shmname, optarg );
break;
case 'b':
my->buffStat = 1;
t_0 = t;
}
-static void statsBufferDump (TheArgs * theArgs, TheStats * my, float interval,
- HadTuQueue **htuq, ShmTrans **shmtr)
+static void statsBufferDump (TheArgs *theArgs, TheStats *my, float interval,
+ HadTuQueue **htuq, ShmTrans **shmtr, char *progName)
{
static unsigned long lastEC2;
static unsigned long lastBW2;
printTime();
unsigned long runId2print;
- Worker_getStatistic( "daq_evtbuild", "runId", &runId2print);
+ char buf[_POSIX_PATH_MAX];
+ sprintf( buf, "%s%s", progName, theArgs->shmname );
+ Worker_getStatistic( buf, "runId", &runId2print);
printf("ioc: RUN Id = %lu\n", runId2print);
}
}
theArgs->expId[1] = tolower (theArgs->expId[1]);
theArgs->expId[2] = '\0';
- if (NULL == (worker = Worker_initBegin (argv[0], sigHandler, theArgs->priority,
- theArgs->isStandalone))) {
+ /* Create a name for a worker's shared memory segment
+ * which consists of a program name and a base name provided by user
+ */
+ char buf[_POSIX_PATH_MAX];
+ sprintf( buf, "%s%s", argv[0], theArgs->shmname );
+
+ if (NULL == (worker = Worker_initBegin (buf, sigHandler, theArgs->priority,
+ theArgs->isStandalone))) {
syslog (LOG_ERR, "%s, %d: %s", __FILE__, __LINE__, strerror (errno));
exit (EXIT_FAILURE);
}
-
+
if (theArgs->no_rpc)
syslog (LOG_WARNING, "DISABLE of online service");
else
shmTrans = malloc (sizeof (ShmTrans *));
hadTuQueue = malloc (sizeof (HadTuQueue *));
- shmTrans[0] = ShmTrans_create ("subevtqueue", 2 * theArgs->queueSize);
+ sprintf( buf, "subevtqueue%s", theArgs->shmname );
+ shmTrans[0] = ShmTrans_create( buf, 2 * theArgs->queueSize );
+
hadTuQueue[0] = NULL;
theArgs->nrOfMsgs = 1;
}
for (i = 0; i < theArgs->nrOfMsgs; i++) {
char buf[_POSIX_PATH_MAX];
- sprintf (buf, "netqueue%d", i);
+ /* use shared mem name from CL if given */
+ sprintf (buf, "netqueue%s%d", theArgs->shmname, i);
if( theArgs->queueSize > 0 ) {
/* The queueSize is given in CL. */
int tagError = 0;
add2Stat( theArgs, theStats, 1, shmTrans );
- statsBufferDump( theArgs, theStats, 1, hadTuQueue, shmTrans );
+ statsBufferDump( theArgs, theStats, 1, hadTuQueue, shmTrans, argv[0] );
statsDump (theArgs, theStats, 1);
if (*theStats->bytesWritten == 0)
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.32 2008-05-28 14:57:04 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.33 2008-06-03 16:31:56 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
unsigned long isStandalone;
unsigned long priority;
unsigned long queueSize;
- long varQSize[MAXINPATH];
+ unsigned long varQSize[MAXINPATH];
int varQSizeCnt;
char verbosity[PARAM_MAX_VALUE_LEN];
- unsigned int buffStat;
+ unsigned int buffStat;
+ char shmname[PARAM_MAX_VALUE_LEN];
} TheArgs;
typedef struct TheStatsS
{
unsigned long *netmemBuff[MAXINPATH];
unsigned long *nrOfMsgs;
- unsigned long *recvBytesPS[MAXINPATH];
+ unsigned long *recvBytesRate[MAXINPATH];
} TheStats;
static jmp_buf terminateJmp;
static void usage(const char *progName)
{
syslog(LOG_ERR, "Usage: %s -i inPath [-i inPath] -m nrOfMsgs [-p priority]", progName);
- syslog (LOG_ERR, "[-b] show fill levels of buffers]");
+ syslog( LOG_ERR, "[-b] show fill levels of buffers]" );
+ syslog( LOG_ERR, "[-S shmem_name] extention of a shared memory name to be used" );
}
static void argsDump(TheArgs *my)
syslog(LOG_DEBUG, "isStandalone: %d", my->isStandalone);
syslog(LOG_DEBUG, "queueSize: %d", my->queueSize);
syslog(LOG_DEBUG, "verbosity: %s", my->verbosity);
+ if( strcmp( my->shmname, "" ) != 0 ) {
+ syslog (LOG_DEBUG, "shmem name: %s", my->shmname);
+ }
}
static void argsDefault(TheArgs *my)
my->varQSize[i] = 1 * 1024 * 1024;
}
my->buffStat = 0;
+ strcpy (my->shmname, "");
}
static int argsFromCL(TheArgs *my, int argc, char *argv[])
inPathCntFromParam = my->inPathCnt;
my->inPathCnt = 0;
- while ((i = getopt(argc, argv, "ai:m:q:p:v:b")) != -1) {
+ while ((i = getopt(argc, argv, "ai:m:q:p:v:bS:")) != -1) {
switch (i) {
case 'm':
my->nrOfMsgs = atoi(optarg);
case 'b':
my->buffStat = 1;
break;
+ case 'S':
+ strcpy(my->shmname, optarg);
+ break;
default:
return -1;
break;
(*my->netmemBuff[i]) = fillLevel;
/* Add more statistic for recv bytes per second */
- (*my->recvBytesPS[i]) = *nettr[i]->bytesReceived - lastBytesRecv[i];
+ (*my->recvBytesRate[i]) = *nettr[i]->bytesReceived - lastBytesRecv[i];
lastBytesRecv[i] = *nettr[i]->bytesReceived;
}
hadTu = malloc(theArgs->nrOfMsgs * sizeof(void *));
hadTuSize = malloc(theArgs->nrOfMsgs * sizeof(size_t));
- if (NULL == (worker = Worker_initBegin(argv[0], sigHandler, theArgs->priority, theArgs->isStandalone))) {
+ char buf[_POSIX_PATH_MAX];
+ sprintf( buf, "%s%s", argv[0], theArgs->shmname );
+
+ if (NULL == (worker = Worker_initBegin(buf, sigHandler, theArgs->priority, theArgs->isStandalone))) {
syslog(LOG_ERR, "%s, %d: %s", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
syslog(LOG_ERR, "%s, %d: %s", __FILE__, __LINE__, strerror(errno));
exit(EXIT_FAILURE);
}
- sprintf(buf, "netqueue%d", i);
+
+ /* use shared mem name from CL if given */
+ sprintf(buf, "netqueue%s%d", theArgs->shmname, i);
if( theArgs->queueSize > 0 ){
/* if the queueSize is given in CL */
sprintf( buf, "netmemBuff%d", i );
theStats->netmemBuff[i] = Worker_addStatistic( worker, buf );
- sprintf( buf, "bytesReceivedPS%d", i );
- theStats->recvBytesPS[i] = Worker_addStatistic( worker, buf );
+ sprintf( buf, "bytesReceivedRate%d", i );
+ theStats->recvBytesRate[i] = Worker_addStatistic( worker, buf );
}
theStats->nrOfMsgs = Worker_addStatistic( worker, "nrOfMsgs" );