Subversion Repositories HomeAutomation

Rev

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

Rev 1598 Rev 1601
Line 17... Line 17...
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
18
 *
19
 */
19
 */
20
 
20
 
21
#include "Node.h"
21
#include "Node.h"
-
 
22
 
-
 
23
#include <boost/date_time/posix_time/posix_time.hpp>
22
 
24
 
23
#include "Message.h"
25
#include "Message.h"
24
#include "broker/Manager.h"
26
#include "broker/Manager.h"
25
 
27
 
26
namespace atom {
28
namespace atom {
27
namespace can {
29
namespace can {
28
   
30
   
29
Node::Node(Node::Id id)
31
Node::Node(Node::Id id)
30
{
32
{
31
    this->state_ = STATE_OFFLINE;
33
    this->state_ = STATE_OFFLINE;
32
    this->id_ = id;
34
    this->id_ = id;
33
}
35
}
34
 
36
 
35
Node::~Node()
37
Node::~Node()
36
{
38
{
37
 
39
 
38
}
40
}
39
 
41
 
40
Node::Id Node::GetId()
42
Node::Id Node::GetId()
41
{
43
{
42
    return this->id_;
44
    return this->id_;
43
}
45
}
44
 
46
 
45
Node::State Node::GetState()
47
Node::State Node::GetState()
46
{
48
{
47
    return this->state_;
49
    return this->state_;
48
}
50
}
49
 
51
 
50
void Node::SetState(Node::State state)
52
void Node::SetState(Node::State state)
-
 
53
{
-
 
54
    this->state_ = state;
-
 
55
}
-
 
56
 
-
 
57
bool Node::CheckTimeout()
-
 
58
{
-
 
59
    if (this->last_active_ + 10 < time(NULL))
-
 
60
    {
-
 
61
        this->state_ = STATE_OFFLINE;
-
 
62
        return false;
-
 
63
    }
-
 
64
   
-
 
65
    return true;
-
 
66
}
-
 
67
 
-
 
68
void Node::ResetTimeout()
51
{
69
{
52
    this->state_ = state;
70
    this->last_active_ = time(NULL);
53
}
71
}
54
   
72
   
55
}; // namespace can
73
}; // namespace can
56
}; // namespace atom
74
}; // namespace atom