static char *rcsId =
- "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.87 2008-06-04 16:12:06 hadaq Exp $";
+ "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.88 2008-06-06 15:39:50 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
-/* #define RFIO */
+/* #define RFIO */
#include <unistd.h>
#include <getopt.h>
unsigned long varQSize[MAXINPATH];
int varQSizeCnt;
- unsigned int rfioFlag;
char rfioRemotePath[PARAM_MAX_VALUE_LEN];
char lustrePath[PARAM_MAX_VALUE_LEN];
unsigned short buffStat;
unsigned short epicsCtrl;
char shmname[PARAM_MAX_VALUE_LEN];
+ unsigned int ebnum;
} TheArgs;
typedef struct TheStatsS
unsigned long *evtbuildBuff[MAXINPATH];
unsigned long *nrOfMsgs;
unsigned long *runId;
- unsigned long *evtsCompleteRate;
- unsigned long *bytesWrittenRate;
- unsigned long *evtsDiscardedRate;
} TheStats;
static jmp_buf terminateJmp;
syslog (LOG_ERR, "Usage: [--buffstat] show fill levels of buffers");
syslog (LOG_ERR, "Usage: [--epicsctrl] enable synch and distribution of RUN Id by Epics for parallel event builders");
syslog (LOG_ERR, "Usage: [--lustre path_to_lustre] path to the file on the Lustre cluster");
+ syslog (LOG_ERR, "Usage: [--ebnum] number of the event builder");
}
static void argsDump (TheArgs * my)
if( strcmp( my->lustrePath, "" ) != 0 ) {
syslog (LOG_DEBUG, "lustre path: %s", my->lustrePath);
}
+ syslog (LOG_DEBUG, "EB numder: %d", my->ebnum);
}
static void argsDefault (TheArgs * my)
strcpy (my->lustrePath, "");
my->buffStat = 0;
my->epicsCtrl = 0;
+ my->ebnum = 0;
}
static int argsFromCL (TheArgs * my, int argc, char *argv[])
{"epicsctrl", 0, 0, 'E'},
{"lustre", 1, 0, 'L'},
{"shmname", 1, 0, 'S'},
+ {"ebnum", 1, 0, 'B'},
{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:S:",
+ "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:S:B:",
long_options, &option_index);
if (i == -1)
break;
case 'E':
my->epicsCtrl = 1;
break;
+ case 'B':
+ my->ebnum = strtoul (optarg, NULL, 0);
+ break;
case 'H':
usage (argv[0]);
return -1;
{
/* Add statistic for fill levels of buffers in percentage. */
- static unsigned long lastEvtsComplete;
- static unsigned long lastBytesWritten;
- static unsigned long lastEvtsDisc;
static time_t t_0 = 0;
float buffSize, queueSize;
time_t t, dT;
fillLevel = (unsigned long) (100*queueSize+0.5)/buffSize;
(*my->evtbuildBuff[i]) = fillLevel;
}
-
- /* Add more statistic for evtsComplete and bytesWritten per second */
- if( (*my->evtsComplete) >= lastEvtsComplete )
- (*my->evtsCompleteRate) = (*my->evtsComplete - lastEvtsComplete) / dT;
- else
- (*my->evtsCompleteRate) = (*my->evtsComplete);
-
- if( (*my->bytesWritten) >= lastBytesWritten)
- (*my->bytesWrittenRate) = (*my->bytesWritten - lastBytesWritten) / dT;
- else
- (*my->bytesWrittenRate) = (*my->bytesWritten);
-
- if( (*my->evtsDiscarded) >= lastEvtsDisc)
- (*my->evtsDiscardedRate) = (*my->evtsDiscarded - lastEvtsDisc) / dT;
- else
- (*my->evtsDiscardedRate) = (*my->evtsDiscarded);
-
- lastEvtsComplete = *my->evtsComplete;
- lastBytesWritten = *my->bytesWritten;
- lastEvtsDisc = *my->evtsDiscarded;
}
t_0 = t;
char buf[_POSIX_PATH_MAX];
sprintf( buf, "%s%s", progName, theArgs->shmname );
Worker_getStatistic( buf, "runId", &runId2print);
- printf("ioc: RUN Id = %lu\n", runId2print);
+ printf("ioc: RUN Id = %lu RUN Nr = %lu\n", runId2print, runNr);
}
}
/* construct a default filename */
strcpy (fileName, theArgs->expId);
- strftime (fileName + strlen (fileName), 18, "%y%j%H%M%S.hld",
+
+ /* %y : year (00-99) %M : minute (00-59)
+ * %j : day of year (001-366) %S : second (00-59)
+ * %H : hour (00-23)
+ */
+ strftime (fileName + strlen (fileName), 18, "%y%j%H%M%S",
localtime (&ourTime));
+
+ /* if ebnum == 0 then we assume that there is only 1 EB,
+ * RUNID distribution by IOC is not needed and file name
+ * can be in the usual format without EB identificator.
+ */
+ if( theArgs->epicsCtrl && theArgs->ebnum > 0 )
+ sprintf( fileName, "%s%02d.hld", fileName, theArgs->ebnum);
+ else
+ sprintf( fileName, "%s.hld", fileName);
outTape = NULL;
outFile = NULL;
}
theStats->evtsDiscarded = Worker_addStatistic (worker, "evtsDiscarded");
- theStats->evtsDiscardedRate = Worker_addStatistic (worker, "evtsDiscardedRate");
theStats->evtsComplete = Worker_addStatistic (worker, "evtsComplete");
- theStats->evtsCompleteRate = Worker_addStatistic (worker, "evtsCompleteRate");
theStats->evtsDataError = Worker_addStatistic (worker, "evtsDataError");
theStats->evtsTagError = Worker_addStatistic (worker, "evtsTagError");
theStats->bytesWritten = Worker_addStatistic (worker, "bytesWritten");
- theStats->bytesWrittenRate = Worker_addStatistic (worker, "bytesWrittenRate");
theStats->runId = Worker_addStatistic (worker, "runId");
(*theStats->runId) = 0; /* initialize to zero */
else
res_time = ourTime = time (NULL);
+ char s[20];
+ time_t my_time;
+ my_time = time(NULL);
+ strftime( s, 20, "%Y-%m-%dT%H:%M:%S", localtime(&my_time) );
+ printf("local time: %s\n", s);
+ strftime( s, 20, "%Y-%m-%dT%H:%M:%S", localtime(&ourTime) );
+ printf("ioc time: %s\n", s);
+ printf("ioc runid: %d\n", runNr);
if (-1 == openFile (theArgs))
{