Changeset 13905 for trunk


Ignore:
Timestamp:
05/26/12 11:27:42 (12 years ago)
Author:
tbretz
Message:
Initialize callbacks in constructor; output also if dim dns not available; improved handling of dimctrl messages; handle scriptdepth
File:
1 edited

Legend:

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

    r13894 r13905  
    328328
    329329    deque<string> fControlMessageHist;
     330    int32_t       fControlScriptDepth;
    330331
    331332    uint32_t fMcpConfigurationState;   // For consistency
     
    377378    deque<float> fRateScanDataHist[41];
    378379
    379     bool fHasError;
     380    int fHasError;
    380381
    381382    // ------------- Initialize variables before the Dim stuff ------------
     
    520521    int HandleDimControlMessage(const EventImp &d)
    521522    {
     523        cout << "Received1: " << d.GetQoS() << endl;
     524
    522525        if (d.GetQoS()==90)
    523526            HandleControlMessageImp(d);
     
    528531    void HandleControlStateChange(const EventImp &d)
    529532    {
    530         if (d.GetQoS()==-2)
     533        DimControl ctrl;
     534        ctrl.Handler(d);
     535
     536        if (d.GetQoS()==-2 && ctrl.scriptdepth==0)
    531537            fControlMessageHist.clear();
    532538
    533         if (d.GetQoS()<0)
    534         {
    535             DimControl ctrl;
    536             ctrl.Handler(d);
     539        cout << "Received2: " << d.GetString() << endl;
     540        cout << "Received2: " << d.GetQoS() << endl;
     541
     542        if (d.GetQoS()>=0)
     543            return;
    537544
    538545#if BOOST_VERSION < 104600
    539             const string file = boost::filesystem::path(ctrl.file).filename();
     546        const string file = boost::filesystem::path(ctrl.file).filename();
    540547#else
    541             const string file = boost::filesystem::path(ctrl.file).filename().string();
     548        const string file = boost::filesystem::path(ctrl.file).filename().string();
    542549#endif
    543550
    544             const string msg = ctrl.shortmsg+"<br>"+file;
    545             HandleControlMessageImp(Event(d, msg.data(), msg.length()+1));
    546         }
     551        HandleControlMessageImp(Event(d, ctrl.shortmsg.data(), ctrl.shortmsg.length()+1));
     552        HandleControlMessageImp(Event(d, file.data(), file.length()+1));
    547553    }
    548554
     
    551557        if (!CheckDataSize(d, "Mcp:Configuration", 16, true))
    552558        {
    553             fMcpConfigurationState     = -4;
     559            fMcpConfigurationState     = -256;
    554560            fMcpConfigurationMaxTime   = 0;
    555561            fMcpConfigurationMaxEvents = 0;
     
    14971503        //poll_one();
    14981504
    1499         if (!fDimDNS.online())
    1500             return kStateDimNetworkNA;
    1501 
    15021505        Time now;
    15031506        if (now-fLastUpdate<boost::posix_time::seconds(1))
     
    15101513        ostringstream msg;
    15111514
     1515        if (fHasError==2)
     1516            msg << "SmartFACT backend initializing." << endl;
     1517        if (!fDimDNS.online())
     1518            msg << "DIM network not available.<br/>";
    15121519        if (fDimDriveControl.state()>0xff)
    15131520            msg << "Drive in ERROR state<br/>";
     
    15691576
    15701577        fHasError = haserror;
     1578
     1579        if (!fDimDNS.online())
     1580            return kStateDimNetworkNA;
    15711581
    15721582        // ==============================================================
     
    18451855    StateMachineSmartFACT(ostream &out=cout) : StateMachineDim(out, "SMART_FACT"),
    18461856        fPath("www/smartfact/data"),
     1857        fControlScriptDepth(0),
    18471858        fMcpConfigurationMaxTime(0),
    18481859        fMcpConfigurationMaxEvents(0),
     
    18551866        fRateScanDataId(0),
    18561867        fRateScanBoard(0),
    1857         fHasError(false),
     1868        fHasError(2),
    18581869        // ---
    18591870        fDimMcp         ("MCP"),
     
    18871898        fDimChatServer.Subscribe(*this);
    18881899
     1900        fDimControl.SetCallback(bind(&StateMachineSmartFACT::HandleControlStateChange, this, placeholders::_1));
     1901        fDimControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1));
     1902
    18891903        Subscribe("DIM_CONTROL/MESSAGE")
    18901904            (bind(&StateMachineSmartFACT::HandleDimControlMessage,   this, placeholders::_1));
     
    19621976
    19631977        fPath = conf.Get<string>("path");
    1964 
    1965         fDimControl.SetCallback(bind(&StateMachineSmartFACT::HandleControlStateChange, this, placeholders::_1));
    1966         fDimControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1));
    19671978
    19681979        return -1;
Note: See TracChangeset for help on using the changeset viewer.