Rev 1644 | Rev 1650 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1644 | Rev 1647 | ||
|---|---|---|---|
| Line 53... | Line 53... | ||
| 53 | this->ImportFunction("Module_OnMessage"); |
53 | this->ImportFunction("Module_OnMessage"); |
| 54 | 54 | ||
| 55 | control::Manager::Instance()->ConnectSlots(control::Manager::SignalOnNodeChange::slot_type(&Module::SlotOnNodeChange, this, _1, _2).track(this->tracker_), |
55 | control::Manager::Instance()->ConnectSlots(control::Manager::SignalOnNodeChange::slot_type(&Module::SlotOnNodeChange, this, _1, _2).track(this->tracker_), |
| 56 | control::Manager::SignalOnModuleChange::slot_type(&Module::SlotOnModuleChange, this, _1, _2).track(this->tracker_), |
56 | control::Manager::SignalOnModuleChange::slot_type(&Module::SlotOnModuleChange, this, _1, _2).track(this->tracker_), |
| 57 | control::Manager::SignalOnModuleMessage::slot_type(&Module::SlotOnModuleMessage, this, _1, _2, _3).track(this->tracker_)); |
57 | control::Manager::SignalOnModuleMessage::slot_type(&Module::SlotOnModuleMessage, this, _1, _2, _3).track(this->tracker_)); |
| - | 58 | } |
|
| - | 59 | ||
| - | 60 | void Module::CallOutput(unsigned int request_id, std::string output) |
|
| - | 61 | { |
|
| - | 62 | LOG.Info(output); |
|
| 58 | } |
63 | } |
| 59 | 64 | ||
| 60 | void Module::SlotOnNodeChange(unsigned int node_id, bool available) |
65 | void Module::SlotOnNodeChange(unsigned int node_id, bool available) |
| 61 | { |
66 | { |
| 62 | this->io_service_.post(boost::bind(&Module::SlotOnNodeChangeHandler, this, node_id, available)); |
67 | this->io_service_.post(boost::bind(&Module::SlotOnNodeChangeHandler, this, node_id, available)); |
| Line 76... | Line 81... | ||
| 76 | { |
81 | { |
| 77 | 82 | ||
| 78 | } |
83 | } |
| 79 | 84 | ||
| 80 | void Module::SlotOnModuleChangeHandler(std::string full_id, bool available) |
85 | void Module::SlotOnModuleChangeHandler(std::string full_id, bool available) |
| 81 | { |
86 | { |
| 82 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
87 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 83 | 88 | ||
| 84 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
89 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 85 | 90 | ||
| 86 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
91 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
| 87 | arguments->push_back(v8::String::New(full_id.data())); |
92 | arguments->push_back(v8::String::New(full_id.data())); |
| 88 | arguments->push_back(v8::Boolean::New(available)); |
93 | arguments->push_back(v8::Boolean::New(available)); |
| 89 | 94 | ||
| 90 | this->Call(0, "Module_OnChange", arguments); |
95 | this->Call(0, "Module_OnChange", arguments); |
| 91 | } |
96 | } |
| 92 | 97 | ||
| 93 | void Module::SlotOnModuleMessageHandler(std::string full_id, std::string command, common::StringMap variables) |
98 | void Module::SlotOnModuleMessageHandler(std::string full_id, std::string command, common::StringMap variables) |
| 94 | { |
99 | { |
| 95 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
100 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 96 | 101 | ||
| 97 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
102 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 98 | 103 | ||
| 99 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
104 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
| 100 | 105 | ||
| 101 | arguments->push_back(v8::String::New(full_id.data())); |
106 | arguments->push_back(v8::String::New(full_id.data())); |
| 102 | arguments->push_back(v8::String::New(command.data())); |
107 | arguments->push_back(v8::String::New(command.data())); |
| 103 | 108 | ||
| 104 | v8::Local<v8::Array> vars = v8::Array::New(variables.size()); |
109 | v8::Local<v8::Array> vars = v8::Array::New(variables.size()); |
| 105 | 110 | ||
| 106 | for (common::StringMap::iterator it = variables.begin(); it != variables.end(); it++) |
111 | for (common::StringMap::iterator it = variables.begin(); it != variables.end(); it++) |
| 107 | { |
112 | { |
| 108 | vars->Set(v8::String::New(it->first.data()), v8::String::New(it->second.data())); |
113 | vars->Set(v8::String::New(it->first.data()), v8::String::New(it->second.data())); |
| 109 | } |
114 | } |
| 110 | 115 | ||
| 111 | arguments->push_back(vars); |
116 | arguments->push_back(vars); |
| 112 | 117 | ||
| 113 | this->Call(0, "Module_OnMessage", arguments); |
118 | this->Call(0, "Module_OnMessage", arguments); |
| 114 | } |
119 | } |
| 115 | 120 | ||
| 116 | Value Module::Export_SendModuleMessage(const v8::Arguments& args) |
121 | Value Module::Export_SendModuleMessage(const v8::Arguments& args) |
| 117 | { |
122 | { |
| 118 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
123 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 119 | 124 | ||
| 120 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
125 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 121 | 126 | ||
| 122 | if (args.Length() < 3) |
127 | if (args.Length() < 3) |
| 123 | { |
128 | { |
| 124 | LOG.Error("To few arguments."); |
129 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| - | 130 | return v8::Boolean::New(false); |
|
| 125 | } |
131 | } |
| 126 | 132 | ||
| 127 | common::StringMap variables; |
133 | common::StringMap variables; |
| 128 | 134 | ||
| 129 | v8::String::AsciiValue full_id(args[0]); |
135 | v8::String::AsciiValue full_id(args[0]); |
| Line 152... | Line 158... | ||
| 152 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
158 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 153 | 159 | ||
| 154 | if (args.Length() < 1) |
160 | if (args.Length() < 1) |
| 155 | { |
161 | { |
| 156 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
162 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| - | 163 | return v8::Boolean::New(false); |
|
| 157 | } |
164 | } |
| 158 | 165 | ||
| 159 | common::StringList available_modules = control::Manager::Instance()->GetAvailableModules(); |
166 | common::StringList available_modules = control::Manager::Instance()->GetAvailableModules(); |
| 160 | 167 | ||
| 161 | v8::Local<v8::Array> result = v8::Array::New(available_modules.size()); |
168 | v8::Local<v8::Array> result = v8::Array::New(available_modules.size()); |
| Line 175... | Line 182... | ||
| 175 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
182 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 176 | 183 | ||
| 177 | if (args.Length() < 3) |
184 | if (args.Length() < 3) |
| 178 | { |
185 | { |
| 179 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
186 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| - | 187 | return v8::Boolean::New(false); |
|
| 180 | } |
188 | } |
| 181 | 189 | ||
| 182 | v8::String::AsciiValue filename(args[2]); |
190 | v8::String::AsciiValue filename(args[2]); |
| 183 | 191 | ||
| 184 | return v8::Boolean::New(control::Manager::Instance()->ProgramNode(args[0]->Uint32Value(), args[1]->BooleanValue(), std::string(*filename))); |
192 | return v8::Boolean::New(control::Manager::Instance()->ProgramNode(args[0]->Uint32Value(), args[1]->BooleanValue(), std::string(*filename))); |