Subversion Repositories HomeAutomation

Rev

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

Rev 1609 Rev 1625
Line 29... Line 29...
29
namespace vm {
29
namespace vm {
30
namespace plugin {
30
namespace plugin {
31
 
31
 
32
logging::Logger System::LOG("vm::plugin::System");
32
logging::Logger System::LOG("vm::plugin::System");
33
   
33
   
34
System::System(bool legacy)
34
System::System(boost::asio::io_service& io_service, bool legacy) : Plugin(io_service)
35
{
35
{
36
    this->name_ = "system";
36
    this->name_ = "system";
37
   
37
   
38
    this->legacy_ = legacy;
38
    this->legacy_ = legacy;
39
                 
39
                 
Line 47... Line 47...
47
 
47
 
48
}
48
}
49
 
49
 
50
void System::InitializeDone()
50
void System::InitializeDone()
51
{
51
{
-
 
52
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
53
   
52
    Plugin::InitializeDone();
54
    Plugin::InitializeDone();
53
   
55
   
54
    this->ImportFunction("Start");
56
    this->ImportFunction("Start");
55
   
57
   
56
    ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList);
58
    ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList);
57
   
59
   
58
    arguments->push_back(v8::Boolean::New(this->legacy_));
60
    arguments->push_back(v8::Boolean::New(this->legacy_));
59
   
61
   
60
    this->Call(0, "Start", arguments);
62
    this->Call(0, "Start", arguments);
61
}
63
}
62
 
64
 
63
Value System::Export_Log(const v8::Arguments& args)
65
Value System::Export_Log(const v8::Arguments& args)
64
{
66
{
-
 
67
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
68
   
-
 
69
    LOG.Debug(std::string(__FUNCTION__) + " called!");
-
 
70
   
65
    if (args.Length() < 1)
71
    if (args.Length() < 1)
66
    {
72
    {
67
        LOG.Error("To few arguments to log.");
73
        LOG.Error("To few arguments to log.");
68
    }
74
    }
69
   
75
   
70
    v8::String::AsciiValue str(args[0]);
76
    v8::String::AsciiValue str(args[0]);
71
   
77
   
72
    LOG.Info(*str);
78
    LOG.Info(*str);
73
   
79
   
74
    return v8::Undefined();
80
    return v8::Undefined();
75
}
81
}
76
 
82
 
77
Value System::Export_LoadScript(const v8::Arguments& args)
83
Value System::Export_LoadScript(const v8::Arguments& args)
78
{
84
{
-
 
85
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
86
   
79
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
87
    LOG.Debug(std::string(__FUNCTION__) + " called!");
80
   
88
   
81
    if (args.Length() < 1)
89
    if (args.Length() < 1)
82
    {
90
    {
83
        LOG.Error("To few arguments.");
91
        LOG.Error("To few arguments.");
84
    }
92
    }
85
   
93
   
86
    v8::String::AsciiValue str(args[0]);
94
    v8::String::AsciiValue str(args[0]);
87
   
95
   
88
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
96
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
89
}
97
}
90
 
98
 
91
Value System::Export_Execute(const v8::Arguments& args)
99
Value System::Export_Execute(const v8::Arguments& args)
92
{
100
{
-
 
101
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
102
   
93
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
103
    LOG.Debug(std::string(__FUNCTION__) + " called!");
94
   
104
   
95
    if (args.Length() < 1)
105
    if (args.Length() < 1)
96
    {
106
    {
97
        LOG.Error("To few arguments.");
107
        LOG.Error("To few arguments.");
98
    }
108
    }