Changeset 13844 for trunk/FACT++


Ignore:
Timestamp:
05/23/12 19:32:56 (12 years ago)
Author:
tbretz
Message:
Removed the DimServiceInfoList; unified the Printing of states.
Location:
trunk/FACT++/src
Files:
5 edited

Legend:

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

    r13838 r13844  
    6565    PixelMap fMap;
    6666
    67     DimServiceInfoListImp fNetwork;
    68 
    6967    DimVersion fDim;
    70     DimState  fDimFAD;
    71     DimState  fDimFSC;
    72     DimState  fDimBias;
     68    DimDescribedState fDimFAD;
     69    DimDescribedState fDimFSC;
     70    DimDescribedState fDimBias;
    7371
    7472    DimDescribedService fDimReference;
     
    769767    }
    770768
    771     const State GetState(const DimState &s) const
    772     {
    773         return fNetwork.GetState(s.name(), s.state());
    774     }
    775 
    776     void PrintState(const DimState &state) const
    777     {
    778         const State rc = GetState(state);
    779 
    780         Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    781         Out() << kBold << state.name() << ": ";
    782         if (rc.index==-3)
    783         {
    784             Out() << kReset << "Offline" << endl;
    785             return;
    786         }
    787         if (rc.index==-2)
    788             Out() << state.state();
    789         else
    790             Out() << rc.name << "[" << rc.index << "]";
    791         Out() << kReset << " - " << kBlue << rc.comment << endl;
    792     }
    793 
    794769    int Print() const
    795770    {
    796         Out() << fDim.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    797         Out() << kBold << "DIM_DNS: " << fDim.version() << endl;
    798 
    799         PrintState(fDimFAD);
    800         PrintState(fDimFSC);
    801         PrintState(fDimBias);
    802 
    803         return GetCurrentState();
    804     }
    805 /*
    806     void PrintState(const pair<Time,int> &state, const char *server)
    807     {
    808         const State rc = fNetwork.GetState(server, state.second);
    809 
    810         Out() << state.first.GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    811         Out() << kBold << server << ": ";
    812         Out() << rc.name << "[" << rc.index << "]";
    813         Out() << kReset << " - " << kBlue << rc.comment << endl;
    814     }
    815 
    816     int Print()
    817     {
    818         Out() << fStatusDim.first.GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    819         Out() << kBold << "DIM_DNS: ";
    820         if (fStatusDim.second==0)
    821             Out() << "Offline" << endl;
    822         else
    823             Out() << "V" << fStatusDim.second/100 << 'r' << fStatusDim.second%100 << endl;
    824 
    825         PrintState(fStatusFAD,  "FAD_CONTROL");
    826         PrintState(fStatusFSC,  "FSC_CONTROL");
    827         PrintState(fStatusBias, "BIAS_CONTROL");
    828 
    829         return GetCurrentState();
    830     }
    831 */
     771        Out() << fDim << endl;
     772        Out() << fDimFAD << endl;
     773        Out() << fDimFSC << endl;
     774        Out() << fDimBias << endl;
     775
     776        return GetCurrentState();
     777    }
     778
    832779    int PrintCalibration()
    833780    {
  • trunk/FACT++/src/mcp.cc

    r13838 r13844  
    5050    };
    5151
    52     DimServiceInfoListImp fNetwork;
    53 
    5452    DimVersion fDim;
    55     DimState  fDimFTM;
    56     DimState  fDimFAD;
    57     DimState  fDimLog;
    58     DimState  fDimRC;
     53    DimDescribedState fDimFTM;
     54    DimDescribedState fDimFAD;
     55    DimDescribedState fDimLog;
     56    DimDescribedState fDimRC;
    5957
    6058    DimDescribedService fService;
    6159
    62     const State GetState(const DimState &s) const
    63     {
    64         return fNetwork.GetState(s.name(), s.state());
    65     }
    66 
    67     void PrintState(const DimState &state) const
    68     {
    69         const State rc = GetState(state);
    70 
    71         Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    72         Out() << kBold << state.name() << ": ";
    73         if (rc.index==-3)
    74         {
    75             Out() << kReset << "Offline" << endl;
    76             return;
    77         }
    78         if (rc.index==-2)
    79             Out() << state.state();
    80         else
    81             Out() << rc.name << "[" << rc.index << "]";
    82         Out() << kReset << " - " << kBlue << rc.comment << endl;
    83     }
    84 
    8560    int Print() const
    8661    {
    87         Out() << fDim.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    88         Out() << kBold << "DIM_DNS: " << fDim.version() << endl;
    89 
    90         PrintState(fDim);
    91         PrintState(fDimFTM);
    92         PrintState(fDimFAD);
    93         PrintState(fDimLog);
    94         PrintState(fDimRC);
     62        Out() << fDim << endl;
     63        Out() << fDimFTM << endl;
     64        Out() << fDimFAD << endl;
     65        Out() << fDimLog << endl;
     66        Out() << fDimRC << endl;
    9567
    9668        return GetCurrentState();
  • trunk/FACT++/src/ratecontrol.cc

    r13838 r13844  
    5151    vector<bool> fBlock;
    5252
    53     DimServiceInfoListImp fNetwork;
    54 
    5553    DimVersion fDim;
    56     DimState  fDimFTM;
    57     DimState  fDimRS;
     54    DimDescribedState fDimFTM;
     55    DimDescribedState fDimRS;
    5856
    5957    float  fTargetRate;
     
    431429        return GetCurrentState();
    432430    }
    433 /*
    434     void PrintState(const pair<Time,int> &state, const char *server)
    435     {
    436         const State rc = fNetwork.GetState(server, state.second);
    437 
    438         Out() << state.first.GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    439         Out() << kBold << server << ": ";
    440         Out() << rc.name << "[" << rc.index << "]";
    441         Out() << kReset << " - " << kBlue << rc.comment << endl;
    442     }
    443 
    444     int Print()
    445     {
    446         Out() << fStatusDim.first.GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    447         Out() << kBold << "DIM_DNS: ";
    448         if (fStatusDim.second==0)
    449             Out() << "Offline" << endl;
    450         else
    451             Out() << "V" << fStatusDim.second/100 << 'r' << fStatusDim.second%100 << endl;
    452 
    453         PrintState(fStatusRS,  "RATE_SCAN");
    454         PrintState(fStatusFTM, "FTM_CONTROL");
    455 
    456         return GetCurrentState();
    457     }
    458     */
    459 
    460     const State GetState(const DimState &s) const
    461     {
    462         return fNetwork.GetState(s.name(), s.state());
    463     }
    464 
    465     void PrintState(const DimState &state) const
    466     {
    467         const State rc = GetState(state);
    468 
    469         Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    470         Out() << kBold << state.name() << ": ";
    471         if (rc.index==-3)
    472         {
    473             Out() << kReset << "Offline" << endl;
    474             return;
    475         }
    476         if (rc.index==-2)
    477             Out() << state.state();
    478         else
    479             Out() << rc.name << "[" << rc.index << "]";
    480         Out() << kReset << " - " << kBlue << rc.comment << endl;
    481     }
    482431
    483432    int Print() const
    484433    {
    485         Out() << fDim.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    486         Out() << kBold << "DIM_DNS: " << fDim.version() << endl;
    487 
    488         PrintState(fDimFTM);
    489         PrintState(fDimRS);
     434        Out() << fDim << endl;
     435        Out() << fDimFTM << endl;
     436        Out() << fDimRS << endl;
    490437
    491438        return GetCurrentState();
  • trunk/FACT++/src/ratescan.cc

    r13838 r13844  
    4242    };
    4343
    44     DimServiceInfoListImp fNetwork;
    45 
    4644    DimVersion fDim;
    4745    DimState   fDimFTM;
     
    224222    }
    225223
    226     const State GetState(const DimState &s) const
    227     {
    228         return fNetwork.GetState(s.name(), s.state());
    229     }
    230 
    231     void PrintState(const DimState &state) const
    232     {
    233         const State rc = GetState(state);
    234 
    235         Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    236         Out() << kBold << state.name() << ": ";
    237         if (rc.index==-3)
    238         {
    239             Out() << kReset << "Offline" << endl;
    240             return;
    241         }
    242         if (rc.index==-2)
    243             Out() << state.state();
    244         else
    245             Out() << rc.name << "[" << rc.index << "]";
    246         Out() << kReset << " - " << kBlue << rc.comment << endl;
    247     }
    248 
    249224    int Print() const
    250225    {
    251         Out() << fDim.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    252         Out() << kBold << "DIM_DNS: " << fDim.version() << endl;
    253 
    254         PrintState(fDimFTM);
     226        Out() << fDim << endl;
     227        Out() << fDimFTM << endl;
    255228
    256229        return GetCurrentState();
  • trunk/FACT++/src/smartfact.cc

    r13838 r13844  
    326326    deque<string> fControlMessageHist;
    327327
    328     uint32_t fMcpConfigurationState;
     328    uint32_t fMcpConfigurationState;   // For consistency
    329329     int64_t fMcpConfigurationMaxTime;
    330330     int64_t fMcpConfigurationMaxEvents;
     
    372372    // ------------- Initialize variables before the Dim stuff ------------
    373373
    374     DimServiceInfoListImp fNetwork;
    375 
    376374    DimVersion fDimDNS;
    377375    DimControl fDimControl;
    378     DimState  fDimMcp;
    379     DimState  fDimDataLogger;
    380     DimState  fDimDriveControl;
    381     DimState  fDimMagicWeather;
    382     DimState  fDimFeedback;
    383     DimState  fDimBiasControl;
    384     DimState  fDimFtmControl;
    385     DimState  fDimFadControl;
    386     DimState  fDimFscControl;
    387     DimState  fDimRateControl;
    388     DimState  fDimRateScan;
    389     DimState  fDimChatServer;
     376    DimDescribedState fDimMcp;
     377    DimDescribedState fDimDataLogger;
     378    DimDescribedState fDimDriveControl;
     379    DimDescribedState fDimMagicWeather;
     380    DimDescribedState fDimFeedback;
     381    DimDescribedState fDimBiasControl;
     382    DimDescribedState fDimFtmControl;
     383    DimDescribedState fDimFadControl;
     384    DimDescribedState fDimFscControl;
     385    DimDescribedState fDimRateControl;
     386    DimDescribedState fDimRateScan;
     387    DimDescribedState fDimChatServer;
    390388
    391389    // -------------------------------------------------------------------
    392 /*
    393     bool HandleService(DimInfo *curr, const DimInfo &service, void (StateMachineSmartFACT::*handle)(const DimData &))
    394     {
    395         if (curr!=&service)
    396             return false;
    397 
    398         (this->*handle)(DimData(curr));
    399         return true;
    400     }
    401 */
    402390
    403391    bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false)
     
    415403    }
    416404
    417 
    418405    // -------------------------------------------------------------------
    419406
     
    528515    {
    529516        if (!CheckDataSize(d, "Mcp:Configuration", 16, true))
     517        {
     518            fMcpConfigurationState     = -4;
     519            fMcpConfigurationMaxTime   = 0;
     520            fMcpConfigurationMaxEvents = 0;
     521            fMcpConfigurationName      = "";
     522            fMcpConfigurationRunStart  = Time(Time::none);
    530523            return GetCurrentState();
     524        }
    531525
    532526        fMcpConfigurationState     = d.GetQoS();
     
    13221316    }
    13231317
    1324     const State GetState(const DimState &s) const
    1325     {
    1326         return fNetwork.GetState(s.name(), s.state());
    1327     }
    1328 
    1329     void PrintState(const DimState &state) const
    1330     {
    1331         const State rc = GetState(state);
    1332 
    1333         Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    1334         Out() << kBold << state.name() << ": ";
    1335         if (rc.index==-3)
    1336         {
    1337             Out() << kReset << "Offline" << endl;
    1338             return;
    1339         }
    1340         if (rc.index==-2)
    1341             Out() << state.state();
    1342         else
    1343             Out() << rc.name << "[" << rc.index << "]";
    1344         Out() << kReset << " - " << kBlue << rc.comment << endl;
    1345     }
    1346 
    13471318    int Print() const
    13481319    {
    1349         Out() << fDimDNS.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";
    1350         Out() << kBold << "DIM_DNS: " << fDimDNS.version() << endl;
    1351 
    1352         PrintState(fDimMcp);
    1353         PrintState(fDimControl);
    1354         PrintState(fDimDataLogger);
    1355         PrintState(fDimDriveControl);
    1356         PrintState(fDimFadControl);
    1357         PrintState(fDimFtmControl);
    1358         PrintState(fDimBiasControl);
    1359         PrintState(fDimFeedback);
    1360         PrintState(fDimRateControl);
    1361         PrintState(fDimFscControl);
    1362         PrintState(fDimMagicWeather);
    1363         PrintState(fDimRateScan);
    1364         PrintState(fDimChatServer);
     1320        Out() << fDimDNS          << endl;
     1321        Out() << fDimMcp          << endl;
     1322        Out() << fDimControl      << endl;
     1323        Out() << fDimDataLogger   << endl;
     1324        Out() << fDimDriveControl << endl;
     1325        Out() << fDimFadControl   << endl;
     1326        Out() << fDimFtmControl   << endl;
     1327        Out() << fDimBiasControl  << endl;
     1328        Out() << fDimFeedback     << endl;
     1329        Out() << fDimRateControl  << endl;
     1330        Out() << fDimFscControl   << endl;
     1331        Out() << fDimMagicWeather << endl;
     1332        Out() << fDimRateScan     << endl;
     1333        Out() << fDimChatServer   << endl;
    13651334
    13661335        return GetCurrentState();
     
    13791348        }
    13801349
    1381         const State rc = GetState(state);
     1350        const State rc = state.description();
    13821351
    13831352        // Sate not found in list, server online (-3: offline; -2: not found)
     
    14091378        //poll_one();
    14101379
    1411         if (fDimDNS.state()==0)
     1380        if (!fDimDNS.online())
    14121381            return kStateDimNetworkNA;
    14131382
     
    14231392
    14241393        // -------------- System status --------------
    1425         if (fDimMcp.state()>=5) // Idle
     1394        if (fMcpConfigurationState>=5) // Idle
    14261395        {
    14271396            string col = kHtmlBlue;
    1428             /*
    14291397            if (fMcpConfigurationState!= 5 &&  // Idle
    14301398                fMcpConfigurationState!=11 &&  // Trigger On
    1431                 fMcpConfigurationState!=12)    // Taking Data*/
    1432             if (fDimMcp.state()!= 5 &&  // Idle
    1433                 fDimMcp.state()!=11 &&  // Trigger On
    1434                 fDimMcp.state()!=12)    // Taking Data
     1399                fMcpConfigurationState!=12)    // Taking Data
    14351400                col = kHtmlYellow;
    14361401            else
     
    14421407            if (fDimRateControl.state()!=5 && fDimRateScan.state()!=5)
    14431408            {
    1444                 switch (fDimMcp.state()/*fMcpConfigurationState*/)
     1409                switch (fMcpConfigurationState)
    14451410                {
    14461411                // kStateIdle
     
    14651430                        out << "Rate scan in progress";
    14661431
    1467             if (fDimMcp.state()>10 && fDimRateControl.state()!=5)
     1432            if (fMcpConfigurationState>10 && fDimRateControl.state()!=5)
    14681433            {
    14691434                if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)
     
    15141479        {
    15151480            const double dev = fDriveControlTrackingDevHist.size()>0 ? fDriveControlTrackingDevHist.back() : 0;
    1516             const State rc = GetState(fDimDriveControl);
     1481            const State rc = fDimDriveControl.description();
    15171482            string col = kHtmlGreen;
    15181483            if (rc.index==6) // Moving
     
    16171582            // MCP in ReadyForDatataking/Configuring/Configured/TriggerOn/TakingData
    16181583            // and Bias not in "data-taking state' => Red
    1619             if (fDimMcp.state()>5 &&
     1584            if (fMcpConfigurationState>5 &&
    16201585                fDimBiasControl.state()!=BIAS::kVoltageOn &&
    16211586                fDimBiasControl.state()!=BIAS::kVoltageOff)
     
    16631628        out << now.JavaDate() << '\t' << fDimControl.online() << '\n';
    16641629
    1665         if (fDimDNS.state()==0)
     1630        if (!fDimDNS.online())
    16661631            out << kHtmlWhite << "\tOffline\n\n\n\n\n\n\n\n\n\n\n\n";
    16671632        else
     
    16951660        fMcpConfigurationMaxTime(0),
    16961661        fMcpConfigurationMaxEvents(0),
     1662        fBiasControlVoltageMed(0),
     1663        fBiasControlCurrentMax(0),
    16971664        fFscControlHumidityAvg(0),
    16981665        fRateScanDataId(0),
     
    17121679        fDimChatServer  ("CHAT_SERVER")
    17131680    {
     1681        fDimDNS.Subscribe(*this);
     1682        fDimControl.Subscribe(*this);
    17141683        fDimMcp.Subscribe(*this);
    17151684        fDimDataLogger.Subscribe(*this);
     
    17861755        AddEvent("PRINT")
    17871756            (bind(&StateMachineSmartFACT::Print, this))
    1788             ("");
     1757            ("Print a list of the states of all connected servers.");
    17891758
    17901759    }
Note: See TracChangeset for help on using the changeset viewer.