Changeset 86


Ignore:
Timestamp:
07/09/09 16:33:34 (15 years ago)
Author:
ogrimm
Message:
Made SlowData class independent
Location:
drsdaq
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DAQReadout.cc

    r73 r86  
    153153  char Filename[MAX_PATH];
    154154  snprintf(Filename,sizeof(Filename),"%s/SlowData/", fRawDataPath);
    155   SlowDataClass = new SlowData(this, "DAQ", Filename);
     155  SlowDataClass = new SlowData("DAQ", Filename);
     156  if(SlowDataClass->ErrorCode != 0) {
     157   PrintMessage("Warning: Could not open DAQ slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode));
     158  }
    156159}
    157160
     
    12751278    m->PrintMessage("\rRun #%d (%s) %s, %d events\n",m->RunNumber,daq_runtype_str[m->daq_runtype],(m->NumEvents == m->NumEventsRequested) ? "completed":"stopped",m->NumEvents);
    12761279    m->SlowDataClass->NewEntry("Runinfo");
    1277     m->SlowDataClass->AddToEntry("%d %s %s %d %d",m->RunNumber,daq_runtype_str[m->daq_runtype],m->RHeader->Description,m->NumEvents,m->FileNumber);
     1280    m->SlowDataClass->AddToEntry("%d %s %s %d %d", m->RunNumber, daq_runtype_str[m->daq_runtype], m->RHeader->Description, m->NumEvents, m->FileNumber);
     1281    if(m->SlowDataClass->ErrorCode != 0) {
     1282      m->PrintMessage("SlowData: Error, could not write data to file (%s); closing file\n", strerror(m->SlowDataClass->ErrorCode));
     1283    }
     1284
    12781285  }
    12791286  else m->PrintMessage("\rRun #%d (%s) aborted due to error after %d events\n",m->RunNumber,daq_runtype_str[m->daq_runtype],m->NumEvents);
  • drsdaq/HVFeedback.cc

    r55 r86  
    3030
    3131  snprintf(Filename,sizeof(Filename),"%s/SlowData/", m->fRawDataPath);
    32   SlowDataClass = new SlowData(m, "HVFB", Filename);
     32  SlowDataClass = new SlowData("HVFB", Filename);
    3333
    3434  // Initialise with zero content
  • drsdaq/History.txt

    r79 r86  
    4040            correct order using writev() (10% gain in rate)
    414118/6/2009   Run date is now calculated with a change to the next date on 13:00 UTC.
    42            
     429/7/2009    SlowData class is now independet of PrintMessage() method, thus more
     43            universal       
  • drsdaq/SlowData.cc

    r85 r86  
    1616// Constructor: Open slow data file (filename generate using current date)
    1717//
    18 SlowData::SlowData(DAQReadout* DAQClass, const char* IssuerName, char* Direcory) {
     18SlowData::SlowData(const char* IssuerName, const char* Direcory) {
    1919
    2020  time_t rawtime;
     
    2222  char Filename[MAX_PATH];
    2323
    24   m = DAQClass;
    2524  Issuer = IssuerName;
    2625  NewEntryCalled = false;
     
    3130  if(timeinfo->tm_hour>=13) rawtime += 12*60*60;
    3231  timeinfo = gmtime(&rawtime);
    33   snprintf(Filename,sizeof(Filename),"%s/%s_%d%02d%02d.slow",Direcory,Issuer,timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday);
     32  snprintf(Filename, sizeof(Filename), "%s/%s_%d%02d%02d.slow", Direcory, Issuer, timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday);
    3433
    35   if ((SlowdataFile = fopen(Filename, "a")) == NULL)
    36     m->PrintMessage("Warning: Could not open slowdata file '%s' (%s)\n", Filename, strerror(errno));
     34  if ((SlowdataFile = fopen(Filename, "a")) == NULL) ErrorCode = errno;
     35  else ErrorCode = 0;
    3736}
    3837
     
    4140//
    4241SlowData::~SlowData() {
    43   if(SlowdataFile!=NULL && fclose(SlowdataFile)==-1)
    44     m->PrintMessage("SlowData: Error, could not close slowdata file (%s)\n", strerror(errno)); 
     42  if(SlowdataFile!=NULL) fclose(SlowdataFile); 
    4543}
    4644
     
    4846// Add a new entry to slow data file
    4947//
    50 bool SlowData::NewEntry(char *Variable) {
     48bool SlowData::NewEntry(const char *Variable) {
    5149
    5250  time_t RawTime;
     
    6664// Add data to an open entry
    6765//
    68 bool SlowData::AddToEntry(char *Format, ...) {
     66bool SlowData::AddToEntry(const char *Format, ...) {
    6967
    7068  char Textbuffer[MAX_COM_SIZE];
     
    8280
    8381  if(fprintf(SlowdataFile, "%s", Textbuffer) == -1) {
    84     m->PrintMessage("SlowData: Error, could not write data to file (%s); closing file\n", strerror(errno));
     82    ErrorCode = errno;
    8583    fclose(SlowdataFile);
    8684    SlowdataFile = NULL; 
     
    8886  }
    8987  fflush(SlowdataFile);
     88  ErrorCode = 0;
    9089  return true;
    9190}
  • drsdaq/SlowData.h

    r36 r86  
    77class SlowData {
    88
    9     class DAQReadout *m;
    109    const char *Issuer;
    1110    FILE *SlowdataFile;
     
    1413                         
    1514  public:
    16     SlowData(class DAQReadout*, const char*, char*);
     15    SlowData(const char*, const char*);
    1716    ~SlowData();
    1817
    19     bool NewEntry(char*);
    20     bool AddToEntry(char*, ...);
     18    int ErrorCode;      // Set to errno if an error occured, zero otherwise
     19    bool NewEntry(const char*);
     20    bool AddToEntry(const char*, ...);
    2121};
    2222
Note: See TracChangeset for help on using the changeset viewer.