Subversion Repositories HomeAutomation

Rev

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

Rev 1323 Rev 1326
Line 36... Line 36...
36
    }
36
    }
37
 
37
 
38
    // Check if valid for this module
38
    // Check if valid for this module
39
    xml::Node moduleNode = Protocol::getInstance()->getRootNode().selectFirst("modules").selectFirst("module", xml::Node::attributePair("name", this->myHeader.getModuleType()));
39
    xml::Node moduleNode = Protocol::getInstance()->getRootNode().selectFirst("modules").selectFirst("module", xml::Node::attributePair("name", this->myHeader.getModuleType()));
40
 
40
 
41
    if (moduleNode.selectFirst("in").select("message", xml::Node::attributePair("name", this->myHeader.getModuleType())).size() == 0 &&
41
    if (moduleNode.selectFirst("in").select("message", xml::Node::attributePair("name", this->myHeader.getMessageType())).size() == 0 &&
42
        moduleNode.selectFirst("out").select("message", xml::Node::attributePair("name", this->myHeader.getModuleType())).size() == 0)
42
        moduleNode.selectFirst("out").select("message", xml::Node::attributePair("name", this->myHeader.getMessageType())).size() == 0)
43
    {
43
    {
44
        LOG.error("This message is not supported by this module type, something is wrong; protocol.xml is old, module code is old or a Atom is trying to send and illegal message.");
44
        LOG.error("This message is not supported by this module type, something is wrong; protocol.xml is old, module code is old or a Atom is trying to send and illegal message.");
45
        // TODO throw exception
45
        // TODO throw exception
46
    }
46
    }
47
}
47
}
Line 76... Line 76...
76
Variable & Message::getVariable(string name)
76
Variable & Message::getVariable(string name)
77
{
77
{
78
    return this->myVariables[name];
78
    return this->myVariables[name];
79
 
79
 
80
    // TODO Check if it does not exist, throw exception?
80
    // TODO Check if it does not exist, throw exception?
-
 
81
}
-
 
82
 
-
 
83
Message::variableMap & Message::getVariables()
-
 
84
{
-
 
85
    return this->myVariables;
81
}
86
}
82
 
87
 
83
Message::responseList Message::getResponses()
88
Message::responseList Message::getResponses()
84
{
89
{
85
    return this->myResponses;
90
    return this->myResponses;
86
}
91
}
87
 
92
 
88
 
93
 
89
void Message::readBits(BitBuffer & buffer)
94
void Message::readBits(BitBuffer & buffer)
90
{
95
{
91
    for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
96
    for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
92
    {
97
    {
93
        iter->second.readBits(buffer);
98
        iter->second.readBits(buffer);
94
    }
99
    }
95
}
100
}
96
 
101
 
97
void Message::writeBits(BitBuffer & buffer)
102
void Message::writeBits(BitBuffer & buffer)
98
{
103
{
99
    for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
104
    for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
100
    {
105
    {
101
        iter->second.writeBits(buffer);
106
        iter->second.writeBits(buffer);
102
    }
107
    }
-
 
108
}
-
 
109
 
-
 
110
string Message::toString()
-
 
111
{
-
 
112
    string buffer = this->myHeader.toString() + "::Message(";
-
 
113
 
-
 
114
    for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
-
 
115
    {
-
 
116
        buffer += iter->second.toString() + ",";
103
}
117
    }
104
 
118
 
-
 
119
    trim_if(buffer, is_any_of(","));
-
 
120
 
-
 
121
    buffer += ")";
-
 
122
 
-
 
123
    return buffer;
-
 
124
}
105
 
125
 
106
}
126
}
107
}
127
}