class EBusLoop renamed to BusLoop; class Dump cleared.

This commit is contained in:
Roland Jax
2014-11-19 21:53:11 +01:00
parent 85c00c9cc7
commit 3165342057
7 changed files with 62 additions and 62 deletions
+5 -5
View File
@@ -6,14 +6,14 @@ AM_CXXFLAGS = -fpic \
bin_PROGRAMS = ebusd
ebusd_SOURCES = network.cpp \
network.h \
dump.cpp \
ebusd_SOURCES = dump.cpp \
dump.h \
buscommand.cpp \
buscommand.h \
ebusloop.cpp \
ebusloop.h \
busloop.cpp \
busloop.h \
network.cpp \
network.h \
baseloop.cpp \
baseloop.h \
ebusd.cpp
+16 -16
View File
@@ -34,9 +34,9 @@ BaseLoop::BaseLoop()
L.log(bas, event, " cycle DB: %d ", m_commands->sizeCycDB());
L.log(bas, event, " polling DB: %d ", m_commands->sizePollDB());
// create ebusloop
m_ebusloop = new EBusLoop(m_commands);
m_ebusloop->start("ebusloop");
// create busloop
m_busloop = new BusLoop(m_commands);
m_busloop->start("busloop");
// create network
m_network = new Network(A.getOptVal<bool>("localhost"), &m_netQueue);
@@ -49,11 +49,11 @@ BaseLoop::~BaseLoop()
if (m_network != NULL)
delete m_network;
// free ebusloop
if (m_ebusloop != NULL) {
m_ebusloop->stop();
m_ebusloop->join();
delete m_ebusloop;
// free busloop
if (m_busloop != NULL) {
m_busloop->stop();
m_busloop->join();
delete m_busloop;
}
// free commands DB
@@ -152,7 +152,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
BusCommand* busCommand = new BusCommand(ebusCommand, false, false);
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
// send busCommand
m_ebusloop->addBusCommand(busCommand);
m_busloop->addBusCommand(busCommand);
busCommand->waitSignal();
if (!busCommand->isErrorResult()) {
@@ -205,7 +205,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
BusCommand* busCommand = new BusCommand(ebusCommand, false, false);
L.log(bas, event, " msg: %s", ebusCommand.c_str());
// send busCommand
m_ebusloop->addBusCommand(busCommand);
m_busloop->addBusCommand(busCommand);
busCommand->waitSignal();
if (!busCommand->isErrorResult()) {
@@ -274,7 +274,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
BusCommand* busCommand = new BusCommand(ebusCommand, false, false);
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
// send busCommand
m_ebusloop->addBusCommand(busCommand);
m_busloop->addBusCommand(busCommand);
busCommand->waitSignal();
if (busCommand->isErrorResult()) {
@@ -291,13 +291,13 @@ std::string BaseLoop::decodeMessage(const std::string& data)
case scan:
if (cmd.size() == 1) {
m_ebusloop->scan();
m_busloop->scan();
result << "done";
break;
}
if (strcasecmp(cmd[1].c_str(), "FULL") == 0) {
m_ebusloop->scan(true);
m_busloop->scan(true);
result << "done";
break;
}
@@ -346,7 +346,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
break;
}
m_ebusloop->raw();
m_busloop->raw();
result << "done";
break;
@@ -356,7 +356,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
break;
}
m_ebusloop->dump();
m_busloop->dump();
result << "done";
break;
@@ -376,7 +376,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
delete m_commands;
m_commands = commands;
m_ebusloop->reload(m_commands);
m_busloop->reload(m_commands);
result << "done";
break;
+2 -2
View File
@@ -22,7 +22,7 @@
#include "commands.h"
#include "network.h"
#include "ebusloop.h"
#include "busloop.h"
class BaseLoop
{
@@ -37,7 +37,7 @@ public:
private:
Commands* m_commands;
EBusLoop* m_ebusloop;
BusLoop* m_busloop;
Network* m_network;
WQueue<NetMessage*> m_netQueue;
@@ -17,7 +17,7 @@
* along with ebusd. If not, see http://www.gnu.org/licenses/.
*/
#include "ebusloop.h"
#include "busloop.h"
#include "logger.h"
#include "appl.h"
#include <iomanip>
@@ -25,7 +25,7 @@
extern Logger& L;
extern Appl& A;
EBusLoop::EBusLoop(Commands* commands)
BusLoop::BusLoop(Commands* commands)
: m_commands(commands), m_stop(false), m_lockCounter(0),
m_priorRetry(false), m_scan(false), m_scanFull(false), m_scanIndex(0)
{
@@ -51,7 +51,7 @@ EBusLoop::EBusLoop(Commands* commands)
m_acquireTime = A.getOptVal<long>("acquiretime");
}
EBusLoop::~EBusLoop()
BusLoop::~BusLoop()
{
if (m_port->isOpen() == true)
m_port->close();
@@ -60,7 +60,7 @@ EBusLoop::~EBusLoop()
delete m_dump;
}
void* EBusLoop::run()
void* BusLoop::run()
{
int sendRetries = 0;
int lockRetries = 0;
@@ -191,7 +191,7 @@ void* EBusLoop::run()
return NULL;
}
unsigned char EBusLoop::fetchByte()
unsigned char BusLoop::fetchByte()
{
unsigned char byte;
@@ -207,7 +207,7 @@ unsigned char EBusLoop::fetchByte()
return byte;
}
void EBusLoop::collectCycData(const int numRecv)
void BusLoop::collectCycData(const int numRecv)
{
// cycle bytes
for (int i = 0; i < numRecv; i++) {
@@ -242,7 +242,7 @@ void EBusLoop::collectCycData(const int numRecv)
}
}
void EBusLoop::analyseCycData()
void BusLoop::analyseCycData()
{
static bool skipfirst = false;
@@ -276,7 +276,7 @@ void EBusLoop::analyseCycData()
skipfirst = true;
}
void EBusLoop::addPollCommand()
void BusLoop::addPollCommand()
{
int index = m_commands->nextPollCommand();
if (index < 0) {
@@ -301,7 +301,7 @@ void EBusLoop::addPollCommand()
}
}
int EBusLoop::acquireBus()
int BusLoop::acquireBus()
{
unsigned char recvByte, sendByte;
ssize_t numRecv, numSend;
@@ -358,7 +358,7 @@ int EBusLoop::acquireBus()
return RESULT_ERR_EXTRA_DATA;
}
BusCommand* EBusLoop::sendCommand()
BusCommand* BusLoop::sendCommand()
{
unsigned char recvByte;
std::string result;
@@ -470,7 +470,7 @@ on_exit:
}
int EBusLoop::sendByte(const unsigned char sendByte)
int BusLoop::sendByte(const unsigned char sendByte)
{
unsigned char recvByte;
ssize_t numRecv, numSend;
@@ -495,7 +495,7 @@ int EBusLoop::sendByte(const unsigned char sendByte)
return RESULT_OK;
}
int EBusLoop::recvSlaveAck(unsigned char& recvByte)
int BusLoop::recvSlaveAck(unsigned char& recvByte)
{
ssize_t numRecv;
@@ -522,7 +522,7 @@ int EBusLoop::recvSlaveAck(unsigned char& recvByte)
return RESULT_OK;
}
int EBusLoop::recvSlaveData(SymbolString& result)
int BusLoop::recvSlaveData(SymbolString& result)
{
unsigned char recvByte, calcCrc = 0;
ssize_t numRecv;
@@ -568,7 +568,7 @@ int EBusLoop::recvSlaveData(SymbolString& result)
return RESULT_OK;
}
void EBusLoop::collectSlave()
void BusLoop::collectSlave()
{
std::vector<unsigned char>::iterator it;
@@ -594,7 +594,7 @@ void EBusLoop::collectSlave()
}
}
void EBusLoop::addScanCommand()
void BusLoop::addScanCommand()
{
std::string ebusCommand(A.getOptVal<const char*>("address"));
std::stringstream sstr;
+6 -6
View File
@@ -17,8 +17,8 @@
* along with ebusd. If not, see http://www.gnu.org/licenses/.
*/
#ifndef EBUSLOOP_H_
#define EBUSLOOP_H_
#ifndef BUSLOOP_H_
#define BUSLOOP_H_
#include "commands.h"
#include "port.h"
@@ -30,12 +30,12 @@
/** the maximum time [us] allowed for retrieving a byte from an addressed slave */
#define RECV_TIMEOUT 10000
class EBusLoop : public Thread
class BusLoop : public Thread
{
public:
EBusLoop(Commands* commands);
~EBusLoop();
BusLoop(Commands* commands);
~BusLoop();
void* run();
void stop() { m_stop = true; }
@@ -92,4 +92,4 @@ private:
};
#endif // EBUSLOOP_H_
#endif // BUSLOOP_H_
+4 -4
View File
@@ -25,18 +25,18 @@ int Dump::write(const char* byte)
{
int ret = 0;
std::ofstream fs(m_filename.c_str(), std::ios::out | std::ios::binary | std::ios::app);
std::ofstream fs(m_name.c_str(), std::ios::out | std::ios::binary | std::ios::app);
if (fs == 0)
return -1;
fs.write(byte, 1);
if (fs.tellp() >= m_filesize * 1024) {
if (fs.tellp() >= m_size * 1024) {
std::string oldfile;
oldfile += m_filename;
oldfile += m_name;
oldfile += ".old";
ret = rename(m_filename.c_str(), oldfile.c_str());
ret = rename(m_name.c_str(), oldfile.c_str());
}
fs.close();
+14 -14
View File
@@ -23,19 +23,19 @@
#include <string>
/**
* @brief Class for writing raw bytes to binary file.
* @brief class for writing raw bytes to binary file.
*/
class Dump
{
public:
/**
* @brief Create a new instance to write dump files.
* @param filename which will be used for dumping raw bytes.
* @param filesize max. Size of the dump file, before switching.
* @brief create a new instance to write dump files.
* @param name the file name of dump file.
* @param size the max. size of the dump file, before switching.
*/
Dump(std::string filename, long filesize)
: m_filename(filename), m_filesize(filesize) {}
Dump(std::string name, long size)
: m_name(name), m_size(size) {}
/**
* @brief write byte to dump file.
@@ -45,23 +45,23 @@ public:
int write(const char* byte);
/**
* @brief setter for dump file name.
* @param filename which will be used for dumping raw bytes.
* @brief set the name of dump file.
* @param name the file name of dump file.
*/
void setFilename(const std::string& filename) { m_filename = filename; }
void setName(const std::string& name) { m_name = name; }
/**
* @brief setter for max size of dump file.
* @param filesize max. Size of the dump file, before switching.
* @brief set the max size of dump file.
* @param size the max. size of the dump file, before switching.
*/
void setFilesize(const long filesize) { m_filesize = filesize; }
void setSize(const long size) { m_size = size; }
private:
/** the name of dump file*/
std::string m_filename;
std::string m_name;
/** max. size of dump file */
long m_filesize;
long m_size;
};