Subversion Repositories HomeAutomation

Rev

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

Rev 1657 Rev 1665
Line 21... Line 21...
21
#include "Node.h"
21
#include "Node.h"
22
 
22
 
23
#include <boost/lexical_cast.hpp>
23
#include <boost/lexical_cast.hpp>
24
 
24
 
25
#include "control/Manager.h"
25
#include "control/Manager.h"
-
 
26
#include "control/Node.h"
26
#include "vm/Manager.h"
27
#include "vm/Manager.h"
27
 
28
 
28
namespace atom {
29
namespace atom {
29
namespace vm {
30
namespace vm {
30
namespace plugin {
31
namespace plugin {
Line 36... Line 37...
36
    this->name_ = "node";
37
    this->name_ = "node";
37
   
38
   
38
    this->ExportFunction("NodeExport_ResetNode",         Node::Export_ResetNode);
39
    this->ExportFunction("NodeExport_ResetNode",         Node::Export_ResetNode);
39
    this->ExportFunction("NodeExport_GetAvailableNodes", Node::Export_GetAvailableNodes);
40
    this->ExportFunction("NodeExport_GetAvailableNodes", Node::Export_GetAvailableNodes);
40
    this->ExportFunction("NodeExport_ProgramNode",       Node::Export_ProgramNode);
41
    this->ExportFunction("NodeExport_ProgramNode",       Node::Export_ProgramNode);
-
 
42
    this->ExportFunction("NodeExport_GetNodeInformation",Node::Export_GetNodeInformation);
41
}
43
}
42
 
44
 
43
Node::~Node()
45
Node::~Node()
44
{
46
{
45
    this->tracker_.reset();
47
    this->tracker_.reset();
Line 104... Line 106...
104
   
106
   
105
    v8::Local<v8::Array> result = v8::Array::New(available_nodes.size());
107
    v8::Local<v8::Array> result = v8::Array::New(available_nodes.size());
106
   
108
   
107
    for (unsigned int n = 0; n < available_nodes.size(); n++)
109
    for (unsigned int n = 0; n < available_nodes.size(); n++)
108
    {
110
    {
109
        LOG.Debug(boost::lexical_cast<std::string>(n) + ": " + available_nodes[n]);
-
 
110
        result->Set(n, v8::String::New(available_nodes[n].data()));
111
        result->Set(n, v8::String::New(available_nodes[n].data()));
111
    }
112
    }
112
   
113
   
113
    return result;
114
    return result;
114
}
115
}
Line 127... Line 128...
127
   
128
   
128
    v8::String::AsciiValue node_id(args[0]);
129
    v8::String::AsciiValue node_id(args[0]);
129
    v8::String::AsciiValue filename(args[2]);
130
    v8::String::AsciiValue filename(args[2]);
130
   
131
   
131
    return v8::Boolean::New(control::Manager::Instance()->ProgramNode(*node_id, args[1]->BooleanValue(), std::string(*filename)));
132
    return v8::Boolean::New(control::Manager::Instance()->ProgramNode(*node_id, args[1]->BooleanValue(), std::string(*filename)));
-
 
133
}
-
 
134
 
-
 
135
Value Node::Export_GetNodeInformation(const v8::Arguments& args)
-
 
136
{
-
 
137
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
138
   
-
 
139
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
-
 
140
   
-
 
141
    if (args.Length() < 1)
-
 
142
    {
-
 
143
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
144
        return v8::Boolean::New(false);
-
 
145
    }
-
 
146
   
-
 
147
    v8::String::AsciiValue node_id(args[0]);
-
 
148
   
-
 
149
    control::Node::Information information;
-
 
150
   
-
 
151
    try
-
 
152
    {
-
 
153
        information = control::Manager::Instance()->GetNodeInformation(*node_id);
-
 
154
    }
-
 
155
    catch (std::runtime_error& e)
-
 
156
    {
-
 
157
        LOG.Error(e.what());
-
 
158
        return v8::Undefined();
-
 
159
    }
-
 
160
   
-
 
161
    v8::Local<v8::Array> result = v8::Array::New(6);
-
 
162
   
-
 
163
    result->Set(v8::String::New("Id"),            args[0]);
-
 
164
    result->Set(v8::String::New("Valid"),         v8::Boolean::New(information.valid_));
-
 
165
    result->Set(v8::String::New("BiosVersion"),   v8::Uint32::New(information.bios_version_));
-
 
166
    result->Set(v8::String::New("DeviceType"),    v8::String::New(information.device_type_.data()));
-
 
167
    result->Set(v8::String::New("HasApplication"),v8::Boolean::New(information.has_application_));
-
 
168
    result->Set(v8::String::New("LastActive"),    v8::Uint32::New(information.last_active_));
-
 
169
   
-
 
170
    return result;
132
}
171
}
133
   
172
 
134
}; // namespace plugin
173
}; // namespace plugin
135
}; // namespace vm
174
}; // namespace vm
136
}; // namespace atom
175
}; // namespace atom