class BusCommand separated from class Bus.
This commit is contained in:
+1
-33
@@ -24,6 +24,7 @@
|
||||
#include "result.h"
|
||||
#include "port.h"
|
||||
#include "dump.h"
|
||||
#include "buscommand.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
@@ -36,39 +37,6 @@ namespace libebus
|
||||
// the maximum time allowed for retrieving a byte from an addressed slave
|
||||
#define RECV_TIMEOUT 10000
|
||||
|
||||
|
||||
enum CommandType { invalid, broadcast, masterMaster, masterSlave };
|
||||
|
||||
|
||||
class BusCommand
|
||||
{
|
||||
|
||||
public:
|
||||
BusCommand(const std::string commandStr, const bool isPoll);
|
||||
~BusCommand();
|
||||
|
||||
CommandType getType() const { return m_type; }
|
||||
bool isPoll() const { return m_isPoll; }
|
||||
SymbolString getCommand() const { return m_command; }
|
||||
bool isErrorResult() const { return m_resultCode < 0; }
|
||||
const char* getResultCodeCStr();
|
||||
SymbolString getResult() const { return m_result; }
|
||||
void setResult(const SymbolString result, const int resultCode) { m_result = result; m_resultCode = resultCode; }
|
||||
const std::string getMessageStr();
|
||||
void waitSignal() { pthread_cond_wait(&m_cond, &m_mutex); } // TODO timeout
|
||||
void sendSignal() { pthread_cond_signal(&m_cond); }
|
||||
|
||||
private:
|
||||
CommandType m_type;
|
||||
bool m_isPoll;
|
||||
SymbolString m_command;
|
||||
SymbolString m_result;
|
||||
int m_resultCode;
|
||||
|
||||
pthread_mutex_t m_mutex;
|
||||
pthread_cond_t m_cond;
|
||||
};
|
||||
|
||||
class Bus
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user