Changeset 110


Ignore:
Timestamp:
09/23/09 11:05:41 (15 years ago)
Author:
ogrimm
Message:
DAQ can run without writing data to disk, bug fix to RawDataCTX reading routine
Location:
drsdaq
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DAQReadout.cc

    r99 r110  
    3535   {"take", &DAQReadout::cmd_take, false, "<d|p|t> [n] [source]", "Start run (data, pedestal or test) with n events"},
    3636   {"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)"},
    3838   {"stop", &DAQReadout::cmd_stop, false, "", "Issue soft trigger and stop DAQ"},
    3939   {"test", &DAQReadout::cmd_test, true, "[2e]<blt32|blt64> [n]", "Test read access of VMEbus (n blocks)"},
     
    7171  CalibrationRead    = false;
    7272  NumEvents          = 0;
    73   NumEventsRequested = 100;
     73  NumEventsRequested = 0;
    7474  NumBoards          = 0;
    7575  FirstBoard         = 0;
     
    306306    StartDRS();
    307307    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    } 
    308317  }
    309318}
     
    10351044// Print message to selected target
    10361045void DAQReadout::PrintMessage(int Target, const char *Format, ...) {
     1046
    10371047  va_list ArgumentPointer;
    10381048  va_start(ArgumentPointer, Format);
    1039   PrintMessage(Target, Format, ArgumentPointer);
     1049  PrintMessage(Format, ArgumentPointer, Target);
    10401050  va_end(ArgumentPointer);
    10411051}
     
    10451055  va_list ArgumentPointer;
    10461056  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);
    10491059  va_end(ArgumentPointer);
    10501060}
    10511061
    10521062// 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 *, ...)
     1066void DAQReadout::PrintMessage(const char *Format, va_list ArgumentPointer, int Target) {
     1067
     1068  static char Textbuffer[MAX_COM_SIZE];  // static: it is only allocated once
    10561069
    10571070  memset(Textbuffer, 0, sizeof(Textbuffer)); 
     
    10681081  // Print to log file
    10691082  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);
    10711086    fflush(Logfile);
    10721087  }
     
    11831198  m->HVFB->ClearAverages();   
    11841199  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);
    11861201
    11871202  do {
     
    12651280  m->daq_state = stopped;
    12661281}
     1282
     1283
     1284/********************************************************************\
     1285
     1286  DAQ Thread - no disk writing, only hardware trigger, for feedback tests
     1287 
     1288\********************************************************************/
     1289
     1290void 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  
    3333class DAQReadout {
    3434    time_t StartTime;
    35     DRS *drs;
     35
    3636    pthread_t thread_DAQ;
     37    pthread_t thread_DAQ_Silent;
     38
    3739    unsigned int CmdNumber;
    3840    FILE *Logfile;   
     
    4446    EventHeader* EHeader;
    4547   
     48    DRS *drs;
     49
    4650    short (*WaveForm)[kNumberOfChips][kNumberOfChannels][kNumberOfBins];
    4751    int (*TriggerCell)[kNumberOfChips];
     
    127131    void PrintMessage(int, const char*, ...);
    128132    void PrintMessage(const char*, ...);
    129     void PrintMessage(int, const char*, va_list);
     133    void PrintMessage(const char*, va_list, int);
    130134    bool OpenRawFile();
    131135    bool WriteRunHeader();
     
    135139
    136140void DAQ(DAQReadout *);
     141void DAQ_Silent(DAQReadout *);
    137142
    138143bool Match(const char*, const char*);
  • drsdaq/HVFeedback.cc

    r99 r110  
    9999  if (SocketDescriptor!=-1) {
    100100    close(SocketDescriptor);
    101     m->PrintMessage("Feeback socket closed.\n");
     101    m->PrintMessage("Feedback socket closed.\n");
    102102  }
    103103  delete[] Average;     delete[] Response;
     
    123123      for (k=0; k<kNumberOfChannels; k++) {
    124124        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();
    126126        Integral /= 2*fIntHalfWidth+1;
    127127        Average[i][j][k] += Integral;
  • drsdaq/History.txt

    r99 r110  
    5151            initialisation steps)
    525210/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.
     5422/9/2009   The 'start' command will now start the DAQ without disk writing, but
     55            with invocation of the feedback.
     5623/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  
    148148 
    149149  // 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 
    151153  if (EventNo!=0 && fseek(Rawfile, RHeader->RunHeaderSize+RHeader->BoardStructureSize*RHeader->NBoards, SEEK_SET) != 0) SEEK_OK=false;
    152154  while(SEEK_OK) {
     
    159161    }
    160162    else {
    161       if (EHeader->EventNumber==EventNo || EventNo==0) break;
     163      if ((Count++) == EventNo) break;
    162164      if (fseek(Rawfile, EHeader->EventSize, SEEK_CUR) != 0) SEEK_OK = false;
    163165    }
  • drsdaq/drsdaq.cpp

    r92 r110  
    138138void ConsoleCommand(DAQReadout *m) {
    139139
    140   time_t Time;
    141   char *Command, Buf[MAX_COM_SIZE];;
     140  char *Command;
    142141 
    143142  while (!m->Exit) {
     
    150149    // Read Command
    151150    Command = readline(m->Prompt);
    152     if (Command==NULL) {
     151    if (Command == NULL) {
    153152      m->PrintMessage("Error reading command line input\n");
    154153      continue;
     
    157156
    158157    // 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);
    161159
    162160    // Process command
     
    192190  struct hostent *ClientName;
    193191  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];
    196193
    197194  // Set up server socket
     
    248245     
    249246      // 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);
    252248
    253249      // Process command     
Note: See TracChangeset for help on using the changeset viewer.