Esempio n. 1
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;
}       
Esempio n. 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);
}
Esempio n. 3
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;
}