Subversion Repositories HomeAutomation

Rev

Rev 1602 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

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