Rev 1596 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1596 | Rev 1602 | ||
|---|---|---|---|
| 1 | /* |
1 | /* |
| 2 | * |
2 | * |
| 3 | * Copyright (C) 2010 Mattias Runge |
3 | * Copyright (C) 2010 Mattias Runge |
| 4 | * |
4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
8 | * (at your option) any later version. |
| 9 | * |
9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
13 | * GNU General Public License for more details. |
| 14 | * |
14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
18 | * |
| 19 | */ |
19 | */ |
| 20 | 20 | ||
| 21 | #include "Message.h" |
21 | #include "Message.h" |
| 22 | 22 | ||
| 23 | #include "Protocol.h" |
23 | #include "Protocol.h" |
| 24 | 24 | ||
| 25 | namespace atom { |
25 | namespace atom { |
| 26 | namespace can { |
26 | namespace can { |
| 27 | 27 | ||
| 28 | Message::Message(std::string class_name, std::string direction_name, std::string module_name, unsigned int id, std::string command_name) |
28 | Message::Message(std::string class_name, std::string direction_name, std::string module_name, unsigned int id, std::string command_name) |
| 29 | { |
29 | { |
| 30 | this->class_name_ = class_name; |
30 | this->class_name_ = class_name; |
| 31 | this->direction_name_ = direction_name; |
31 | this->direction_name_ = direction_name; |
| 32 | this->module_name_ = module_name; |
32 | this->module_name_ = module_name; |
| 33 | this->id_ = id; |
33 | this->id_ = id; |
| 34 | this->command_name_ = command_name; |
34 | this->command_name_ = command_name; |
| 35 | 35 | ||
| 36 | xml::Node::NodeList variable_nodes; |
36 | xml::Node::NodeList variable_nodes; |
| 37 | 37 | ||
| 38 | if (class_name == "nmt") |
38 | if (class_name == "nmt") |
| 39 | { |
39 | { |
| 40 | variable_nodes = Protocol::Instance()->GetNMTCommandVariables(command_name); |
40 | variable_nodes = Protocol::Instance()->GetNMTCommandVariables(command_name); |
| 41 | } |
41 | } |
| 42 | else |
42 | else |
| 43 | { |
43 | { |
| 44 | variable_nodes = Protocol::Instance()->GetCommandVariables(command_name, module_name); |
44 | variable_nodes = Protocol::Instance()->GetCommandVariables(command_name, module_name); |
| 45 | } |
45 | } |
| 46 | 46 | ||
| 47 | for (unsigned int n = 0; n < variable_nodes.size(); n++) |
47 | for (unsigned int n = 0; n < variable_nodes.size(); n++) |
| 48 | { |
48 | { |
| 49 | this->variables_[variable_nodes[n].GetAttributeValue("name")] = ""; |
49 | this->variables_[variable_nodes[n].GetAttributeValue("name")] = ""; |
| 50 | } |
50 | } |
| 51 | } |
51 | } |
| 52 | 52 | ||
| 53 | Message::~Message() |
53 | Message::~Message() |
| 54 | { |
54 | { |
| 55 | 55 | ||
| 56 | } |
56 | } |
| 57 | 57 | ||
| 58 | std::string Message::GetClassName() |
58 | std::string Message::GetClassName() |
| 59 | { |
59 | { |
| 60 | return this->class_name_; |
60 | return this->class_name_; |
| 61 | } |
61 | } |
| 62 | 62 | ||
| 63 | std::string Message::GetDirectionName() |
63 | std::string Message::GetDirectionName() |
| 64 | { |
64 | { |
| 65 | return this->direction_name_; |
65 | return this->direction_name_; |
| 66 | } |
66 | } |
| 67 | 67 | ||
| 68 | std::string Message::GetModuleName() |
68 | std::string Message::GetModuleName() |
| 69 | { |
69 | { |
| 70 | return this->module_name_; |
70 | return this->module_name_; |
| 71 | } |
71 | } |
| 72 | 72 | ||
| 73 | unsigned int Message::GetId() |
73 | unsigned int Message::GetId() |
| 74 | { |
74 | { |
| 75 | return this->id_; |
75 | return this->id_; |
| 76 | } |
76 | } |
| 77 | 77 | ||
| 78 | std::string Message::GetCommandName() |
78 | std::string Message::GetCommandName() |
| 79 | { |
79 | { |
| 80 | return this->command_name_; |
80 | return this->command_name_; |
| 81 | } |
81 | } |
| 82 | 82 | ||
| 83 | std::string Message::GetVariable(std::string name) |
83 | std::string Message::GetVariable(std::string name) |
| 84 | { |
84 | { |
| 85 | return this->variables_[name]; |
85 | return this->variables_[name]; |
| 86 | } |
86 | } |
| 87 | 87 | ||
| 88 | void Message::SetVariable(std::string name, std::string value) |
88 | void Message::SetVariable(std::string name, std::string value) |
| 89 | { |
89 | { |
| 90 | this->variables_[name] = value; |
90 | this->variables_[name] = value; |
| 91 | } |
91 | } |
| 92 | 92 | ||
| 93 |
|
93 | type::StringMap& Message::GetVariables() |
| 94 | { |
94 | { |
| 95 | return this->variables_; |
95 | return this->variables_; |
| - | 96 | } |
|
| - | 97 | ||
| - | 98 | void Message::SetVariables(type::StringMap variables) |
|
| - | 99 | { |
|
| - | 100 | this->variables_ = variables; |
|
| 96 | } |
101 | } |
| 97 | 102 | ||
| 98 | }; // namespace can |
103 | }; // namespace can |
| 99 | }; // namespace atom |
104 | }; // namespace atom |
| 100 | 105 | ||