From 8957c42a2e93067fcc62d91e8add4f7084b69fa0 Mon Sep 17 00:00:00 2001 From: hadaq Date: Tue, 17 Aug 2010 13:31:08 +0000 Subject: [PATCH] Dinamic maxFileSize added. Sergey. --- ebctrl/ioc/ebctrlApp/src/genrunid.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ebctrl/ioc/ebctrlApp/src/genrunid.c b/ebctrl/ioc/ebctrlApp/src/genrunid.c index 86020d9..91c405f 100644 --- a/ebctrl/ioc/ebctrlApp/src/genrunid.c +++ b/ebctrl/ioc/ebctrlApp/src/genrunid.c @@ -20,9 +20,9 @@ long genRunId_proc( struct subRecord *psub ) static long runId = 0; static long runIdOld = 0; - long timeoffset = 1200000000; /* seconds */ - long sizelimit = 100; /* bytes (MB) */ - int fileSize = 0; + long timeoffset = 1200000000; /* seconds */ + unsigned long maxFileSize = 1500; /* MBytes */ + long currentFileSize = 0; int status = 0; struct timeval tv; @@ -49,13 +49,13 @@ long genRunId_proc( struct subRecord *psub ) } else{ - fileSize = psub->a; /* size (MB) of the data file written by event builder */ + currentFileSize = psub->a; /* size (MB) of the data file written by event builder */ status = (int) psub->b; /* status of the event buidler (1=on/0=off) */ if( status == 0 ) { if( genrunidDebug ) { printf( " genrunid.c: Event Builder is off, status: %d\n", status ); - printf( " genrunid.c: You might check permissions of EB shared memory segment.\n"); + printf( " genrunid.c: You might need to check permissions of EB shared memory segment.\n"); /* * One of the reasons for this message might be closed permissions * for (/dev/shm/daq_evtbuild.shm) shared memory access. @@ -65,16 +65,19 @@ long genRunId_proc( struct subRecord *psub ) runId = 0; } + /* Get max file size limit in MBytes */ + maxFileSize = strtoul(getenv("FILESIZE"), NULL, 0); + if( genrunidDebug ) - printf( " genrunid.c: received file size: %d\n", fileSize ); + printf( " genrunid.c: bytes written to a file: %lu\n", maxFileSize ); - if( fileSize < sizelimit ){ + if( currentFileSize <= maxFileSize ){ runIdOld = runId; } /* Generate RUN Id: time (in sec from 1970) minus timeoffset */ if( (runId == 0 && status) || - (fileSize > sizelimit && runIdOld == runId && runId > 0 && status) ) { + (currentFileSize > maxFileSize && runIdOld == runId && runId > 0 && status) ) { /* * The following line is executed only ONCE -- 2.43.0