]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Mathias updated readout, short test run
authorhades <hades>
Wed, 11 Apr 2001 12:56:18 +0000 (12:56 +0000)
committerhades <hades>
Wed, 11 Apr 2001 12:56:18 +0000 (12:56 +0000)
hadaq/hwshow.c

index f16363f8ed74ebfd26d502b6f3c3b426be9452a1..319c40784aa9f13eeb0a13074feb66317dd324d0 100644 (file)
@@ -1,9 +1,10 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.15 2001-03-07 16:02:44 hades Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.16 2001-04-11 12:56:18 hades Exp $";
 
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
 
+#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h> 
@@ -19,7 +20,6 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada
 struct HardwareS {
        size_t maxSubEvtSize;
        HwShip *ship[NSHIPS];
-       unsigned shipToRead;
 };
 
 #include "hardware.h"
@@ -47,7 +47,6 @@ Hardware *newHardware(void)
        my = allocMem(sizeof(Hardware));
 
        my->maxSubEvtSize = SubEvt_hdrSize() + (NSHIPS * 1600 * sizeof(UInt4));
-       my->shipToRead = 0;
 
        for (i = 0; i < NSHIPS; i++) {
                char buf[16];
@@ -79,38 +78,61 @@ void deleteHardware(Hardware *my)
 
 void Hardware_waitForTrigger(Hardware *my, void *subEvt)
 {
+       int i;
+
+       for (i = 0; i < NSHIPS; i++) {
+               if (HwShip_isEmpty(my->ship[i])) {
+                       HwShip_requestBuffer(my->ship[i]);
+               }
+       }
+
+       for (i = 0; i < NSHIPS; i++) {
+               while (HwShip_isBusy(my->ship[i])) {
+#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;
+                       nanosleep(t, NULL);
+#endif
+               }
+       }
 }
 
 void Hardware_readout(Hardware *my, void *partEvt)
 {
+       int i;
        void *subEvt = SubEvt_data(partEvt);
+       static UInt4 trigNr = 0;
+       UInt4 trigTag;
 
+       /* init partial event, necessary for  SubEvt_next() */
        SubEvt_setDecoding(partEvt, SubEvtDecoding_SubEvts);
+       SubEvt_setId(partEvt, 0);
 
-       for (my->shipToRead = 0; my->shipToRead < NSHIPS; my->shipToRead++) {
-               if (HwShip_isEmpty(my->ship[my->shipToRead])) {
-                       HwShip_requestBuffer(my->ship[my->shipToRead]);
-                       while (HwShip_isBusy(my->ship[my->shipToRead])) {
-#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;
-                               nanosleep(t, NULL);
-#endif
+       /* read all ships, check for common trigger tag */
+       for (i = 0; i < NSHIPS; i++) {
+               HwShip_readSubEvt(my->ship[i], subEvt);
+               if (i == 0) {
+                       trigTag = SubEvt_trigNr(subEvt);
+               } else {
+                       if (trigTag != SubEvt_trigNr(subEvt)) {
+                               msglog(LOG_ERR, "(%s)Trigger tag mismatch: 0x%08x != 0x%08x\n",
+                                       my->ship[i]->name,trigTag, SubEvt_trigNr(subEvt));
                        }
                }
-               HwShip_readSubEvt(my->ship[my->shipToRead], subEvt);
-               SubEvt_setTrigNr(partEvt, SubEvt_trigNr(subEvt));
                subEvt = SubEvt_next(partEvt, subEvt);
        }
 
+    SubEvt_setTrigNr(partEvt, trigNr << 8 | trigTag);
        SubEvt_setSize(partEvt, (char *)subEvt - (char *)partEvt);
-       SubEvt_setId(partEvt, 0);
+    trigNr++;
+
+       assert(SubEvt_size(partEvt) <= my->maxSubEvtSize);
 #ifndef NDEBUG
        msglog(LOG_DEBUG, "partEvt: %s\n", SubEvt_2charP(partEvt));
 #endif