Changeset 12277 for trunk


Ignore:
Timestamp:
10/26/11 11:41:42 (13 years ago)
Author:
lyard
Message:
fixed the handling of columns names in the datalogger
Location:
trunk/FACT++/src
Files:
3 edited

Legend:

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

    r12035 r12277  
    5656//! @param dataPointer the memory location where the DIM data starts
    5757//! @param numDataBytes the number of bytes taken by the DIM data.
     58//! @param out Message object to use for propagating messages
    5859//     
    59 void Fits::InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, void* dataPointer)
     60void Fits::InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, void* dataPointer, MessageImp* out)
    6061{
    6162    fDataFormats = dataFormat;
     
    6364
    6465    //we will copy this information here. It duplicates the data, which is not great, but it is the easiest way of doing it right now
    65     if (desc.size() == dataFormat.size())
    66     {
    67         fDataColDesc = desc;
     66    if ((desc.size() == dataFormat.size()+1) || //regular service
     67        (desc.size() == dataFormat.size()+2))//service with ending string. skipped in fits
     68    {//services have one (or two) more description than columns. skip the first entry while copying as it describes the table itself.
     69        fDataColDesc.clear();
     70        for (unsigned int i=0;i<dataFormat.size(); i++)
     71        {
     72            string name = desc[i+1].name;
     73            if (name.length() > 68) name = name.substr(0, 68);
     74            string comment = desc[i+1].comment;
     75            if (comment.length() > 68) comment = comment.substr(0,68);
     76            string unit = desc[i+1].unit;
     77            if (unit.length() > 68)  unit = comment.substr(0,68);
     78            fDataColDesc.push_back(Description(name, comment, unit));
     79        }
    6880        return;
    6981    }
    7082
     83    {//if we arrived here, this means that the columns descriptions could not be parsed
     84        ostringstream str;
     85        str << "Expected " << dataFormat.size() << " descriptions of columns, got " << desc.size()-1 << " for service: ";
     86        if (desc.size() > 0)
     87            str << desc[0].name;
     88        else
     89            str << "<unknown>";
     90
     91        out->Warn(str.str());
     92    }
     93
    7194    fDataColDesc.clear();
     95 //   fDataColDesc.push_back(Description("service", "comment", "unit"));
    7296    for (unsigned int i=0;i<dataFormat.size();i++)
    7397    {
     
    133157            name = stt.str();
    134158        }
    135 
     159//cout << endl << "#####adding column: " << name << " " << fDataFormats[i] << " " << fDataColDesc[i].unit << endl << endl;
    136160        fFile->AddColumn(name, fDataFormats[i], fDataColDesc[i].unit);
    137161    }
     
    249273        fFile->WriteKeyNT("TSTART", Time(doubleValue).Iso(),
    250274                          "Time of the first received data");
     275        fFile->WriteKeyNT("TSTOP", Time(fEndMjD).Iso(),
     276                          "Time of the last receied data");
    251277    }
    252278    fEndMjD = *reinterpret_cast<double*>(fStandardPointers[0]);
  • trunk/FACT++/src/Fits.h

    r12071 r12277  
    7878
    7979    ///Adds columns specific to the service being logged.
    80     void InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, void* dataPointer);
     80    void InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, void* dataPointer, MessageImp* out);
    8181
    8282    ///Opens a FITS file
  • trunk/FACT++/src/datalogger.cc

    r12167 r12277  
    645645    ostringstream str;
    646646
    647     const Time ftime(time-boost::posix_time::hours(12));
     647    const Time ftime(time);//removed this as already done by nightAsInt: -boost::posix_time::hours(12));
    648648    str << ftime.NightAsInt();
    649649
     
    811811     fNumSubAndFits = new DimDescribedService(GetName() + "/NUM_SUBS", "I:2", fNumSubAndFitsData,
    812812                               "Shows number of services to which the data logger is currently subscribed and the total number of open files."
    813                                "|Subscriptions[int]:number of dim services to which the data logger is currently subscribed."
    814                                "|NumOpenFiles[int]:number of files currently open by the data logger");
     813                               "|NumSubAndNumOpenFiles[int]:number of dim services to which the data logger is currently subscribed plus number of files currently open by the data logger");
    815814
    816815     //services parameters
     
    18511850    const vector<string> dataFormatsLocal = sub.fConv->GetFitsFormat();
    18521851
    1853     sub.nightlyFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData());
    1854     sub.runFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData());
     1852    sub.nightlyFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData(), this);
     1853    sub.runFile.InitDataColumns(GetDescription(sub.server, sub.service), dataFormatsLocal, sub.dimInfo->getData(), this);
    18551854    sub.fitsBufferAllocated = true;
    18561855}
Note: See TracChangeset for help on using the changeset viewer.