Changeset 10938


Ignore:
Timestamp:
06/08/11 20:16:51 (13 years ago)
Author:
tbretz
Message:
Send some dim messages.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilderWrapper.h

    r10923 r10938  
    4646    MessageImp &fMsg;
    4747
     48    enum
     49    {
     50        kCurrent = 0,
     51        kTotal   = 1
     52    };
     53
     54    bool fFitsFormat;
     55
     56    uint32_t fMaxRun;
     57    uint32_t fNumEvts[2];
     58
    4859    DimDescribedService fDimFiles;
     60    DimDescribedService fDimRuns;
     61    DimDescribedService fDimEvents;
     62    DimDescribedService fDimCurrentEvent;
    4963
    5064public:
    51     EventBuilderWrapper(MessageImp &msg) : fMsg(msg),
    52         fDimFiles("FAD_CONTROL/FILES", "X:1", "")
     65    EventBuilderWrapper(MessageImp &msg) : fMsg(msg),
     66        fFitsFormat(false), fMaxRun(0),
     67        fDimFiles ("FAD_CONTROL/FILES",         "X:1", ""),
     68        fDimRuns  ("FAD_CONTROL/RUNS",          "I:1", ""),
     69        fDimEvents("FAD_CONTROL/EVENTS",        "I:3", ""),
     70        fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", "")
    5371    {
    5472        if (This)
     
    5775        This = this;
    5876
    59         fFitsFormat = false;
     77        memset(fNumEvts, 0, sizeof(fNumEvts));
     78
     79        Update(fDimRuns,         uint32_t(0));
     80        Update(fDimCurrentEvent, uint32_t(0));
     81        Update(fDimEvents,       fNumEvts);
    6082    }
    6183    ~EventBuilderWrapper()
     
    165187    size_t GetUsedMemory() const { return gi_usedMem; }
    166188
     189    virtual int CloseOpenFiles() { CloseRunFile(0, 0); return 0; }
     190
     191
    167192    /*
    168193     struct OpenFileToDim
     
    223248    vector<DataFileImp*> fFiles;
    224249
    225     bool fFitsFormat;
    226 
    227250    template<class T>
    228251        void Update(DimDescribedService &svc, const T &data) const
     
    236259    {
    237260        // Check if file already exists...
    238         cout << "OPEN_FILE #" << runid << endl;
     261        DataFileImp *file = NULL;
     262        try
     263        {
     264            file = fFitsFormat ?
     265                static_cast<DataFileImp*>(new DataFileFits(runid)) :
     266                static_cast<DataFileImp*>(new DataFileRaw(runid));
     267        }
     268        catch (const exception &e)
     269        {
     270            return 0;
     271        }
     272
     273        cout << "OPEN_FILE #" << runid << " (" << file << ")" <<  endl;
    239274        cout << " Ver= " << h->Version << endl;
    240275        cout << " Typ= " << h->RunType << endl;
     
    244279        cout << " roi= " << h->Nroi << endl;
    245280
    246         DataFileImp *file = NULL;
    247         try
    248         {
    249             file = fFitsFormat ?
    250                 static_cast<DataFileImp*>(new DataFileFits(runid)) :
    251                 static_cast<DataFileImp*>(new DataFileRaw(runid));
    252         }
    253         catch (const exception &e)
    254         {
    255             return 0;
    256         }
    257 
    258281        fFiles.push_back(file);
     282
     283        if (runid>fMaxRun)
     284        {
     285            fMaxRun = runid;
     286            fNumEvts[kCurrent] = 0;
     287
     288            Update(fDimRuns,         fMaxRun);
     289            Update(fDimEvents,       fNumEvts);
     290            Update(fDimCurrentEvent, uint32_t(0));
     291        }
    259292
    260293        Update(fDimFiles, fFiles.size());
     
    281314            return -1;
    282315
     316        if (file->GetRunId()==fMaxRun)
     317        {
     318            Update(fDimCurrentEvent, e->EventNum);
     319            fNumEvts[kCurrent]++;
     320        }
     321
     322        fNumEvts[kTotal]++;
     323        Update(fDimEvents, fNumEvts);
     324
    283325        // ===> SignalEvtWritten(runid);
    284326        // Send num events written of newest file
     
    295337        DataFileImp *file = reinterpret_cast<DataFileImp*>(handler);
    296338
    297         cout << "CLOSE_RUN " << file->GetRunId() << endl;
    298 
    299         fFiles.erase(find(fFiles.begin(), fFiles.end(), file));
     339         const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file);
     340        if (it==fFiles.end())
     341        {
     342            ostringstream str;
     343            str << "File handler (" << handler << ") requested to close by event builder doesn't exist.";
     344            fMsg.Fatal(str);
     345            return -1;
     346        }
     347
     348        ostringstream str;
     349        str << "CLOSE_RUN requested for " << file->GetRunId() << " (" << file << ")" <<endl;
     350        fMsg.Debug(str);
     351
     352        fFiles.erase(it);
    300353
    301354        Update(fDimFiles, fFiles.size());
Note: See TracChangeset for help on using the changeset viewer.