Changeset 14541 for trunk/FACT++/src


Ignore:
Timestamp:
10/30/12 12:53:07 (12 years ago)
Author:
tbretz
Message:
Added time to State so that the time of state reception is propagated.
Location:
trunk/FACT++/src
Files:
5 edited

Legend:

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

    r14538 r14541  
    161161        for (auto it=states.begin(); it!=states.end(); it++)
    162162            if (it->index==state())
    163                 return *it;
     163                return State(it->index, it->name, it->comment, time());
    164164
    165165        return State(kNotAvailable, "n/a");
     
    245245    State description() const
    246246    {
    247         return State(state(), version());
     247        return State(state(), version(), "", time());
    248248    }
    249249};
     
    307307    State description() const
    308308    {
    309         return State(state(), "Current label");
     309        return State(state(), "Current label", "", time());
    310310    }
    311311};
  • trunk/FACT++/src/State.cc

    r10429 r14541  
    4040//!     Descriptive text of the state, e.g. "Connection to hardware established."
    4141//
    42 State::State(int i, const std::string &n, const std::string &c)
    43     : index(i), name(Trim(n)), comment(Trim(c))
     42State::State(int i, const std::string &n, const std::string &c, const Time &t)
     43    : index(i), name(Trim(n)), comment(Trim(c)), time(t)
    4444{
    4545}
  • trunk/FACT++/src/State.h

    r10395 r14541  
    55#include <vector>
    66
     7#include "Time.h"
     8
    79struct State
    810{
     
    1012    std::string name;     /// Name (e.g. 'Connected')
    1113    std::string comment;  /// Description (e.g. 'Connection to hardware established.')
     14    Time        time;     /// Time of state change
    1215
    1316    static std::vector<State> SplitStates(const std::string &buffer);
     
    1518    static bool Compare(const State &i, const State &j) { return i.index<j.index; }
    1619
    17     State(int i, const std::string &n, const std::string &c="");
     20    State(int i=-256, const std::string &n="", const std::string &c="", const Time &t=Time(Time::none));
    1821};
    1922
  • trunk/FACT++/src/StateMachineDimControl.cc

    r14440 r14541  
    294294    fMutex.lock();
    295295    const State state = dim->description();
    296     fCurrentStateList[server] = make_pair(dim->state(), state.index==DimState::kNotAvailable?"":state.name);
    297     fMutex.unlock();
    298 
    299     return GetCurrentState();
    300 }
    301 
    302 pair<int32_t, string> StateMachineDimControl::GetServerState(const std::string &server)
     296    fCurrentStateList[server] = State(state.index, state.index==DimState::kNotAvailable?"":state.name, state.comment, state.time);
     297    fMutex.unlock();
     298
     299    return GetCurrentState();
     300}
     301
     302State StateMachineDimControl::GetServerState(const std::string &server)
    303303{
    304304    const lock_guard<mutex> guard(fMutex);
    305305
    306306    const auto it = fCurrentStateList.find(server);
    307     return it==fCurrentStateList.end() ? make_pair(-256, string()) : it->second;
     307    return it==fCurrentStateList.end() ? State() : it->second;
    308308}
    309309
  • trunk/FACT++/src/StateMachineDimControl.h

    r14132 r14541  
    1818    std::set<Service> fServiceList;
    1919    std::map<std::string, std::vector<std::string>> fCommandList;
    20     std::map<std::string, std::pair<int32_t,  std::string>> fCurrentStateList;
     20    std::map<std::string, State> fCurrentStateList;
    2121    std::map<std::pair<std::string, int32_t>, std::pair<std::string, std::string>> fStateDescriptionList;
    2222    std::map<std::string, std::vector<Description>> fServiceDescriptionList;
     
    5959    int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="");
    6060
    61     std::pair<int32_t, std::string> GetServerState(const std::string &server);
     61    State GetServerState(const std::string &server);
    6262
    6363    void SendDimCommand(const std::string &server, std::string str, std::ostream &lout);
Note: See TracChangeset for help on using the changeset viewer.