Changeset 11532 for trunk/FACT++/src


Ignore:
Timestamp:
07/22/11 08:49:55 (13 years ago)
Author:
tbretz
Message:
Changed fExpectedRuns to keep target configuration; added NumBoards and reserved to FITS.
File:
1 edited

Legend:

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

    r11522 r11532  
    1111#include <boost/thread.hpp>
    1212#include <boost/date_time/posix_time/posix_time_types.hpp>
     13
    1314
    1415#include <CCfits/CCfits>
     
    453454        AddColumnEntry(colNames, dataTypes, 1,            'J', "EventNum");
    454455        AddColumnEntry(colNames, dataTypes, 1,            'I', "TriggerType");
     456        AddColumnEntry(colNames, dataTypes, 1,            'I', "NumBoards");
     457        AddColumnEntry(colNames, dataTypes, 1,            'I', "reserved");
    455458        AddColumnEntry(colNames, dataTypes, 1,            'J', "SoftTrig");
    456459        AddColumnEntry(colNames, dataTypes, 2,            'J', "PCTime");
     
    461464
    462465        ostringstream fmt;
    463         fmt << "I:1;S:1;I:1;I:2";
     466        fmt << "I:1;S:1;I:1;I:1;I:1;I:2";
    464467        fmt << ";I:" << NBOARDS;
    465468        fmt << ";S:" << NPIX;
     
    865868    }
    866869
    867     map<uint32_t, pair<uint32_t, uint32_t>> fExpectedRuns;
    868 
    869     uint32_t StartNewRun(int64_t maxtime, int64_t maxevt)
    870     {
    871         if (maxtime==0)
     870    struct RunDescription
     871    {
     872        uint32_t maxtime;
     873        uint32_t maxevt;
     874
     875        FAD::Configuration reference;
     876    };
     877
     878    map<uint32_t, RunDescription> fExpectedRuns;
     879
     880    uint32_t StartNewRun(int64_t maxtime, int64_t maxevt, const FAD::Configuration &ref)
     881    {
     882        if (maxtime<=0 || maxtime>24*60*60)
    872883            maxtime = 24*60*60;
    873         if (maxevt==0)
     884        if (maxevt<=0 || maxevt>INT32_MAX)
    874885            maxevt  = INT32_MAX;
    875886
    876         fExpectedRuns[fRunNumber] = make_pair(maxtime, maxevt);
     887        const RunDescription descr =
     888        {
     889            uint32_t(maxtime),
     890            uint32_t(maxevt),
     891            ref
     892        };
     893
     894        fExpectedRuns[fRunNumber] = descr;
    877895        return fRunNumber++;
    878896    }
     
    13301348         */
    13311349
    1332         // Check consistency of:
    1333         // =====================
    1334 
    1335         // Write a single key for:
    1336         // -----------------------
    1337         // Start package flag
    1338         // package length
    1339         // version number
    1340         // status
    1341         // Prescaler
    1342 
    1343         // Write 40 kays for (?)
    1344         // Phaseshift
    1345         // DNA
    1346         // DAC
    1347 
    1348 
    13491350        /*
    1350          uint16_t start_package_flag;
    1351          uint16_t package_length;
    1352          uint16_t version_no;
    1353          uint16_t PLLLCK;
    1354 
    1355          uint16_t trigger_crc;
    1356          uint16_t trigger_type;
    1357          uint32_t trigger_id;
    1358 
    1359          uint32_t fad_evt_counter;
    1360          uint32_t REFCLK_frequency;
    1361 
    1362          uint16_t board_id;
    1363          uint8_t  zeroes;
    1364          int8_t   adc_clock_phase_shift;
    1365          uint16_t number_of_triggers_to_generate;
    1366          uint16_t trigger_generator_prescaler;
    1367 
    1368          uint64_t DNA;
    1369 
    1370          uint32_t time;
    1371          uint32_t runnumber;
    1372 
    1373          int16_t  drs_temperature[NTemp];
    1374 
    1375          int16_t  dac[NDAC];
    1376          */
    1377 
     1351        const FAD::EventHeader *beg = reinterpret_cast<FAD::EventHeader*>(fadhd);
     1352        const FAD::EventHeader *end = reinterpret_cast<FAD::EventHeader*>(fadhd)+41;
     1353
     1354        for (const FAD::EventHeader *ptr=beg; ptr!=end; ptr++)
     1355        {
     1356            // Event incomplete
     1357            if (ptr->fStartDelimiter==0)
     1358                return -1;
     1359
     1360                // Either one of
     1361                //   * fStatus
     1362                //   * fRunNumber
     1363                //   * fEventCounter
     1364                //   * fAdcClockPhaseShift
     1365                //   * fTriggerGeneratorPrescaler
     1366                //   * fDac
     1367                // inconsistent
     1368            if (*ptr != *beg)
     1369                return -1;
     1370
     1371            if (ptr->fTriggerType != beg->fTriggerType)
     1372                return -1;
     1373            if (ptr->fTriggerId   != beg->fTriggerId)
     1374                return -1;
     1375            if (ptr->fVersion     != beg->fVersion)
     1376                return -1;
     1377        }*/
     1378
     1379        // check REFCLK_frequency
     1380        // check consistency with command configuration
     1381        // how to log errors?
     1382        // need gotNewRun/closedRun to know it is finished
    13781383
    13791384        static Time oldt(boost::date_time::neg_infin);
     
    13901395        fDimEventData.updateService();
    13911396
    1392         //delete data;
    1393 
    13941397        return 0;
    13951398    }
     
    14031406    {
    14041407        // This function is called even when writing is switched off
    1405         const map<uint32_t,pair<uint32_t,uint32_t>>::iterator it = fExpectedRuns.find(runnr);
     1408        const map<uint32_t,RunDescription>::iterator it = fExpectedRuns.find(runnr);
    14061409        if (it==fExpectedRuns.end())
    14071410        {
     
    14111414        }
    14121415
    1413         CloseRunFile(runnr, time(NULL)+it->second.first, it->second.second);
     1416        CloseRunFile(runnr, time(NULL)+it->second.maxtime, it->second.maxevt);
    14141417        // return: 0=close scheduled / >0 already closed / <0 does not exist
    14151418
Note: See TracChangeset for help on using the changeset viewer.