Subversion Repositories HomeAutomation

Rev

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

Rev 1646 Rev 1647
Line 57... Line 57...
57
    Plugin::InitializeDone();
57
    Plugin::InitializeDone();
58
   
58
   
59
    this->ImportFunction("Timer_OnTimeout");
59
    this->ImportFunction("Timer_OnTimeout");
60
   
60
   
61
    timer::Manager::Instance()->ConnectSlots(timer::Manager::SignalOnTimeout::slot_type(&Timer::SlotOnTimeout, this, _1, _2).track(this->tracker_));
61
    timer::Manager::Instance()->ConnectSlots(timer::Manager::SignalOnTimeout::slot_type(&Timer::SlotOnTimeout, this, _1, _2).track(this->tracker_));
-
 
62
}
-
 
63
 
-
 
64
void Timer::CallOutput(unsigned int request_id, std::string output)
-
 
65
{
-
 
66
    LOG.Info(output);
62
}
67
}
63
 
68
 
64
void Timer::SlotOnTimeout(timer::TimerId timer_id, bool repeat)
69
void Timer::SlotOnTimeout(timer::TimerId timer_id, bool repeat)
65
{
70
{
66
    this->io_service_.post(boost::bind(&Timer::SlotOnTimeoutHandler, this, timer_id, repeat));
71
    this->io_service_.post(boost::bind(&Timer::SlotOnTimeoutHandler, this, timer_id, repeat));
Line 96... Line 101...
96
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
101
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
97
   
102
   
98
    if (args.Length() < 1)
103
    if (args.Length() < 1)
99
    {
104
    {
100
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
105
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
106
        return v8::Boolean::New(false);
101
    }
107
    }
102
   
108
   
103
    v8::String::AsciiValue time(args[0]);
109
    v8::String::AsciiValue time(args[0]);
104
   
110
   
105
    timer::TimerId timer_id = timer::Manager::Instance()->SetAlarm(*time);
111
    timer::TimerId timer_id = timer::Manager::Instance()->SetAlarm(*time);
Line 116... Line 122...
116
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
122
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
117
   
123
   
118
    if (args.Length() < 2)
124
    if (args.Length() < 2)
119
    {
125
    {
120
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
126
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
127
        return v8::Boolean::New(false);
121
    }
128
    }
122
   
129
   
123
    timer::TimerId timer_id = timer::Manager::Instance()->SetTimer(args[0]->Uint32Value(), args[1]->BooleanValue());
130
    timer::TimerId timer_id = timer::Manager::Instance()->SetTimer(args[0]->Uint32Value(), args[1]->BooleanValue());
124
   
131
   
125
    Timer::timers_.insert(timer_id);
132
    Timer::timers_.insert(timer_id);
Line 134... Line 141...
134
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
141
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
135
   
142
   
136
    if (args.Length() < 1)
143
    if (args.Length() < 1)
137
    {
144
    {
138
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
145
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
146
        return v8::Boolean::New(false);
139
    }
147
    }
140
   
148
   
141
    Timers::iterator it = Timer::timers_.find(args[0]->IsUint32());
149
    Timers::iterator it = Timer::timers_.find(args[0]->IsUint32());
142
   
150
   
143
    if (it != Timer::timers_.end())
151
    if (it != Timer::timers_.end())
Line 156... Line 164...
156
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
164
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
157
   
165
   
158
    if (args.Length() < 1)
166
    if (args.Length() < 1)
159
    {
167
    {
160
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
168
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
169
        return v8::Boolean::New(false);
161
    }
170
    }
162
   
171
   
163
    boost::this_thread::sleep(boost::posix_time::milliseconds(args[0]->Uint32Value()));
172
    boost::this_thread::sleep(boost::posix_time::milliseconds(args[0]->Uint32Value()));
164
   
173
   
165
    return v8::Undefined();
174
    return v8::Undefined();