Changeset 110
- Timestamp:
- 09/23/09 11:05:41 (15 years ago)
- Location:
- drsdaq
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DAQReadout.cc
r99 r110 35 35 {"take", &DAQReadout::cmd_take, false, "<d|p|t> [n] [source]", "Start run (data, pedestal or test) with n events"}, 36 36 {"events", &DAQReadout::cmd_events, false, "", "Number of events in current run"}, 37 {"start", &DAQReadout::cmd_start, true, "", "Start domino wave"},37 {"start", &DAQReadout::cmd_start, true, "", "Start DRS and DAQ without disk writing (feedback will be called)"}, 38 38 {"stop", &DAQReadout::cmd_stop, false, "", "Issue soft trigger and stop DAQ"}, 39 39 {"test", &DAQReadout::cmd_test, true, "[2e]<blt32|blt64> [n]", "Test read access of VMEbus (n blocks)"}, … … 71 71 CalibrationRead = false; 72 72 NumEvents = 0; 73 NumEventsRequested = 100;73 NumEventsRequested = 0; 74 74 NumBoards = 0; 75 75 FirstBoard = 0; … … 306 306 StartDRS(); 307 307 PrintMessage("Domino wave started\n"); 308 309 // Create DAQ thread 310 if ((pthread_create(&thread_DAQ_Silent, NULL, (void * (*)(void *)) DAQ_Silent,(void *) this)) != 0) 311 PrintMessage("pthread_create failed with DAQ_Silent thread (%s)\n",strerror(errno)); 312 else { 313 daq_state = active; 314 Stop = false; 315 pthread_detach(thread_DAQ_Silent); 316 } 308 317 } 309 318 } … … 1035 1044 // Print message to selected target 1036 1045 void DAQReadout::PrintMessage(int Target, const char *Format, ...) { 1046 1037 1047 va_list ArgumentPointer; 1038 1048 va_start(ArgumentPointer, Format); 1039 PrintMessage( Target, Format, ArgumentPointer);1049 PrintMessage(Format, ArgumentPointer, Target); 1040 1050 va_end(ArgumentPointer); 1041 1051 } … … 1045 1055 va_list ArgumentPointer; 1046 1056 va_start(ArgumentPointer, Format); 1047 if(CmdFromSocket) PrintMessage( MsgToSocket|MsgToLog, Format, ArgumentPointer);1048 else PrintMessage( MsgToConsole|MsgToLog, Format, ArgumentPointer);1057 if(CmdFromSocket) PrintMessage(Format, ArgumentPointer, MsgToSocket|MsgToLog); 1058 else PrintMessage(Format, ArgumentPointer, MsgToConsole|MsgToLog); 1049 1059 va_end(ArgumentPointer); 1050 1060 } 1051 1061 1052 1062 // Function doing the actual printing work 1053 void DAQReadout::PrintMessage(int Target, const char *Format, va_list ArgumentPointer) { 1054 1055 char Textbuffer[MAX_COM_SIZE]; 1063 // It is important that Target is here the last argument, otherwise 1064 // there can be confusion with the variadic versions (this function is 1065 // called instead of PrintMessage(int, const char *, ...) 1066 void DAQReadout::PrintMessage(const char *Format, va_list ArgumentPointer, int Target) { 1067 1068 static char Textbuffer[MAX_COM_SIZE]; // static: it is only allocated once 1056 1069 1057 1070 memset(Textbuffer, 0, sizeof(Textbuffer)); … … 1068 1081 // Print to log file 1069 1082 if((Target & MsgToLog) && Logfile!=NULL) { 1070 fprintf(Logfile, "%s", Textbuffer); 1083 time_t Time; 1084 strftime(Textbuffer+strlen(Textbuffer)+1,MAX_COM_SIZE-strlen(Textbuffer)-1, "%d/%m/%y %X", localtime(&(Time=time(NULL)))); 1085 fprintf(Logfile, "%s: %s", Textbuffer+strlen(Textbuffer)+1, Textbuffer); 1071 1086 fflush(Logfile); 1072 1087 } … … 1183 1198 m->HVFB->ClearAverages(); 1184 1199 gettimeofday(&StartTime, NULL); 1185 m->PrintMessage("\rStarting run #%d (%s) on \"%s\" with %u event(s)\n",m->RunNumber,daq_runtype_str[m->daq_runtype],m->RHeader->Description,m->NumEventsRequested);1200 m->PrintMessage("\rStarting run #%d (%s) with %u event(s)\n",m->RunNumber,daq_runtype_str[m->daq_runtype],m->NumEventsRequested); 1186 1201 1187 1202 do { … … 1265 1280 m->daq_state = stopped; 1266 1281 } 1282 1283 1284 /********************************************************************\ 1285 1286 DAQ Thread - no disk writing, only hardware trigger, for feedback tests 1287 1288 \********************************************************************/ 1289 1290 void DAQ_Silent(DAQReadout *m) { 1291 1292 m->PrintMessage("\rData taking started\n"); 1293 do { 1294 // Start DRS and wait for hardware trigger 1295 m->StartDRS(); 1296 while (m->IsDRSBusy()); 1297 1298 // Read event data via VME and call feedback 1299 m->ReadCalibratedDRSData(); 1300 m->HVFB->ProcessEvent(); 1301 } while(!m->Stop); 1302 1303 m->PrintMessage("\rData taking stopped\n"); 1304 m->daq_state = stopped; 1305 } -
drsdaq/DAQReadout.h
r99 r110 33 33 class DAQReadout { 34 34 time_t StartTime; 35 DRS *drs; 35 36 36 pthread_t thread_DAQ; 37 pthread_t thread_DAQ_Silent; 38 37 39 unsigned int CmdNumber; 38 40 FILE *Logfile; … … 44 46 EventHeader* EHeader; 45 47 48 DRS *drs; 49 46 50 short (*WaveForm)[kNumberOfChips][kNumberOfChannels][kNumberOfBins]; 47 51 int (*TriggerCell)[kNumberOfChips]; … … 127 131 void PrintMessage(int, const char*, ...); 128 132 void PrintMessage(const char*, ...); 129 void PrintMessage( int, const char*, va_list);133 void PrintMessage(const char*, va_list, int); 130 134 bool OpenRawFile(); 131 135 bool WriteRunHeader(); … … 135 139 136 140 void DAQ(DAQReadout *); 141 void DAQ_Silent(DAQReadout *); 137 142 138 143 bool Match(const char*, const char*); -
drsdaq/HVFeedback.cc
r99 r110 99 99 if (SocketDescriptor!=-1) { 100 100 close(SocketDescriptor); 101 m->PrintMessage("Fee back socket closed.\n");101 m->PrintMessage("Feedback socket closed.\n"); 102 102 } 103 103 delete[] Average; delete[] Response; … … 123 123 for (k=0; k<kNumberOfChannels; k++) { 124 124 for (Integral=0, q=-fIntHalfWidth; q<=(int) fIntHalfWidth; q++) 125 Integral += (m->WaveForm[i][j][k][(fLedSignalSample+q+m->TriggerCell[i][j])%kNumberOfBins] - m->WaveForm[i][j][k][(fLedBaselineSample+q+m->TriggerCell[i][j])%kNumberOfBins])*m-> BStruct[i].ScaleFactor;125 Integral += (m->WaveForm[i][j][k][(fLedSignalSample+q+m->TriggerCell[i][j])%kNumberOfBins] - m->WaveForm[i][j][k][(fLedBaselineSample+q+m->TriggerCell[i][j])%kNumberOfBins])*m->drs->GetBoard(i)->GetPrecision(); 126 126 Integral /= 2*fIntHalfWidth+1; 127 127 Average[i][j][k] += Integral; -
drsdaq/History.txt
r99 r110 51 51 initialisation steps) 52 52 10/8/2009 Socket interface to hvcontrol only checks, if first reponse starts with 53 'OK', otherwise assumes command to hvcontrol failed. 53 'OK', otherwise assumes command to hvcontrol failed. 54 22/9/2009 The 'start' command will now start the DAQ without disk writing, but 55 with invocation of the feedback. 56 23/9/2009 Fixed bug in RawDataCTX.cc: sequential event number in a file is only 57 the same as the event number in the run for the first file part -
drsdaq/RawDataCTX.cc
r68 r110 148 148 149 149 // Move file pointer to desired event header (if zero read next event) 150 bool SEEK_OK=true; 150 bool SEEK_OK = true; 151 unsigned int Count = 0; 152 151 153 if (EventNo!=0 && fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NBoards, SEEK_SET) != 0) SEEK_OK=false; 152 154 while(SEEK_OK) { … … 159 161 } 160 162 else { 161 if ( EHeader->EventNumber==EventNo || EventNo==0) break;163 if ((Count++) == EventNo) break; 162 164 if (fseek(Rawfile, EHeader->EventSize, SEEK_CUR) != 0) SEEK_OK = false; 163 165 } -
drsdaq/drsdaq.cpp
r92 r110 138 138 void ConsoleCommand(DAQReadout *m) { 139 139 140 time_t Time; 141 char *Command, Buf[MAX_COM_SIZE];; 140 char *Command; 142 141 143 142 while (!m->Exit) { … … 150 149 // Read Command 151 150 Command = readline(m->Prompt); 152 if (Command ==NULL) {151 if (Command == NULL) { 153 152 m->PrintMessage("Error reading command line input\n"); 154 153 continue; … … 157 156 158 157 // Log command 159 strftime(Buf,MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL)))); 160 m->PrintMessage(MsgToLog, "CONSOLE(%s)> %s\n", Buf, Command); 158 m->PrintMessage(MsgToLog, "CONSOLE> %s\n", Command); 161 159 162 160 // Process command … … 192 190 struct hostent *ClientName; 193 191 socklen_t SizeClientAddress=sizeof(ClientAddress); 194 char Command[MAX_COM_SIZE], Buf[MAX_COM_SIZE]; 195 time_t Time; 192 char Command[MAX_COM_SIZE]; 196 193 197 194 // Set up server socket … … 248 245 249 246 // Log command 250 strftime(Buf, MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL)))); 251 m->PrintMessage(MsgToConsole|MsgToLog, "SOCKET(%s)> %s\n", Buf, Command); 247 m->PrintMessage(MsgToConsole|MsgToLog, "SOCKET> %s\n", Command); 252 248 253 249 // Process command
Note:
See TracChangeset
for help on using the changeset viewer.