]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
optimized code (omits empty subevents, minimized communication overhead with
authorhadaq <hadaq>
Thu, 23 May 2002 16:53:27 +0000 (16:53 +0000)
committerhadaq <hadaq>
Thu, 23 May 2002 16:53:27 +0000 (16:53 +0000)
ships. Needs new hwship.h. W.K.

hadaq/hwship.c

index 5cd2f004155cff50c168138bd248a2c80fc8128b..cc3325d80327b1149de83adde6bd03f312c0f846 100644 (file)
@@ -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 <assert.h>
 #include <string.h>
@@ -12,24 +12,8 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada
 
 #include <allParam.h>
 
-#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