]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
*** empty log message ***
authormuench <muench>
Thu, 3 Feb 2000 18:02:46 +0000 (18:02 +0000)
committermuench <muench>
Thu, 3 Feb 2000 18:02:46 +0000 (18:02 +0000)
hadaq/hwrich.c
hadaq/readout.c

index 2a13087dbcf802b5d06a03abfedc9d92cc8cddf2..227b5951d9cd97e47cba88cc2e8c2f5d4243ea13 100644 (file)
@@ -1,24 +1,35 @@
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.3 1999-11-01 08:35:36 muench Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.4 2000-02-03 18:02:46 muench Stab $";
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
 
 #include <errno.h>
 #include <stdio.h>
-#include <string.h> 
+#include <string.h>
 #include <sys/time.h>
 
+#define SYNCHRONOUS
+
+#ifdef SYNCHRONOUS
+#include <lvme.h>
+
+#include "dtu_defs.h"
+
+#endif
 #include "param.h"
 #include "subevt.h"
 #include "hwrace.h"
 
 /* Set number of RCs here */
-#define NRACES 1
+#define NRACES 2
 
 struct HardwareS {
        size_t maxSubEvtSize;
        HwRace *race[NRACES];
        unsigned raceToRead;
+#ifdef SYNCHRONOUS
+       LVme *lvme;
+#endif
 };
 
 #include "hardware.h"
@@ -38,6 +49,13 @@ Hardware *newHardware(void)
        Hardware *my;
        Param paramS, *param = &paramS;
        int i;
+#ifdef SYNCHRONOUS
+       unsigned long cardBase;
+#endif
+
+#ifdef SYNCHRONOUS
+       cardBase = 0x44100000;
+#endif
 
        if (0 > conParam(param, "param.tcl")) {
                msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
@@ -45,7 +63,7 @@ Hardware *newHardware(void)
        }
        my = allocMem(sizeof(Hardware));
 
-       my->maxSubEvtSize = SubEvt_hdrSize() + (0x2010 * sizeof(UInt4));
+       my->maxSubEvtSize = SubEvt_hdrSize() + (2500 * sizeof(UInt4));
        my->raceToRead = 0;
 
        for (i = 0; i < NRACES; i++) {
@@ -59,6 +77,14 @@ Hardware *newHardware(void)
                }
        }
 
+#ifdef SYNCHRONOUS
+       my->lvme = allocMem(sizeof(LVme));
+       if (-1 == conLVme(my->lvme, cardBase, 0x100000, 0x09, 0, 0)) {
+               return NULL;
+       }
+       /* set Lock Busy */
+       LVme_setBitL(my->lvme, STATUS1, 4);
+#endif
 
        desParam(param);
        return my;
@@ -72,16 +98,54 @@ void deleteHardware(Hardware *my)
                desHwRace(my->race[i]);
                freeMem(my->race[i]);
        }
+#ifdef SYNCHRONOUS
+       desLVme(my->lvme);
+#endif
 
        freeMem(my);
 }
 
 void Hardware_waitForTrigger(Hardware *my, void *subEvt)
 {
+#ifdef SYNCHRONOUS
+       int i, j;
+       static int beginRun = 1; /* eat 1 triggers at begin run */
+
+       while (beginRun > 0) {
+               /* wait for begin run trigger and release busy afterwards */
+               while (!LVme_tstBitL(my->lvme, STATUS1, 6)) {
+                       struct timespec tS, *t = &tS;
+                       t->tv_sec = 0;
+                       t->tv_nsec = 020000000;
+                       nanosleep(t, NULL);
+               }
+               LVme_setL(my->lvme, RELEASE1, 0xee);
+               sleep(1);
+               beginRun--;
+       }
+#endif
        if (HwRace_isEmpty(my->race[my->raceToRead])) {
+#ifdef SYNCHRONOUS
+               LVme_setL(my->lvme, RELEASE1, 0xee);
+               for (i = 0; i < 20000; i++) {
+                       j = 1 + 1;
+               }
+/*                     msglog(LOG_INFO, "buffer is empty RC %d\n",my->raceToRead); */
+#endif
                HwRace_requestBuffer(my->race[my->raceToRead]);
+#ifdef SYNCHRONOUS
+               for (i = 0; i < 20000; i++) {
+                       j = 1 + 1;
+               }
+/*                     msglog(LOG_INFO, "switch request set\n"); */
+#endif
                while (HwRace_isBusy(my->race[my->raceToRead])) {
-#if 1
+#if 0
+/*
+ * This sleep prevents a tight loop which stops work on real
+ * time systems if the priority of readout is not lowered.
+ * When not using the sleep use option -p -2 for daq_readout.
+*/
                        struct timespec tS, *t = &tS;
                        t->tv_sec = 0;
                        t->tv_nsec = 020000000;
@@ -94,7 +158,7 @@ void Hardware_waitForTrigger(Hardware *my, void *subEvt)
 void Hardware_readout(Hardware *my, void *subEvt)
 {
        HwRace_readSubEvt(my->race[my->raceToRead], subEvt);
-       if (++my->raceToRead == NRACES ) {
+       if (++my->raceToRead == NRACES) {
                my->raceToRead = 0;
        }
 }
index 635ee0c9fb3710a51453d7e733edff1a18a08f22..74e1ef1ccd7b1b2f57b56804ec9a44fd5a244102 100644 (file)
@@ -1,4 +1,4 @@
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.8 1999-11-22 09:00:48 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.9 2000-02-03 18:06:04 muench Stab $";
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
@@ -96,13 +96,13 @@ void main(int argc, char *argv[])
                HadTuQueue *hadTuQueue;
                Worker_dump(worker, 1);
 
-               hadTu = ShmTrans_alloc(shmTrans, 64 * 1024);
+               hadTu = ShmTrans_alloc(shmTrans, 60 * 1024);
 #ifndef NDEBUG
                msglog(LOG_DEBUG,
                        "shmTrans: %p = hadTu: %s\n", hadTu, HadTu_2charP(hadTu));
 #endif
                hadTuQueue = allocMem(HadTuQueue_sizeOf());
-               conHadTuQueue(hadTuQueue, hadTu, 64 * 1024);
+               conHadTuQueue(hadTuQueue, hadTu, 60 * 1024);
                while (NULL != (subEvt = HadTuQueue_alloc(hadTuQueue, Hardware_maxSubEvtSize(hw)))) {
                        Hardware_waitForTrigger(hw, subEvt);