class BaseLoop: adapted for Command::calcResult
This commit is contained in:
+24
-13
@@ -57,7 +57,7 @@ void BaseLoop::start()
|
|||||||
std::string BaseLoop::decodeMessage(const std::string& data)
|
std::string BaseLoop::decodeMessage(const std::string& data)
|
||||||
{
|
{
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
std::string value;
|
std::string cycdata;
|
||||||
int index;
|
int index;
|
||||||
BusCommand* busCommand;
|
BusCommand* busCommand;
|
||||||
|
|
||||||
@@ -90,17 +90,22 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
|
||||||
std::string type = m_commands->getType(index);
|
std::string type = m_commands->getType(index);
|
||||||
std::string cmd(A.getParam<const char*>("p_address"));
|
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||||
cmd += m_commands->getEbusCommand(index);
|
ebusCommand += m_commands->getEbusCommand(index);
|
||||||
std::transform(cmd.begin(), cmd.end(), cmd.begin(), tolower);
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
L.log(bas, trace, " type: %s msg: %s", type.c_str(), cmd.c_str());
|
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||||
// send BusCommand
|
// send busCommand
|
||||||
m_ebusloop->addBusCommand(new BusCommand(type, cmd));
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
busCommand = m_ebusloop->getBusCommand();
|
busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
|
// decode data
|
||||||
|
Command* command = new Command(index, (*m_commands)[index], busCommand->getResult().c_str());
|
||||||
|
|
||||||
// decode BusCommand
|
// return result
|
||||||
result << busCommand->getResult().c_str();
|
result << command->calcResult(cmd);
|
||||||
|
|
||||||
|
delete command;
|
||||||
delete busCommand;
|
delete busCommand;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -118,10 +123,16 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
index = m_commands->findCommand(data);
|
index = m_commands->findCommand(data);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
value = m_cycdata->getData(index);
|
// get cycdata
|
||||||
if (value != "") {
|
cycdata = m_cycdata->getData(index);
|
||||||
// decode CYC Data
|
if (cycdata != "") {
|
||||||
result << value.c_str();
|
// decode data
|
||||||
|
Command* command = new Command(index, (*m_commands)[index], cycdata.c_str());
|
||||||
|
|
||||||
|
// return result
|
||||||
|
result << command->calcResult(cmd);
|
||||||
|
|
||||||
|
delete command;
|
||||||
} else {
|
} else {
|
||||||
result << "no data stored";
|
result << "no data stored";
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -78,15 +78,16 @@ void* EBusLoop::run()
|
|||||||
|
|
||||||
// send bus command
|
// send bus command
|
||||||
if (busResult == 1 && busCommandActive == true) {
|
if (busResult == 1 && busCommandActive == true) {
|
||||||
L.log(bus, trace, " getBus success");
|
L.log(bus, event, " getBus success");
|
||||||
m_bus->sendCommand();
|
m_bus->sendCommand();
|
||||||
BusCommand* busCommand = m_bus->recvCommand();
|
BusCommand* busCommand = m_bus->recvCommand();
|
||||||
|
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
||||||
m_recvBuffer.add(busCommand);
|
m_recvBuffer.add(busCommand);
|
||||||
busCommandActive = false;
|
busCommandActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (busResult == 0)
|
if (busResult == 0)
|
||||||
L.log(bus, trace, " getBus failure");
|
L.log(bus, event, " getBus failure");
|
||||||
|
|
||||||
if (busResult == -1)
|
if (busResult == -1)
|
||||||
L.log(bus, event, " getBus error");
|
L.log(bus, event, " getBus error");
|
||||||
|
|||||||
Reference in New Issue
Block a user