class WQueue: method 'T remove(const long delay)' removed.
This commit is contained in:
@@ -21,10 +21,7 @@
|
|||||||
#define WQUEUE_H_
|
#define WQUEUE_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <ctime>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
template <typename T> class WQueue
|
template <typename T> class WQueue
|
||||||
{
|
{
|
||||||
@@ -67,34 +64,6 @@ public:
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
T remove(const long delay)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
struct timespec timeout;
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&m_mutex);
|
|
||||||
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
timeout.tv_sec = tv.tv_sec + delay;
|
|
||||||
timeout.tv_nsec = tv.tv_usec * 1000;
|
|
||||||
|
|
||||||
while (m_queue.size() == 0 && ret != ETIMEDOUT)
|
|
||||||
ret = pthread_cond_timedwait(&m_condv, &m_mutex, &timeout);
|
|
||||||
|
|
||||||
if (ret == ETIMEDOUT)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
T item = m_queue.front();
|
|
||||||
m_queue.pop_front();
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&m_mutex);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
int size()
|
int size()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&m_mutex);
|
pthread_mutex_lock(&m_mutex);
|
||||||
|
|||||||
+24
-40
@@ -96,27 +96,22 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
if (busCommand != NULL) {
|
if (busCommand->getResult().c_str()[0] != '-') {
|
||||||
if (busCommand->getResult().c_str()[0] != '-') {
|
// decode data
|
||||||
// decode data
|
Command* command = new Command(index, (*m_commands)[index], busCommand->getResult());
|
||||||
Command* command = new Command(index, (*m_commands)[index], busCommand->getResult());
|
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
result << command->calcResult(cmd);
|
result << command->calcResult(cmd);
|
||||||
|
|
||||||
delete command;
|
delete command;
|
||||||
} else {
|
|
||||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
|
||||||
result << busCommand->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
delete busCommand;
|
|
||||||
} else {
|
} else {
|
||||||
L.log(bas, error, " -7: receive timeout");
|
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||||
result << "-7: receive timeout";
|
result << busCommand->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete busCommand;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result << "ebus command not found";
|
result << "ebus command not found";
|
||||||
}
|
}
|
||||||
@@ -155,25 +150,19 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
if (busCommand != NULL) {
|
if (busCommand->getResult().c_str()[0] != '-') {
|
||||||
if (busCommand->getResult().c_str()[0] != '-') {
|
// decode result
|
||||||
// decode result
|
if (busCommand->getResult().substr(busCommand->getResult().length()-8) == "00000000")
|
||||||
if (busCommand->getResult().substr(busCommand->getResult().length()-8) == "00000000")
|
result << "done";
|
||||||
result << "done";
|
else
|
||||||
else
|
result << "error";
|
||||||
result << "error";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
|
||||||
result << busCommand->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete busCommand;
|
|
||||||
} else {
|
} else {
|
||||||
L.log(bas, error, " -7: receive timeout");
|
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||||
result << "-7: receive timeout";
|
result << busCommand->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete busCommand;
|
||||||
delete command;
|
delete command;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -231,17 +220,12 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
if (busCommand != NULL) {
|
if (busCommand->getResult().c_str()[0] == '-')
|
||||||
if (busCommand->getResult().c_str()[0] == '-')
|
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
|
||||||
|
|
||||||
result << busCommand->getResult();
|
result << busCommand->getResult();
|
||||||
|
|
||||||
delete busCommand;
|
delete busCommand;
|
||||||
} else {
|
|
||||||
L.log(bas, error, " -7: receive timeout");
|
|
||||||
result << "-7: receive timeout";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result << "specified message type is incorrect";
|
result << "specified message type is incorrect";
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ public:
|
|||||||
std::string getData() { return m_cycBuffer.remove(); }
|
std::string getData() { return m_cycBuffer.remove(); }
|
||||||
|
|
||||||
void addBusCommand(BusCommand* busCommand) { m_sendBuffer.add(busCommand); }
|
void addBusCommand(BusCommand* busCommand) { m_sendBuffer.add(busCommand); }
|
||||||
BusCommand* getBusCommand() { return m_recvBuffer.remove(10); }
|
BusCommand* getBusCommand() { return m_recvBuffer.remove(); }
|
||||||
|
|
||||||
void dump(const bool dumpState) { m_bus->setDumpState(dumpState); }
|
void dump(const bool dumpState) { m_bus->setDumpState(dumpState); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user