Subversion Repositories HomeAutomation

Rev

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

Rev 1309 Rev 1310
Line 16... Line 16...
16
 
16
 
17
    this->myModuletype = moduletype;
17
    this->myModuletype = moduletype;
18
    this->myModuleId = moduleId;
18
    this->myModuleId = moduleId;
19
    this->myType = type;
19
    this->myType = type;
20
 
20
 
21
    // TODO Check if this message is supported for the module
21
    xml::Node moduleNode = db::Database::getInstance()->getRootNode().selectFirst("modules").selectFirst("module", xml::Node::attributePair("name", moduletype));
-
 
22
    xml::Node messageNode = db::Database::getInstance()->getRootNode().selectFirst("messagetypes").selectFirst("messagetype", xml::Node::attributePair("name", type));
22
 
23
 
-
 
24
    xml::Node::nodeList variableNodes = messageNode.select("variable");
-
 
25
 
-
 
26
    for (unsigned int n = 0; n < variableNodes.size(); n++)
-
 
27
    {
-
 
28
        Variable variable(variableNodes[n]["name"], variableNodes[n]["datatype"], stob(variableNodes[n]["required"]), variableNodes[n]["unit"]);
-
 
29
        this->myVariables[variableNodes[n]["name"]] = variable;
-
 
30
    }
-
 
31
 
-
 
32
    if (moduleNode.selectFirst("in").select("message", xml::Node::attributePair("name", type)).size() > 0)
-
 
33
    {
-
 
34
        this->myFromModule = false;
-
 
35
    }
-
 
36
    else if (moduleNode.selectFirst("out").select("message", xml::Node::attributePair("name", type)).size() > 0)
-
 
37
    {
-
 
38
        this->myFromModule = true;
-
 
39
    }
-
 
40
    else
-
 
41
    {
-
 
42
        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.");
-
 
43
        // TODO throw exception
-
 
44
    }
-
 
45
 
-
 
46
    xml::Node::nodeList responseNodes = messageNode.select("response");
-
 
47
 
-
 
48
    for (unsigned int n = 0; n < responseNodes.size(); n++)
-
 
49
    {
23
    // TODO Find if this is in our out on module, if out then set myFromModule = true
50
        this->myResponses.push_back(responseNodes[n]["code"]); // TODO Validate the code
-
 
51
    }
24
 
52
 
25
    // TODO Convert type into variables
-
 
26
    // TODO Convert type into responses
-
 
27
}
53
}
28
 
54
 
29
Message::Message()
55
Message::Message()
30
{
56
{
31
}
57
}