Subversion Repositories HomeAutomation

Rev

Rev 1646 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1646 Rev 1768
Line 23... Line 23...
23
#include <boost/date_time/posix_time/posix_time.hpp>
23
#include <boost/date_time/posix_time/posix_time.hpp>
24
 
24
 
25
namespace atom {
25
namespace atom {
26
namespace timer {
26
namespace timer {
27
 
27
 
28
Timer::Timer(boost::asio::io_service& io_service, TimerId id, unsigned int timeout, bool repeat) : instance_(io_service)
28
Timer::Timer(boost::asio::io_service& io_service, TimerId id, unsigned int timeout, bool repeat) : instance_(io_service), LOG("timer::Timer")
29
{
29
{
30
    this->id_ = id;
30
    this->id_ = id;
31
    this->timeout_ = timeout;
31
    this->timeout_ = timeout;
32
    this->repeat_ = repeat;
32
    this->repeat_ = repeat;
33
    this->time_ = "";
33
    this->time_ = "";
34
}
34
}
35
 
35
 
36
Timer::Timer(boost::asio::io_service& io_service, TimerId id, std::string time) : instance_(io_service)
36
Timer::Timer(boost::asio::io_service& io_service, TimerId id, std::string time) : instance_(io_service), LOG("timer::Timer")
37
{
37
{
38
    this->id_ = id;
38
    this->id_ = id;
39
    this->timeout_ = 0;
39
    this->timeout_ = 0;
40
    this->repeat_ = false;
40
    this->repeat_ = false;
41
    this->time_ = time;
41
    this->time_ = time;
Line 74... Line 74...
74
    this->instance_.cancel();
74
    this->instance_.cancel();
75
}
75
}
76
 
76
 
77
void Timer::TimeoutHandler(const boost::system::error_code& error)
77
void Timer::TimeoutHandler(const boost::system::error_code& error)
78
{
78
{
-
 
79
    if (error.value() != 0)
-
 
80
    {
-
 
81
        return;
-
 
82
    }
-
 
83
   
79
    if (this->repeat_)
84
    if (this->repeat_)
80
    {
85
    {
81
        this->Start();
86
        this->Start();
82
    }
87
    }
83
   
88