static void __download() { int i1, i2, i3; char *ch, tmp[64]; #ifdef POLLING_MODE rol->poll = 1; #else rol->poll = 0; #endif printf("\n>>>>>>>>>>>>>>> ROCID=%d, CLASSID=%d <<<<<<<<<<<<<<<<\n",rol->pid,rol->classid); printf("CONFFILE >%s<\n\n",rol->confFile); printf("LAST COMPILED: %s %s\n", __DATE__, __TIME__); printf("USRSTRING >%s<\n\n",rol->usrString); /* if slave, get fiber port number from user string */ #ifdef TI_SLAVE ti_slave_fiber_port = 1; /* default */ ch = strstr(rol->usrString,"fp="); if(ch != NULL) { strcpy(tmp,ch+strlen("fp=")); printf("tmp >>>>>>>>>>>>>>>>>>>>>%s<<<<<<<<<<<<<<<<<<<<<\n",tmp); ti_slave_fiber_port = atoi(tmp); printf("ti_slave_fiber_port =%d\n",ti_slave_fiber_port); tiSetFiberIn_preInit(ti_slave_fiber_port); } #endif /* printf("rol1: downloading DDL table ...\n"); clonbanks_(); printf("rol1: ... done.\n"); */ /**/ CTRIGINIT; /* initialize OS windows and TI board */ #ifdef VXWORKS CDOINIT(TIPRIMARY); #else CDOINIT(TIPRIMARY,TIR_SOURCE); #endif /************/ /* init daq */ daqInit(); DAQ_READ_CONF_FILE; /*************************************/ /* redefine TI settings if neseccary */ #ifndef TI_SLAVE /* TS 1-6 create physics trigger, no sync event pin, no trigger 2 */ vmeBusLock(); tiLoadTriggerTable(3); tiSetTriggerWindow(14); // (7+1)*4ns trigger it coincidence time to form trigger type /* tiSetTriggerHoldoff(1,20,1); tiSetTriggerHoldoff(2,0,1); tiSetTriggerHoldoff(3,0,1); tiSetTriggerHoldoff(4,0,1); */ // tiAddSlave(7); // tiAddSlave(8); vmeBusUnlock(); #endif /*********************************************************/ /*********************************************************/ #ifdef USE_PRAD /* (width + 3)*4 ns, 300 ns width */ vmeBusLock(); tiSetPromptTriggerWidth(60); int ii; for(ii = 1; ii <= 6; ++ii) tiSetTSInputDelay(ii, 0); vmeBusUnlock(); #endif /* set wide pulse */ vmeBusLock(); /*sergey: WAS tiSetSyncDelayWidth(1,127,1);*/ /*worked for bit pattern latch tiSetSyncDelayWidth(0x54,127,1);*/ vmeBusUnlock(); usrVmeDmaSetConfig(2,5,1); /*A32,2eSST,267MB/s*/ /*usrVmeDmaSetConfig(2,5,0);*/ /*A32,2eSST,160MB/s*/ /*usrVmeDmaSetConfig(2,3,0);*/ /*A32,MBLT*/ /* if(rol->pid==18) { usrVmeDmaSetConfig(2,3,0); } */ /* usrVmeDmaSetChannel(1); printf("===== Use DMA Channel %d\n\n\n",usrVmeDmaGetChannel()); */ tdcbuf = (unsigned int *)i2_from_rol1; /******************/ /* USER code here */ #ifdef USE_PRAD vmeBusLock(); dsc2Init(0x400000,0x80000,5,0/*1<<19*/); ndsc2 = dsc2GetNdsc(); printf("!!!!!!!!!!! ndsc2=%d\n",ndsc2); if(ndsc2>0) { DSC2_READ_CONF_FILE; ndsc2_daq = dsc2GetNdsc_daq(); printf("!!!!!!!!!!! ndsc2_daq=%d\n",ndsc2_daq); } printf("Set Gate Source... \n"); dsc2SetGateSource(9, 1, 1); //dsc2SetGateSource(9, 2, 3); /* dsc2Init(0x480000,0x80000,5,1<<19); int dsc_ch, dsc_sl; for(dsc_ch = 0; dsc_ch < 6; ++dsc_ch) dsc2SetThreshold(0, dsc_ch, 100, TDCTRG); for(dsc_sl = 1; dsc_sl < 5; ++dsc_sl) { dsc2SetDelay(dsc_sl, 0, 3); for(dsc_ch = 0; dsc_ch < 16; ++dsc_ch) dsc2SetThreshold(dsc_sl, dsc_ch, 10, TDCTRG); } dsc2SetChannelMask(0,0xffff,TDCTRG); dsc2SetChannelORMask(0,0xffff,TDCTRG); dsc2Status(0,0); */ vmeBusUnlock(); #ifdef USE_V767 /***************** * V767 SETUP *****************/ /*vmeBusLock();*/ v767Init(V767_ADDR1,V767_OFF,1,0); // turn off test mode v767WriteMicro(0, 0x0200); /* select stop trigger matching, substraction of trigger time, all channels on, autoload on, and save configuration */ // v767SetAcqMode(0,0); // v767SetDReadyMode(0,0); /* v767BusErrEnable(0); */ /* v767SetBLKEndMode(0, 1); */ /* v767AutoloadDisable(itdc); */ /* v767AddrRotary(itdc); */ // v767SetEdgeDetectionMode(0,1); /* v767OverlapTrigDisable(itdc); */ v767TriggerConfig(0,2000,1000,0); /* v767ChannelMask(itdc,channelmask); */ v767Status(0, 0, 0); // v767TriggerConfig(0,0,0,0); /* Print current trigger config */ printf("v767 8\n");fflush(stdout); /*vmeBusUnlock();*/ /* v767SaveConfig(itdc); */ #endif #ifdef USE_V1190 vmeBusLock(); tdc1190Init(V1190_ADDR1, V1190_OFF, 1, 0); TDC_READ_CONF_FILE; vmeBusUnlock(); #endif #endif /* USE_PRAD */ sprintf(rcname,"RC%02d",rol->pid); printf("rcname >%4.4s<\n",rcname); #ifdef SSIPC sprintf(ssname,"%s_%s",getenv("HOST"),rcname); printf("Smartsockets unique name >%s<\n",ssname); epics_msg_sender_init(getenv("EXPID"), ssname); /* SECOND ARG MUST BE UNIQUE !!! */ #endif logMsg("INFO: User Download Executed\n",1,2,3,4,5,6); }
static void __download() { int ii, i1, i2, i3, id, slot; char filename[1024]; #ifdef POLLING_MODE rol->poll = 1; #else rol->poll = 0; #endif printf("\n>>>>>>>>>>>>>>> ROCID=%d, CLASSID=%d <<<<<<<<<<<<<<<<\n",rol->pid,rol->classid); printf("CONFFILE >%s<\n\n",rol->confFile); printf("LAST COMPILED: %s %s\n", __DATE__, __TIME__); printf("USRSTRING >%s<\n\n",rol->usrString); /**/ CTRIGINIT; /* initialize OS windows and TS board */ #ifdef VXWORKS CDOINIT(TSPRIMARY); #else CDOINIT(TSPRIMARY,TIR_SOURCE); #endif /************/ /* init daq */ daqInit(); DAQ_READ_CONF_FILE; /*************************************/ /* redefine TS settings if neseccary */ tsSetUserSyncResetReceive(1); /* TS 1-6 create physics trigger, no sync event pin, no trigger 2 */ vmeBusLock(); /*tsLoadTriggerTable();*/ /*tsSetTriggerWindow(7);TS*/ // (7+1)*4ns trigger it coincidence time to form trigger type vmeBusUnlock(); /*********************************************************/ /*********************************************************/ /* set wide pulse */ vmeBusLock(); /*sergey: WAS tsSetSyncDelayWidth(1,127,1);*/ /*worked for bit pattern latch tsSetSyncDelayWidth(0x54,127,1);*/ vmeBusUnlock(); usrVmeDmaSetConfig(2,5,1); /*A32,2eSST,267MB/s*/ /*usrVmeDmaSetConfig(2,5,0);*/ /*A32,2eSST,160MB/s*/ /*usrVmeDmaSetConfig(2,3,0);*/ /*A32,MBLT*/ tdcbuf = (unsigned int *)i2_from_rol1; /******************/ /* USER code here */ /* TD setup */ ntd = 0; tdInit((3<<19),0x80000,20,0); ntd = tdGetNtds(); /* actual number of TD boards found */ tdGSetBlockLevel(block_level); tdGSetBlockBufferLevel(buffer_level); //tdAddSlave(17,2); // TI Slave - Bottom Crate (payload) //tdAddSlave(17,5); // TI Slave - Bench (GTP) tdslotmask = 0; for(id=0; id<ntd; id++) { slot = tdSlot(id); tdslotmask |= (1<<slot); printf("=======================> tdslotmask=0x%08x\n",tdslotmask); } printf("TDSLOTMASK: tdslotmask=0x%08x (from library 0x%08x)\n",tdslotmask,tdSlotMask()); sprintf(filename,"%s/portnames_%s.txt",getenv("CLON_PARMS"),getenv("EXPID")); printf("loading portnames from file >%s<\n",filename); tdLoadPortNames(filename); /* tdGStatus(0); */ /*************************************** * SD SETUP ***************************************/ printf("SD init starts\n"); vmeBusLock(); printf("SD init 1\n"); sdInit(1); /* Initialize the SD library */ sdSetActiveVmeSlots(tdslotmask); /* Use the tdslotmask to configure the SD */ sdStatus(); vmeBusUnlock(); printf("SD init done\n"); /* if TDs are present, set busy from SD board */ if(ntd>0) { printf("Set BUSY from SWB for TDs\n"); vmeBusLock(); tsSetBusySource(TS_BUSY_SWB,0); vmeBusUnlock(); } /*sergey: following piece from tsConfig.c, doing it there not always propagate correct block_level to slaves; doing it again here seems helps, have to investigate */ tsSetInstantBlockLevelChange(1); /* enable immediate block level setting */ printf("trig1: setting block_level = %d\n",block_level); sleep(1); tsSetBlockLevel(block_level); sleep(1); tsSetInstantBlockLevelChange(0); /* disable immediate block level setting */ sprintf(rcname,"RC%02d",rol->pid); printf("rcname >%4.4s<\n",rcname); #ifdef SSIPC sprintf(ssname,"%s_%s",getenv("HOST"),rcname); printf("Smartsockets unique name >%s<\n",ssname); epics_msg_sender_init(getenv("EXPID"), ssname); /* SECOND ARG MUST BE UNIQUE !!! */ #endif logMsg("INFO: User Download Executed\n",1,2,3,4,5,6); }