Subversion Repositories HomeAutomation

Rev

Rev 1657 | Rev 1788 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1657 Rev 1665
Line 41... Line 41...
41
class Node
41
class Node
42
{
42
{
43
public:
43
public:
44
    typedef boost::shared_ptr<Node> Pointer;
44
    typedef boost::shared_ptr<Node> Pointer;
45
    typedef std::string Id;
45
    typedef std::string Id;
-
 
46
   
-
 
47
    typedef struct
-
 
48
    {
-
 
49
        bool valid_;
-
 
50
        unsigned int bios_version_;
-
 
51
        std::string device_type_;
-
 
52
        bool has_application_;
-
 
53
        time_t last_active_;
-
 
54
    } Information;
46
   
55
   
47
    typedef enum
56
    typedef enum
48
    {
57
    {
49
        STATE_INVALID,
58
        STATE_INVALID,
50
        STATE_NO_CHANGE,
59
        STATE_NO_CHANGE,
Line 60... Line 69...
60
        STATE_APGM_OFFLINE,
69
        STATE_APGM_OFFLINE,
61
        STATE_APGM_START,
70
        STATE_APGM_START,
62
        STATE_APGM_DATA,
71
        STATE_APGM_DATA,
63
        STATE_APGM_END,
72
        STATE_APGM_END,
64
    } State;
73
    } State;
65
 
74
 
66
    typedef enum
75
    typedef enum
67
    {
76
    {
68
        EVENT_BIOS_START,
77
        EVENT_BIOS_START,
69
        EVENT_APP_START,
78
        EVENT_APP_START,
70
        EVENT_HEARTBEAT,
79
        EVENT_HEARTBEAT,
Line 75... Line 84...
75
        EVENT_PROGRAM_APP,
84
        EVENT_PROGRAM_APP,
76
        EVENT_RESET
85
        EVENT_RESET
77
    } Event;
86
    } Event;
78
   
87
   
79
    typedef boost::signals2::signal<void(Id, State, State)> SignalOnNewState;
88
    typedef boost::signals2::signal<void(Id, State, State)> SignalOnNewState;
80
   
-
 
81
   
89
   
82
    Node(Id id);
90
    Node(Id id);
83
    virtual ~Node();
91
    virtual ~Node();
84
   
92
   
85
    static void SetupStateMachine();
93
    static void SetupStateMachine();
86
   
94
   
87
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state);
95
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state);
88
   
96
   
89
    Id GetId();
97
    Id GetId();
-
 
98
    Information GetInformation();
-
 
99
    unsigned int GetBiosVersion();
-
 
100
    bool HasApplication();
90
    State GetState();
101
    State GetState();
91
 
102
 
92
    void Trigger(Event event, common::StringMap variables);
103
    void Trigger(Event event, common::StringMap variables);
93
   
104
   
94
    bool CheckTimeout();
105
    bool CheckTimeout();
Line 101... Line 112...
101
private:
112
private:
102
    typedef std::map<Event, State> Transition;
113
    typedef std::map<Event, State> Transition;
103
    typedef std::map<State, Transition> TransitionList;
114
    typedef std::map<State, Transition> TransitionList;
104
   
115
   
105
    Id id_;
116
    Id id_;
-
 
117
    Information information_;    
106
    State state_;
118
    State state_;
107
    time_t last_active_;
-
 
108
    SignalOnNewState signal_on_new_state_;
-
 
109
    logging::Logger LOG;
119
   
110
    Code::Pointer code_;
120
    Code::Pointer code_;
111
    unsigned int start_offset_;
121
    unsigned int start_offset_;
112
    unsigned int current_offset_;
122
    unsigned int current_offset_;
113
    unsigned int expected_ack_data_;
123
    unsigned int expected_ack_data_;
114
    time_t program_start_time_;
124
    time_t program_start_time_;
115
   
125
 
-
 
126
    logging::Logger LOG;
116
   
127
   
117
    static TransitionList transitions_;
128
    static TransitionList transitions_;
118
    static std::map<State, std::string> state_names_;
129
    static std::map<State, std::string> state_names_;
119
    static std::map<Event, std::string> event_names_;
130
    static std::map<Event, std::string> event_names_;
-
 
131
   
-
 
132
    SignalOnNewState signal_on_new_state_;
120
   
133
   
121
    static void AddTransition(State current_state, Event event, State target_state);
134
    static void AddTransition(State current_state, Event event, State target_state);
122
   
135
   
123
    State GetTransitionTarget(Event event);
136
    State GetTransitionTarget(Event event);
124
    void SendReset();
137
    void SendReset();