예제 #1
0
static void
__end()
{
  int iwait=0;
  int blocksLeft=0;
  int id;

  printf("\n\nINFO: End1 Reached\n");fflush(stdout);

  CDODISABLE(TSPRIMARY,TIR_SOURCE,0);

  /* Before disconnecting... wait for blocks to be emptied */
vmeBusLock();
  blocksLeft = tsBReady();
vmeBusUnlock();
  printf(">>>>>>>>>>>>>>>>>>>>>>> %d blocks left on the TS\n",blocksLeft);fflush(stdout);
  if(blocksLeft)
  {
    printf(">>>>>>>>>>>>>>>>>>>>>>> before while ... %d blocks left on the TS\n",blocksLeft);fflush(stdout);
    while(iwait < 10)
	{
      taskDelay(10);
	  if(blocksLeft <= 0) break;
vmeBusLock();
	  blocksLeft = tsBReady();
      printf(">>>>>>>>>>>>>>>>>>>>>>> inside while ... %d blocks left on the TS\n",blocksLeft);fflush(stdout);
vmeBusUnlock();
	  iwait++;
	}
    printf(">>>>>>>>>>>>>>>>>>>>>>> after while ... %d blocks left on the TS\n",blocksLeft);fflush(stdout);
  }



vmeBusLock();
  tsStatus(1);
vmeBusUnlock();

  printf("INFO: End1 Executed\n\n\n");fflush(stdout);

  return;
}
예제 #2
0
int 
main(int argc, char *argv[]) {

    int stat;

    printf("\nJLAB TS Tests\n");
    printf("----------------------------\n");

    vmeOpenDefaultWindows();

  /* Setup Address and data modes for DMA transfers
   *   
   *  vmeDmaConfig(addrType, dataType, sstMode);
   *
   *  addrType = 0 (A16)    1 (A24)    2 (A32)
   *  dataType = 0 (D16)    1 (D32)    2 (BLK32) 3 (MBLK) 4 (2eVME) 5 (2eSST)
   *  sstMode  = 0 (SST160) 1 (SST267) 2 (SST320)
   */
    vmeDmaConfig(2,5,1);

    /* INIT dmaPList */

    dmaPFreeAll();
    vmeIN  = dmaPCreate("vmeIN",1024,500,0);
    vmeOUT = dmaPCreate("vmeOUT",0,0,0);
    
    dmaPStatsAll();

    dmaPReInitAll();

    tsReload();

/*     gefVmeSetDebugFlags(vmeHdl,0x0); */
    /* Set the TS structure pointer */
    tsPartInit(1,(21<<19),TS_READOUT_EXT_POLL,0);
    if(tsCheckAddresses()==ERROR)
      goto CLOSE;

    tsPartLoadTriggerTable();
    tsPartSetBlockBufferLevel(10);    

    tsSetBlockLevel(1);

    stat = tsPartIntConnect(mytsISR, 0);
    if (stat != OK) 
      {
	printf("ERROR: tsIntConnect failed \n");
	goto CLOSE;
      } 
    else 
      {
	printf("INFO: Attached TS Interrupt\n");
      }

    tsSetTriggerSource(6); // Pulser = 5, GTP/Ext/FP = 6

    tsSetFPInput(0);
    tsSetGenInput(0xffff);
    tsSetGTPInput(0x0);

    tsPartSetFPInput(1,2,3);
    tsPartSetExtInput(1,2,3,4,5);
    tsPartSetGTPInput(1,2,3,4,5);

/*     tsSetBusySource(TS_BUSY_LOOPBACK,1); */
    tsSetBusySource(0,1);

/*     tsSetBlockBufferLevel(1); */

    tsClockReset();
    taskDelay(1);
    tsTrigLinkReset();
    taskDelay(1);
    tsSyncReset();

    taskDelay(1);
    
    tsStatus();

    printf("Hit enter to start triggers\n");
    getchar();

    tsPartIntEnable(0);
    tsStatus();

/* #define SOFTTRIG */
#ifdef SOFTTRIG
    tsSetRandomTrigger(1,0x7);
    taskDelay(10);
    tsSoftTrig(1,0x1,0x700,0);
#endif

    printf("Hit any key to Disable TID and exit.\n");
    getchar();
    tsStatus();
    tsPrintScalers(1);
    tsPrintScalers(2);
    tsPrintScalers(3);

#ifdef SOFTTRIG
    /* No more soft triggers */
/*     tidSoftTrig(0x0,0x8888,0); */
    tsSoftTrig(1,0,0x700,0);
    tsDisableRandomTrigger();
#endif

    tsPartIntDisable();

    tsPartIntDisconnect();


 CLOSE:

    vmeCloseDefaultWindows();

    exit(0);
}
예제 #3
0
void FOEFinder::bin2(VelocityBuffer & data){
    int size, x,y, xs, xe, ys, ye, i, j;
    double aFlow, radian, vx, vy, a1, a2, b1, b2, dtmp1, dtmp2;
    double a3, b3;

    static unsigned long prevTS = 0;

    radian = NGHBR_RADIAN; // angle between two consequative lines
    size = data.getSize();

    unsigned long tmpTS = data.getTs(0);


    double leakyFactor = exp( LEAK_RATE * (tmpTS -  prevTS));
    //leak the values
    for (int i = 0; i < X_DIM; ++i) {
       for (int j = 0; j < Y_DIM; ++j) {
           foeMap(i,j) = /*exp( LEAK_RATE * (tmpTS - tsStatus(i,j)) )*/leakyFactor * foeMap(i,j); //LEAK_RATE * foeMap(i,j);
           tsStatus(i,j) = tmpTS;
       }
    }

    //Leaky Integaration
    for (int cntr = 0; cntr < size; ++cntr) {
        x = data.getX(cntr);
        y = data.getY(cntr);
        vx = data.getVx(cntr);
        vy = data.getVy(cntr);

        if (vx == 0 && vy ==0)
             continue;

        aFlow = atan2(vy, vx);
        //Calculate the slope of the flow
        a2 = tan(aFlow + radian);
        a1 = tan(aFlow - radian);
        b2 = y - a2 * x;
        b1 = y - a1 * x;

        //positive weight
        xs = 0; xe = x;
        if (vx < 0){
           xs = x; xe = X_DIM;
        }
        for (i = xs; i < xe; ++i) {
           dtmp1 = a1 * i + b1;
           dtmp2 = a2 * i + b2;
           ys =  dtmp1 + dtmp2 - fabs(dtmp1 - dtmp2); ys = ys /2;// ys is set to min(dtmp1, dtmp2)
           ye =  dtmp1 + dtmp2 + fabs(dtmp1 - dtmp2); ye = ye /2;// ye is set to max(dtmp1, dtmp2)
           if (ys >= 128 || ye < 0)
               continue;
           for (j = ys; j < ye; ++j) {
              if (j < 0 || j >= 128)
                  continue;
//              foeMap(i,j) *= exp( LEAK_RATE* (data.getTs(cntr) - tsStatus(i,j)) );
              foeMap(i,j) +=   .1; //1000*sqrt(vx*vx + vy*vy); // 1 ;
              tsStatus(i,j) = data.getTs(cntr);
           } // end on y -coordinate
       } // end on x -coordinate

//          cout << x << " " << y << " " << vx << " " << vy << " " << data.getTs(cntr) << endl;

   }// end of loop on events


   prevTS = tmpTS;
}
예제 #4
0
static void
__prestart()
{
  int ii, i1, i2, i3;
  int ret;

  /* Clear some global variables etc for a clean start */
  *(rol->nevents) = 0;
  event_number = 0;

  /*tsEnableVXSSignals();TS*/

#ifdef POLLING_MODE
  CTRIGRSS(TSPRIMARY, TIR_SOURCE, usrtrig, usrtrig_done);
#else
  CTRIGRSA(TSPRIMARY, TIR_SOURCE, usrtrig, usrtrig_done);
#endif



  /**************************************************************************/
  /* setting TS busy conditions, based on boards found in Download          */
  /* tsInit() does nothing for busy, tsConfig() sets fiber, we set the rest */
  /* NOTE: if ts is busy, it will not send trigger enable over fiber, since */
  /*       it is the same fiber and busy has higher priority                */

vmeBusLock();
  tsSetBusySource(TS_BUSY_LOOPBACK,0);
  /*tsSetBusySource(TS_BUSY_FP,0);*/
vmeBusUnlock();












  /*****************************************************************/
  /*****************************************************************/





  /* USER code here */
  /******************/

vmeBusLock();
  tsIntDisable();
vmeBusUnlock();



  /* NOT USED !!!!!!!!!!!!!!!!!!!!
vmeBusLock();
  tsSyncReset(1);
vmeBusUnlock();
  sleep(1);

vmeBusLock();
  ret = tsGetSyncResetRequest();
vmeBusUnlock();
  if(ret)
  {
    printf("ERROR: syncrequest still ON after tsSyncReset(); trying again\n");
    sleep(1);
vmeBusLock();

    tsSyncReset(1);

vmeBusUnlock();
    sleep(1);
  }
  */











  /* SYNC RESET - reset event number (and clear FIFOs) in TIs */

  sleep(1);
vmeBusLock();
  tsSyncReset(1); /* '1' will push 'next_block_level' to 'block_level' in slave TI's (not TD's !), we did it already in download */
vmeBusUnlock();
  sleep(1);




  /* USER RESET - use it because 'SYNC RESET' produces too short pulse, still need 'SYNC RESET' above because 'USER RESET'
  does not do everything 'SYNC RESET' does (in paticular does not reset event number) */

vmeBusLock();
  tsUserSyncReset(1);
  tsUserSyncReset(0);
vmeBusUnlock();












vmeBusLock();
  ret = tsGetSyncResetRequest();
vmeBusUnlock();
  if(ret)
  {
    printf("ERROR: syncrequest still ON after tsSyncReset(); try 'tcpClient <rocname> tsSyncReset'\n");
  }
  else
  {
    printf("INFO: syncrequest is OFF now\n");
  }

  printf("holdoff rule 1 set to %d\n",tsGetTriggerHoldoff(1));
  printf("holdoff rule 2 set to %d\n",tsGetTriggerHoldoff(2));


/* set block level in all boards where it is needed;
   it will overwrite any previous block level settings */


/*
#ifdef USE_VSCM
  for(ii=0; ii<nvscm1; ii++)
  {
    slot = vscmSlot(ii);
vmeBusLock();
    vscmSetBlockLevel(slot, block_level);
vmeBusUnlock();
  }
#endif
*/



/*
  {
  char portfile[1024];
  sprintf(portfile,"%s/portnames_%s.txt",getenv("CLON_PARMS"),getenv("EXPID"));
  printf("Loading port names from file >%s<\n",portfile);
  tdLoadPortNames(portfile);
  }
*/


vmeBusLock();
  tsStatus(1);
vmeBusUnlock();


vmeBusLock();
  ret = tdGStatus(block_level);
vmeBusUnlock();
  if(ret)
  {
    logMsg("ERROR: Go 1: WRONG BLOCK_LEVEL, START NEW RUN FROM 'CONFIGURE !!!\n",1,2,3,4,5,6);
    logMsg("ERROR: Go 1: WRONG BLOCK_LEVEL, START NEW RUN FROM 'CONFIGURE !!!\n",1,2,3,4,5,6);
    logMsg("ERROR: Go 1: WRONG BLOCK_LEVEL, START NEW RUN FROM 'CONFIGURE !!!\n",1,2,3,4,5,6);
    UDP_user_request(MSGERR, "rol1", "WRONG BLOCK_LEVEL, START NEW RUN FROM 'CONFIGURE !!!");
  }
  else
  {
    UDP_user_request(0, "rol1", "BLOCK_LEVEL IS OK");
  }


  printf("INFO: Prestart1 Executed\n");fflush(stdout);

  *(rol->nevents) = 0;
  rol->recNb = 0;

  return;
}       
예제 #5
0
static void
__prestart()
{
  int ii, i1, i2, i3;
  int ret;

  /* Clear some global variables etc for a clean start */
  *(rol->nevents) = 0;
  event_number = 0;

  /*tsEnableVXSSignals();TS*/

#ifdef POLLING_MODE
  CTRIGRSS(TSPRIMARY, TIR_SOURCE, usrtrig, usrtrig_done);
#else
  CTRIGRSA(TSPRIMARY, TIR_SOURCE, usrtrig, usrtrig_done);
#endif



  /**************************************************************************/
  /* setting TS busy conditions, based on boards found in Download          */
  /* tsInit() does nothing for busy, tsConfig() sets fiber, we set the rest */
  /* NOTE: if ts is busy, it will not send trigger enable over fiber, since */
  /*       it is the same fiber and busy has higher priority                */

vmeBusLock();
  tsSetBusySource(TS_BUSY_LOOPBACK,0);
  /*tsSetBusySource(TS_BUSY_FP,0);*/
vmeBusUnlock();












  /*****************************************************************/
  /*****************************************************************/





  /* USER code here */
  /******************/

vmeBusLock();
  tsIntDisable();
vmeBusUnlock();


  /* master and standalone crates, NOT slave */

  sleep(1);
vmeBusLock();
  tsSyncReset(1);
vmeBusUnlock();
  sleep(1);
vmeBusLock();
  tsSyncReset(1);
vmeBusUnlock();
  sleep(1);

vmeBusLock();
  ret = tsGetSyncResetRequest();
vmeBusUnlock();
  if(ret)
  {
    printf("ERROR: syncrequest still ON after tsSyncReset(); trying again\n");
    sleep(1);
vmeBusLock();
    tsSyncReset(1);
vmeBusUnlock();
    sleep(1);
  }

vmeBusLock();
  ret = tsGetSyncResetRequest();
vmeBusUnlock();
  if(ret)
  {
    printf("ERROR: syncrequest still ON after tsSyncReset(); try 'tcpClient <rocname> tsSyncReset'\n");
  }
  else
  {
    printf("INFO: syncrequest is OFF now\n");
  }

  printf("holdoff rule 1 set to %d\n",tsGetTriggerHoldoff(1));
  printf("holdoff rule 2 set to %d\n",tsGetTriggerHoldoff(2));


/* set block level in all boards where it is needed;
   it will overwrite any previous block level settings */


/*
#ifdef USE_VSCM
  for(ii=0; ii<nvscm1; ii++)
  {
    slot = vscmSlot(ii);
vmeBusLock();
    vscmSetBlockLevel(slot, block_level);
vmeBusUnlock();
  }
#endif
*/




vmeBusLock();
  tsStatus(1);
vmeBusUnlock();

  printf("INFO: Prestart1 Executed\n");fflush(stdout);

  *(rol->nevents) = 0;
  rol->recNb = 0;

  return;
}