Ignore:
Timestamp:
10/26/11 11:41:42 (13 years ago)
Author:
lyard
Message:
fixed the handling of columns names in the datalogger
File:
1 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]);
Note: See TracChangeset for help on using the changeset viewer.