]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Dinamic maxFileSize added. Sergey.
authorhadaq <hadaq>
Tue, 17 Aug 2010 13:31:08 +0000 (13:31 +0000)
committerhadaq <hadaq>
Tue, 17 Aug 2010 13:31:08 +0000 (13:31 +0000)
ebctrl/ioc/ebctrlApp/src/genrunid.c

index 86020d9c04e43e40bcb7fc5ae6bb1975f4bc331b..91c405f697c02d9db86e7771eb0524b0c4ab118a 100644 (file)
@@ -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( "<D> genrunid.c: Event Builder is off, status: %d\n", status );
-       printf( "<D> genrunid.c: You might check permissions of EB shared memory segment.\n");
+       printf( "<D> 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( "<D> genrunid.c: received file size: %d\n", fileSize );
+      printf( "<D> 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