Changeset 17851 for trunk/FACT++/src


Ignore:
Timestamp:
05/14/14 09:30:43 (11 years ago)
Author:
tbretz
Message:
Some updated to get it properly working.
File:
1 edited

Legend:

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

    r17676 r17851  
    7878            (rst.rise>rst.set && (now.JD()<rst.set  || now.JD()>rst.rise));
    7979
     80        // FIXME: What about errors?
    8081        if (!isUp)
    8182            return EventServer::State::kStandby;
     
    8687        if (fNight!=night)
    8788        {
     89            fNight = night;
     90
    8891            delete fIn;
    8992
    9093            const string name = fAuxPath + Tools::Form("/%04d/%02d/%02d/%08d.FAD_CONTROL_EVENT_DATA.fits", night/10000, (night/100)%100, night%100, night);
    9194
    92             Info("Opening file "+name);
    93 
    9495            fIn = new fits(name);
    95 
    9696            if (!fIn->is_open())
    9797            {
    98                 Error(string("Opening file failed: ")+strerror(errno));
     98                Error(string("Failed to open "+name+": ")+strerror(errno));
    9999                return StateMachineImp::kSM_Error;
    100100            }
    101101
    102             fIn->SetRefAddress("QoS",  fQoS);
    103             fIn->SetRefAddress("Time", fTime);
    104             fIn->SetVecAddress("max",  fMax);
    105             //fIn->SetVecAddress(fRms);
    106             //fIn->SetVecAddress(fMax);
    107             //fIn->SetVecAddress(fPos);
    108         }
    109 
    110         fNight = night;
     102            try
     103            {
     104                fIn->SetRefAddress("QoS",  fQoS);
     105                fIn->SetRefAddress("Time", fTime);
     106                fIn->SetVecAddress("max",  fMax);
     107                //fIn->SetVecAddress(fRms);
     108                //fIn->SetVecAddress(fMax);
     109                //fIn->SetVecAddress(fPos);
     110            }
     111            catch (const runtime_error &e)
     112            {
     113                delete fIn;
     114                fIn = 0;
     115
     116                Error("Failed to open "+name+": "+e.what());
     117                return StateMachineImp::kSM_Error;
     118            }
     119
     120            Info("File "+name+" open.");
     121        }
     122
     123        if (GetCurrentState()==StateMachineImp::kSM_Error)
     124            return  StateMachineImp::kSM_Error;
    111125
    112126        // Get next data event
     
    143157            const double deviation = dev[uint32_t(0.682689477208650697*1440)];
    144158
    145             if (sorted[1439]>med+deviation*6)
     159            // In a typical shower or muon ring, the first
     160            // few pixels will have comparable brightness,
     161            // in a NSB event not. Therefore, the 4th brightest
     162            // pixel is a good reference.
     163            if (sorted[1439-3]>med+deviation*5)
    146164                break;
    147165        }
     
    221239
    222240
    223         AddEvent("START", EventServer::State::kIdle, StateMachineImp::kSM_Error)
     241        AddEvent("START", EventServer::State::kIdle, EventServer::State::kRunning, StateMachineImp::kSM_Error)
    224242            (bind(&StateMachineEventServer::StartServer, this))
    225243            ("Start serving the smartfact camera file");
    226244
    227         AddEvent("START_DATE", "I:1", EventServer::State::kIdle, StateMachineImp::kSM_Error)
     245        AddEvent("START_DATE", "I:1", EventServer::State::kIdle, EventServer::State::kRunning, StateMachineImp::kSM_Error)
    228246            (bind(&StateMachineEventServer::StartDate, this, placeholders::_1))
    229247            ("Start serving the smartfact camera file with the events from the given date"
Note: See TracChangeset for help on using the changeset viewer.