From ff85bd5ae1901e186904929ad83a8d61892a1508 Mon Sep 17 00:00:00 2001 From: muench Date: Thu, 3 Feb 2000 18:02:46 +0000 Subject: [PATCH] *** empty log message *** --- hadaq/hwrich.c | 76 +++++++++++++++++++++++++++++++++++++++++++++---- hadaq/readout.c | 6 ++-- 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/hadaq/hwrich.c b/hadaq/hwrich.c index 2a13087..227b595 100644 --- a/hadaq/hwrich.c +++ b/hadaq/hwrich.c @@ -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 #include #include -#include +#include #include +#define SYNCHRONOUS + +#ifdef SYNCHRONOUS +#include + +#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 = ¶mS; 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; } } diff --git a/hadaq/readout.c b/hadaq/readout.c index 635ee0c..74e1ef1 100644 --- a/hadaq/readout.c +++ b/hadaq/readout.c @@ -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 @@ -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); -- 2.43.0