Changeset 10927


Ignore:
Timestamp:
06/08/11 14:40:14 (13 years ago)
Author:
lyard
Message:
Fixed a bug with the update of Fits files and grouping of daily files
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10898 r10927  
    148148        {
    149149                string factTableName = "FACT-" + tableName;
    150                 fTable = fFile->addTable(factTableName, 0, allNames, allDataTypes, allUnits);
    151                 fTable->makeThisCurrent();
     150                //first, let's check if the table already exist in the file
     151                vector<string> tryToLoadName;
     152                tryToLoadName.push_back(factTableName);
     153                fFile->read(tryToLoadName);
     154            const multimap< string, CCfits::ExtHDU * >& extMap = fFile->extension();
     155            if (extMap.find(factTableName) == extMap.end())
     156            {
     157                for (multimap<string, CCfits::ExtHDU*>::const_iterator it=extMap.begin(); it!= extMap.end(); it++)
     158                    fMess->Debug(it->first);
     159                fTable = fFile->addTable(factTableName, 0, allNames, allDataTypes, allUnits);
     160            }
     161            else
     162            {
     163                fTable = dynamic_cast<CCfits::Table*>(extMap.find(factTableName)->second);
     164            }
     165            if (!fTable)
     166            {
     167                fMess->Error("The table " + factTableName + " could not be created nor loaded. skipping it");
     168                return;
     169            }
     170            fTable->makeThisCurrent();
    152171                fCopyBuffer = new unsigned char[fTotalNumBytes];
    153172                fNumRows = fTable->rows();
     
    178197                        updating = true;
    179198                }
     199
    180200        }
    181201        catch(CCfits::FitsException e)
     
    301321        WriteSingleHeaderKey("TSTOP", fEndMjD, "Time of the last receied data");
    302322        if (fFile != NULL && fOwner)
    303                 delete fFile;
     323        {
     324//          fFile->flush();
     325            delete fFile;
     326        }
    304327        fFile = NULL;
    305328        if (fCopyBuffer != NULL)
  • trunk/FACT++/src/dataLogger.cc

    r10907 r10927  
    933933            }
    934934            //check if daily files should be closed and reopened.
     935            //FIXME when Time().h() == 12, the actual time is 2pm
    935936            if (Time().h() == 12 && !resetDone)
    936937            {
     938                if (fDebugIsOn)
     939                    Debug("Change of day detected. Closing daily files and restarting the dataLogger");
    937940                int cState = GetCurrentState();
    938941                GoToReadyPlease();
     
    952955            }
    953956            else
    954                 resetDone = false;
     957 //           {
     958 //               if (Time().h() != 12 && resetDone)
     959                    resetDone = false;
     960//            }
    955961            if (fStatsPeriodDuration == 0.0f)
    956962            {
     
    20932099        return;
    20942100    }
    2095     string groupName = CompileFileName(fRunFilePath, Time(), runNumber, "", "fits");
     2101    string groupName;
     2102    if (runNumber != 0)
     2103        groupName = CompileFileName(fRunFilePath, Time(), runNumber, "", "fits");
     2104    else
     2105        groupName = CompileFileName(fNightlyFilePath, Time(), "", "fits");
     2106
    20962107    CCfits::Table* groupTable;
    20972108    int maxCharLength = 50;//FILENAME_MAX;
Note: See TracChangeset for help on using the changeset viewer.