Commands::getEbusCommand expanded for cycle messages to check 'QQ' byte too.

This commit is contained in:
Roland Jax
2014-11-08 12:15:31 +01:00
parent ca6c6c04bb
commit 14d632683b
4 changed files with 16 additions and 11 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
} }
std::string ebusCommand(A.getParam<const char*>("p_address")); std::string ebusCommand(A.getParam<const char*>("p_address"));
ebusCommand += m_commands->getEbusCommand(index); ebusCommand += m_commands->getEbusCommand(index, false);
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower); std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
BusCommand* busCommand = new BusCommand(ebusCommand, false); BusCommand* busCommand = new BusCommand(ebusCommand, false);
@@ -190,7 +190,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
if (index >= 0) { if (index >= 0) {
std::string ebusCommand(A.getParam<const char*>("p_address")); std::string ebusCommand(A.getParam<const char*>("p_address"));
ebusCommand += m_commands->getEbusCommand(index); ebusCommand += m_commands->getEbusCommand(index, false);
// encode data // encode data
Command* command = new Command(index, (*m_commands)[index], cmd[3]); Command* command = new Command(index, (*m_commands)[index], cmd[3]);
+1 -1
View File
@@ -267,7 +267,7 @@ void EBusLoop::addPollCommand()
L.log(bus, event, " polling [%4d] %s", index, tmp.c_str()); L.log(bus, event, " polling [%4d] %s", index, tmp.c_str());
std::string ebusCommand(A.getParam<const char*>("p_address")); std::string ebusCommand(A.getParam<const char*>("p_address"));
ebusCommand += m_commands->getEbusCommand(index); ebusCommand += m_commands->getEbusCommand(index, false);
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower); std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
BusCommand* busCommand = new BusCommand(ebusCommand, true); BusCommand* busCommand = new BusCommand(ebusCommand, true);
+12 -7
View File
@@ -127,15 +127,20 @@ int Commands::findCommand(const std::string& data) const
return -1; return -1;
} }
std::string Commands::getEbusCommand(const int index) const std::string Commands::getEbusCommand(const int index, const bool cycle) const
{ {
cmd_t command = m_cmdDB.at(index); cmd_t command = m_cmdDB.at(index);
std::string cmd(command[5]); std::string cmd;
cmd += command[6];
std::stringstream sstr; std::stringstream sstr;
if (cycle == true)
cmd += command[4]; // QQ
cmd += command[5]; // ZZ
cmd += command[6]; // PBSB
sstr << std::setw(2) << std::hex << std::setfill('0') << command[7]; sstr << std::setw(2) << std::hex << std::setfill('0') << command[7];
cmd += sstr.str(); cmd += sstr.str(); // NN
cmd += command[8]; cmd += command[8]; // Dx
return cmd; return cmd;
} }
@@ -158,7 +163,7 @@ int Commands::storeCycData(const std::string& data) const
// walk through commands // walk through commands
for (; iter != m_cycDB.end(); iter++) { for (; iter != m_cycDB.end(); iter++) {
std::string command = getEbusCommand(iter->first); std::string command = getEbusCommand(iter->first, true);
// skip wrong search string length // skip wrong search string length
if (command.length() > search.length()) if (command.length() > search.length())
@@ -211,7 +216,7 @@ void Commands::storePolData(const std::string& data) const
// walk through commands // walk through commands
for (; iter != m_polDB.end(); iter++) { for (; iter != m_polDB.end(); iter++) {
std::string command = getEbusCommand(iter->first); std::string command = getEbusCommand(iter->first, false);
// skip wrong search string length // skip wrong search string length
if (command.length() > search.length()) if (command.length() > search.length())
+1 -1
View File
@@ -56,7 +56,7 @@ public:
std::string getCmdType(const int index) const { return std::string(m_cmdDB.at(index)[0]); } std::string getCmdType(const int index) const { return std::string(m_cmdDB.at(index)[0]); }
std::string getEbusType(const int index) const { return std::string(m_cmdDB.at(index)[4]); } std::string getEbusType(const int index) const { return std::string(m_cmdDB.at(index)[4]); }
std::string getEbusCommand(const int index) const; std::string getEbusCommand(const int index, const bool cycle) const;
int storeCycData(const std::string& data) const; int storeCycData(const std::string& data) const;
std::string getCycData(int index) const; std::string getCycData(int index) const;