Changeset 14364 for trunk/FACT++/src


Ignore:
Timestamp:
08/14/12 11:08:45 (12 years ago)
Author:
lyard
Message:
fixed missing columns desc and log entries
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/datalogger.cc

    r14348 r14364  
    222222
    223223    DimWriteStatistics fFilesStats;
     224
     225    ///map and mutex for storing services description
     226    map<string, vector<Description> > fServiceDescriptionList;
     227    mutex fMutex;
     228    int HandleDescriptions(DimDescriptions* desc);
     229    vector<Description> GetDescription(const string& server, const string& service);
    224230private:
    225231    /***************************************************
     
    378384}; //DataLogger
    379385
     386
     387/**
     388 * @brief the two methods below were copied from StateMachineDimControl.cc
     389 *
     390 */
     391int DataLogger::HandleDescriptions(DimDescriptions* desc)
     392{
     393    fMutex.lock();
     394    for (auto it=desc->descriptions.begin(); it != desc->descriptions.end(); it++) {
     395        if (fDebugIsOn)
     396        {
     397            Debug("Adding description for service: " + it->front().name);
     398        }
     399        fServiceDescriptionList[it->front().name].assign(it->begin(), it->end());
     400    }
     401    fMutex.unlock();
     402
     403    return GetCurrentState();
     404}
     405vector<Description> DataLogger::GetDescription(const string& server, const string& service)
     406{
     407    const lock_guard<mutex> guard(fMutex);
     408    const auto it = fServiceDescriptionList.find(server+"/"+service);
     409    return it==fServiceDescriptionList.end()?vector<Description>():it->second;
     410}
    380411// --------------------------------------------------------------------------
    381412//
     
    442473    {
    443474        DimDescriptions* d = new DimDescriptions(server);
     475        d->SetCallbackDescriptions(bind(&DataLogger::HandleDescriptions, this, d));
    444476        d->Subscribe(*this);
    445477        fServerDescriptionsList.push_back(d);
     
    11901222    {
    11911223        //write text header
    1192         header << evt.GetName() << " " << fQuality << " ";
    1193         header << cTime.Y() << " " << cTime.M() << " " << cTime.D() << " ";
    1194         header << cTime.h() << " " << cTime.m() << " " << cTime.s() << " ";
    1195         header << cTime.ms() << " " << evt.GetTime() << " ";
     1224        header << sub.server << "_" << sub.service << " " << fQuality << " ";
     1225        header << evt.GetTime() << " ";
    11961226
    11971227        string text;
     
    12411271    }
    12421272    else
    1243     {//write entry to both Nightly and run logs
     1273    {//write entry to Nightly log
    12441274        vector<string> strings;
    12451275        try
     
    12651295        }
    12661296        ostringstream msg;
    1267         msg << evt.GetName() << ": " << strings[0];
     1297        msg << sub.server << "_" << sub.service << ": " << strings[0];
    12681298
    12691299        if (fNightlyLogFile.is_open())
     
    16531683    str << "Initializing data columns for service " << sub.server << "/" << sub.service;
    16541684    Info(str);
    1655     sub.nightlyFile.InitDataColumns(Description::SplitDescription(evt.GetDescription()), dataFormatsLocal, this);
     1685    sub.nightlyFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, this);
    16561686
    16571687    sub.fitsBufferAllocated = true;
Note: See TracChangeset for help on using the changeset viewer.