Ignore:
Timestamp:
05/12/11 19:05:36 (14 years ago)
Author:
tbretz
Message:
To simplify the interaction with the GUI SET_*_COINCIDENCE has been splitted; fixed setting of the trigger sequence; removed some debug output.
File:
1 edited

Legend:

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

    r10661 r10679  
    4444    bool fIsDynamicOut;
    4545    bool fIsHexOutput;
     46
     47//    string fDefaultSetup;
    4648
    4749    // --verbose
     
    197199    void HandleReceivedData(const bs::error_code& err, size_t bytes_received, int /*type*/)
    198200    {
    199         cout << "Data received " << err << " " << bytes_received << endl;
    200 
    201201        // Do not schedule a new read if the connection failed.
    202202        if (bytes_received==0 || err)
     
    315315            UpdateCounter();
    316316
    317             cout << "TYPE=" << fHeader.fType << endl;
    318 
    319317            switch (fHeader.fType)
    320318            {
     
    391389        fBuffer.resize(sizeof(FTM::Header)/2);
    392390        AsyncRead(ba::buffer(fBuffer));
     391
     392//        if (!fDefaultSetup.empty())
     393//            LoadStaticData(fDefaultSetup);
    393394
    394395        // Get a header and configdata!
     
    592593        fIsDynamicOut = b;
    593594    }
    594 
     595/*
     596    void SetDefaultSetup(const string &file)
     597    {
     598        fDefaultSetup = file;
     599    }
     600*/
    595601    bool LoadStaticData(string name)
    596602    {
     
    799805
    800806        fStaticData.fTriggerSequence =
    801             (d[0]<<10) | (d[1]<<5) || d[2];
     807            (uint16_t(d[0])<<10) | (uint16_t(d[1])<<5) | uint16_t(d[2]);
    802808
    803809        if (oldseq!=fStaticData.fTriggerSequence || oldset!=fStaticData.fGeneralSettings)
     
    807813    }
    808814
    809     bool SetTriggerCoincidence(uint16_t n, uint16_t win)
    810     {
    811         if (n==0 || n>FTM::StaticData::kMaxCoincidence ||
    812             win>FTM::StaticData::kMaxWindow)
     815    bool SetTriggerCoincidence(uint16_t n)
     816    {
     817        if (n==0 || n>FTM::StaticData::kMaxCoincidence)
    813818            return false;
    814819
    815         if (n  ==fStaticData.fCoincidencePhysics &&
    816             win==fStaticData.fWindowPhysics)
     820        if (n==fStaticData.fCoincidencePhysics)
    817821            return true;
    818822
    819823        fStaticData.fCoincidencePhysics = n;
    820         fStaticData.fWindowPhysics      = win;
    821824
    822825        CmdSendStatDat();
     
    825828    }
    826829
    827     bool SetCalibCoincidence(uint16_t n, uint16_t win)
    828     {
    829         if (n==0 || n>FTM::StaticData::kMaxCoincidence ||
    830             win>FTM::StaticData::kMaxWindow)
     830    bool SetTriggerWindow(uint16_t win)
     831    {
     832        if (win>FTM::StaticData::kMaxWindow)
    831833            return false;
    832834
    833         if (n  ==fStaticData.fCoincidenceCalib &&
    834             win==fStaticData.fWindowCalib)
     835        if (win==fStaticData.fWindowPhysics)
    835836            return true;
    836837
     838        fStaticData.fWindowPhysics = win;
     839
     840        CmdSendStatDat();
     841
     842        return true;
     843    }
     844
     845    bool SetCalibCoincidence(uint16_t n)
     846    {
     847        if (n==0 || n>FTM::StaticData::kMaxCoincidence)
     848            return false;
     849
     850        if (n==fStaticData.fCoincidenceCalib)
     851            return true;
     852
    837853        fStaticData.fCoincidenceCalib = n;
    838         fStaticData.fWindowCalib      = win;
     854
     855        CmdSendStatDat();
     856
     857        return true;
     858    }
     859
     860    bool SetCalibWindow(uint16_t win)
     861    {
     862        if (win>FTM::StaticData::kMaxWindow)
     863            return false;
     864
     865        if (win==fStaticData.fWindowCalib)
     866            return true;
     867
     868        fStaticData.fWindowCalib = win;
    839869
    840870        CmdSendStatDat();
     
    12361266    int SetTriggerCoincidence(const EventImp &evt)
    12371267    {
    1238         if (!CheckEventSize(evt.GetSize(), "SetTriggerCoincidence", 4))
    1239             return T::kSM_FatalError;
    1240 
    1241         const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());;
    1242 
    1243         if (!fFTM.SetTriggerCoincidence(d[0], d[1]))
     1268        if (!CheckEventSize(evt.GetSize(), "SetTriggerCoincidence", 2))
     1269            return T::kSM_FatalError;
     1270
     1271        if (!fFTM.SetTriggerCoincidence(evt.GetUShort()))
    12441272            T::Warn("SetTriggerCoincidence -  Value out of range.");
    12451273
     
    12491277    int SetCalibCoincidence(const EventImp &evt)
    12501278    {
    1251         if (!CheckEventSize(evt.GetSize(), "SetCalibCoincidence", 4))
    1252             return T::kSM_FatalError;
    1253 
    1254         const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());;
    1255 
    1256         if (!fFTM.SetCalibCoincidence(d[0], d[1]))
     1279        if (!CheckEventSize(evt.GetSize(), "SetCalibCoincidence", 2))
     1280            return T::kSM_FatalError;
     1281
     1282        if (!fFTM.SetCalibCoincidence(evt.GetUShort()))
    12571283            T::Warn("SetCalibCoincidence -  Value out of range.");
    12581284
    12591285        return T::GetCurrentState();
    12601286    }
     1287
     1288    int SetTriggerWindow(const EventImp &evt)
     1289    {
     1290        if (!CheckEventSize(evt.GetSize(), "SetTriggerWindow", 2))
     1291            return T::kSM_FatalError;
     1292
     1293        if (!fFTM.SetTriggerWindow(evt.GetUShort()))
     1294            T::Warn("SetTriggerWindow -  Value out of range.");
     1295
     1296        return T::GetCurrentState();
     1297    }
     1298
     1299    int SetCalibWindow(const EventImp &evt)
     1300    {
     1301        if (!CheckEventSize(evt.GetSize(), "SetCalibWindow", 2))
     1302            return T::kSM_FatalError;
     1303
     1304        if (!fFTM.SetCalibWindow(evt.GetUShort()))
     1305            T::Warn("SetCalibWindow -  Value out of range.");
     1306
     1307        return T::GetCurrentState();
     1308    }
     1309
    12611310
    12621311    int Enable(const EventImp &evt, FTM::StaticData::GeneralSettings type)
     
    14671516             "|LPext[int]:number of triggers of the external light pulser");
    14681517
    1469         AddConfiguration("SET_TRIGGER_COINCIDENCE", "S:2", kStateIdle)
     1518        AddConfiguration("SET_TRIGGER_COINCIDENCE", "S:1", kStateIdle)
    14701519            (boost::bind(&StateMachineFTM::SetTriggerCoincidence, this, _1))
    14711520            ("Setup the coincidence condition for physcis triggers"
    14721521             "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)");
    14731522
    1474         AddConfiguration("SET_CALIBRATION_COINCIDENCE", "S:2", kStateIdle)
     1523        AddConfiguration("SET_TRIGGER_WINDOW", "S:1", kStateIdle)
     1524            (boost::bind(&StateMachineFTM::SetTriggerWindow, this, _1))
     1525            ("");
     1526
     1527        AddConfiguration("SET_CALIBRATION_COINCIDENCE", "S:1", kStateIdle)
    14751528            (boost::bind(&StateMachineFTM::SetCalibCoincidence, this, _1))
    14761529            ("Setup the coincidence condition for artificial (calibration) triggers"
    14771530             "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)");
     1531
     1532        AddConfiguration("SET_CALIBRATION_WINDOW", "S:1", kStateIdle)
     1533            (boost::bind(&StateMachineFTM::SetCalibWindow, this, _1))
     1534            ("");
    14781535
    14791536
     
    15491606        fFTM.SetHexOutput(conf.Get<bool>("hex-out"));
    15501607        fFTM.SetDynamicOut(conf.Get<bool>("dynamic-out"));
     1608
     1609//        fFTM.SetDefaultSetup(conf.Get<string>("default-setup"));
    15511610
    15521611        return true;
     
    16541713    po::options_description control("FTM control options");
    16551714    control.add_options()
    1656         ("addr,a",      var<string>("localhost:5000"),  "Network address of FTM")
    1657         ("quiet,q",     po_switch(), "Disable printing contents of all received messages (except dynamic data) in clear text.")
    1658         ("hex-out",     po_switch(), "Enable printing contents of all printed messages also as hex data.")
    1659         ("dynamic-out", po_switch(), "Enable printing received dynamic data.")
     1715        ("addr,a",        var<string>("localhost:5000"),  "Network address of FTM")
     1716        ("quiet,q",       po_switch(),   "Disable printing contents of all received messages (except dynamic data) in clear text.")
     1717        ("hex-out",       po_switch(),   "Enable printing contents of all printed messages also as hex data.")
     1718        ("dynamic-out",   po_switch(),   "Enable printing received dynamic data.")
     1719//        ("default-setup", var<string>(), "Binary file with static data loaded whenever a connection to the FTM was established.")
    16601720        ;
    16611721
Note: See TracChangeset for help on using the changeset viewer.