From a7e20520e45c37730eef3cfdc680d36609425ef7 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 23 May 2002 16:53:27 +0000 Subject: [PATCH] optimized code (omits empty subevents, minimized communication overhead with ships. Needs new hwship.h. W.K. --- hadaq/hwship.c | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/hadaq/hwship.c b/hadaq/hwship.c index 5cd2f00..cc3325d 100644 --- a/hadaq/hwship.c +++ b/hadaq/hwship.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.19 2002-04-19 19:15:16 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.20 2002-05-23 16:53:27 hadaq Exp $"; #include #include @@ -12,24 +12,8 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada #include -#include "ipc_basis.h" #include "hwship.h" -static int bankRequested(HwShip *my) { - return my->bankRequested; -} - -static int bankConfirmed(HwShip *my) { - uint16_t val; - - val = LVme_tstBitL(my->lvme, LVL2_ACCESS_VMEREG, 7); - return val; -} - -static int endOfData(HwShip *my) { - return (LVme_getL(my->lvme, LVL2_OFFSET) - 2 + LVL2_OFFSET); -} - int conHwShip(HwShip * my, const char *name, const Param *param) { unsigned long cardBase; @@ -55,8 +39,8 @@ int conHwShip(HwShip * my, const char *name, const Param *param) /* Select VME-accessible register of LVL2-controller */ LVme_setW(my->lvme, LVL2_SEL_VMEREG, LVL2_SELMEM_VMEREG); - my->trigNr = 0; my->currAddr = 0x7fffffff; /* behind end of memory */ + my->endOfData = 0; return 0; } @@ -86,27 +70,31 @@ void HwShip_requestBuffer(HwShip *my) { LVme_setL(my->lvme, LVL2_ACCESS_VMEREG, i); my->bankRequested = i; my->currAddr = LVL2_DATASTART; -} -int HwShip_isBusy(HwShip *my) { - return bankRequested(my) != bankConfirmed(my); + /* to indicate a buffer request state which is cleared by getEndOfData */ + my->endOfData =0; } -int HwShip_isEmpty(HwShip *my) { - return my->currAddr >= endOfData(my); -} +#define SHIP_NODATASIZE 16 -int HwShip_readSubEvt(HwShip *my, void *subEvt) { - uint32_t *data = (uint32_t *)subEvt; +int HwShip_readSubEvt(HwShip *my, void *subEvt) +{ + uint32_t * data = (uint32_t *)subEvt; int lastAddr; - size_t size; + int currAddr = my->currAddr; + int size; + + size = LVme_getL(my->lvme, currAddr); + lastAddr = currAddr + size; + my->currAddr = lastAddr; + + /* skip empty subevent, nobody will realize this */ + if (size <= SHIP_NODATASIZE) return 1; - size = LVme_getL(my->lvme, my->currAddr); - lastAddr = my->currAddr + size; /* copy one sub evt from RC to memory */ *data++ = size; - while ((my->currAddr+=4) < lastAddr) { - *data++ = LVme_getL(my->lvme, my->currAddr); + while ((currAddr+=4) < lastAddr) { + *data++ = LVme_getL(my->lvme, currAddr); } #ifndef NDEBUG -- 2.43.0