better logging with TRACE, DEBUG, and FATAL #160
@ -14,9 +14,12 @@
|
|||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <boost/log/utility/setup.hpp>
|
#include <boost/log/utility/setup.hpp>
|
||||||
|
|
||||||
|
#define TRACE BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::trace)
|
||||||
|
#define DEBUG BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::debug)
|
||||||
#define INFO BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::info)
|
#define INFO BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::info)
|
||||||
#define WARN BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::warning)
|
#define WARN BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::warning)
|
||||||
#define ERROR BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::error)
|
#define ERROR BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::error)
|
||||||
|
#define FATAL BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::fatal)
|
||||||
|
|
||||||
#define SYS_LOGFILE "/var/log/example.log"
|
#define SYS_LOGFILE "/var/log/example.log"
|
||||||
|
|
||||||
@ -26,4 +29,6 @@ typedef boost::log::sources::severity_logger_mt<boost::log::trivial::severity_le
|
|||||||
//declares a global logger with a custom initialization
|
//declares a global logger with a custom initialization
|
||||||
BOOST_LOG_GLOBAL_LOGGER(my_logger, logger_t)
|
BOOST_LOG_GLOBAL_LOGGER(my_logger, logger_t)
|
||||||
|
|
||||||
|
std::string convert_int(int n);
|
||||||
|
|
||||||
#endif // logger_h
|
#endif // logger_h
|
||||||
|
@ -52,7 +52,7 @@ bool loadFromFile ( char* filename, boost::lockfree::queue<buffer*, boost::lockf
|
|||||||
|
|
||||||
tmpBufPos++;
|
tmpBufPos++;
|
||||||
if (tmpBufPos == BUFFER_SIZE) {
|
if (tmpBufPos == BUFFER_SIZE) {
|
||||||
INFO << "Adding buffer to queue from file";
|
DEBUG << "Adding buffer to queue from file";
|
||||||
// Buffer is now full push it
|
// Buffer is now full push it
|
||||||
outputQ->push(tempBuffer);
|
outputQ->push(tempBuffer);
|
||||||
|
|
||||||
|
@ -29,12 +29,13 @@ inline void FreePacket(EVPacket* packet) {
|
|||||||
* None
|
* None
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void PrintPacket(EVPacket* packet) {
|
void PrintPacket(EVPacket* packet) {
|
||||||
printf("PacketID_HEX: %X, Command: %d, DataSize: %d, Data: ",
|
std::string dbgMsg = "PacketID_HEX: " + convert_int(packet->packetID);
|
||||||
packet->packetID, packet->command,packet->dataSize);
|
dbgMsg += ", Command: " + std::to_string(packet->command);
|
||||||
|
dbgMsg += ", DataSize: " + std::to_string(packet->dataSize) + ", Data: ";
|
||||||
for(unsigned i = 0; i < packet->dataSize; i++) {
|
for(unsigned i = 0; i < packet->dataSize; i++) {
|
||||||
printf("%X ",packet->data[i]);
|
dbgMsg += convert_int(packet->data[i]) + " ";
|
||||||
}
|
}
|
||||||
printf("\n");
|
INFO << dbgMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -99,14 +100,14 @@ txQueue(txQueue)
|
|||||||
* None
|
* None
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
Bridge::~Bridge() {
|
Bridge::~Bridge() {
|
||||||
INFO << "Destroying bridge";
|
DEBUG << "Destroying bridge";
|
||||||
if (rx_run.load() == true) {
|
if (rx_run.load() == true) {
|
||||||
RxStop();
|
RxStop();
|
||||||
}
|
}
|
||||||
if (tx_run.load() == true) {
|
if (tx_run.load() == true) {
|
||||||
TxStop();
|
TxStop();
|
||||||
}
|
}
|
||||||
INFO << "Bridge destroyed";
|
DEBUG << "Bridge destroyed";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -137,7 +138,7 @@ int Bridge::makeConnection(int targetSocket ) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO << "targetSocket: listening for clients, waiting to aceept....";
|
INFO << "targetSocket: listening for clients, waiting to accept....";
|
||||||
// accept the first client to connect
|
// accept the first client to connect
|
||||||
// No need to save it's fd since we will never write to it
|
// No need to save it's fd since we will never write to it
|
||||||
struct sockaddr_un address;
|
struct sockaddr_un address;
|
||||||
@ -176,7 +177,7 @@ void Bridge::TxJob() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConnectNamedPipe(tx_hPipe, NULL);
|
ConnectNamedPipe(tx_hPipe, NULL);
|
||||||
INFO << "tx_pipe: client connected";
|
DEBUG << "tx_pipe: client connected";
|
||||||
#else
|
#else
|
||||||
client_tx_sock = makeConnection(tx_sock);
|
client_tx_sock = makeConnection(tx_sock);
|
||||||
if (client_tx_sock < 0) {
|
if (client_tx_sock < 0) {
|
||||||
@ -230,7 +231,7 @@ void Bridge::RxJob() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConnectNamedPipe(rx_hPipe, NULL);
|
ConnectNamedPipe(rx_hPipe, NULL);
|
||||||
INFO << "rx_pipe: client connected";
|
DEBUG << "rx_pipe: client connected";
|
||||||
#else
|
#else
|
||||||
client_rx_sock = makeConnection(rx_sock);
|
client_rx_sock = makeConnection(rx_sock);
|
||||||
if (client_rx_sock < 0) {
|
if (client_rx_sock < 0) {
|
||||||
@ -268,7 +269,7 @@ void Bridge::RxJob() {
|
|||||||
&& endPacketCheck[1] == END_PACKET_PACKETID
|
&& endPacketCheck[1] == END_PACKET_PACKETID
|
||||||
&& endPacketCheck[2] == END_PACKET_DATA_SIZE) {
|
&& endPacketCheck[2] == END_PACKET_DATA_SIZE) {
|
||||||
|
|
||||||
INFO << "END PACKET Recieved, Jumping Out Of RX Job";
|
DEBUG << "END PACKET Recieved, Jumping Out Of RX Job";
|
||||||
rx_run.store(false);
|
rx_run.store(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -292,7 +293,7 @@ void Bridge::RxJob() {
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
INFO << "rx_pipe data_read: Error: " << GetLastError();
|
ERROR << "rx_pipe data_read: Error: " << GetLastError();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,10 +322,11 @@ void Bridge::RxJob() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//process whatever is sent (for now just print it)
|
//process whatever is sent (for now just print it)
|
||||||
printf("Packet Size: %d, Packet Info:\n",(int)packet_size);
|
std::string dbgMsg = "Packet Size: " + std::to_string(packet_size) + " Packet Info: ";
|
||||||
for(int i = 0; i < (int)packet_size; i++)
|
for(int i = 0; i < (int)packet_size; i++) {
|
||||||
printf("%X ",rxBuff[i]);
|
dbgMsg += convert_int(rxBuff[i]) + " ";
|
||||||
printf("\n");
|
}
|
||||||
|
INFO << dbgMsg;
|
||||||
|
|
||||||
// TODO: you can just cast it as the struct and access things that way
|
// TODO: you can just cast it as the struct and access things that way
|
||||||
uint16_t* rxBuff16 = (uint16_t*) rxBuff;
|
uint16_t* rxBuff16 = (uint16_t*) rxBuff;
|
||||||
@ -374,11 +376,11 @@ int Bridge::TxStart() {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
INFO << "Initialized Tx Bridge";
|
DEBUG << "Initialized Tx Bridge";
|
||||||
|
|
||||||
tx_run.store(true);
|
tx_run.store(true);
|
||||||
tx_worker = std::thread(&Bridge::TxJob, this);
|
tx_worker = std::thread(&Bridge::TxJob, this);
|
||||||
INFO << "Started Tx Worker";
|
DEBUG << "Started Tx Worker";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,11 +403,11 @@ int Bridge::RxStart() {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
INFO << "Init'd Rx Bridge";
|
DEBUG << "Init'd Rx Bridge";
|
||||||
|
|
||||||
rx_run.store(true);
|
rx_run.store(true);
|
||||||
rx_worker = std::thread(&Bridge::RxJob, this);
|
rx_worker = std::thread(&Bridge::RxJob, this);
|
||||||
INFO << "Started Rx Worker";
|
DEBUG << "Started Rx Worker";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +443,7 @@ int Bridge::InitTxBridge() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO << "Created Tx Pipe at: " << tx_connection_string;
|
DEBUG << "Created Tx Pipe at: " << tx_connection_string;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -471,7 +473,7 @@ int Bridge::InitTxBridge() {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO << "tx_sock created and bound on " << name.sun_path;
|
DEBUG << "tx_sock created and bound on " << name.sun_path;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -509,7 +511,7 @@ int Bridge::InitRxBridge() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO << "Created Rx Pipe at: " << rx_connection_string;
|
DEBUG << "Created Rx Pipe at: " << rx_connection_string;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct sockaddr_un name;
|
struct sockaddr_un name;
|
||||||
@ -538,7 +540,7 @@ int Bridge::InitRxBridge() {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO << "rx_sock created and bound on " << name.sun_path;
|
DEBUG << "rx_sock created and bound on " << name.sun_path;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -554,7 +556,7 @@ int Bridge::InitRxBridge() {
|
|||||||
* int - 0 on success
|
* int - 0 on success
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int Bridge::TxStop() {
|
int Bridge::TxStop() {
|
||||||
INFO << "Stopping Tx";
|
DEBUG << "Stopping Tx";
|
||||||
|
|
||||||
tx_run.store(false);
|
tx_run.store(false);
|
||||||
|
|
||||||
@ -598,7 +600,7 @@ int Bridge::TxStop() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INFO << "Tx stopped";
|
DEBUG << "Tx stopped";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +615,7 @@ int Bridge::TxStop() {
|
|||||||
* int - 0 on success
|
* int - 0 on success
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int Bridge::RxStop() {
|
int Bridge::RxStop() {
|
||||||
INFO << "Stopping Rx";
|
DEBUG << "Stopping Rx";
|
||||||
|
|
||||||
rx_run.store(false);
|
rx_run.store(false);
|
||||||
|
|
||||||
@ -670,6 +672,6 @@ int Bridge::RxStop() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INFO << "Rx stopped";
|
DEBUG << "Rx stopped";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ controller::~controller()
|
|||||||
delete postProcessorThread;
|
delete postProcessorThread;
|
||||||
delete bridgeThread;
|
delete bridgeThread;
|
||||||
|
|
||||||
INFO << "Controller Destroyed";
|
DEBUG << "Controller Destroyed";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -58,15 +58,15 @@ void controller::controllerLoop()
|
|||||||
while (stopController.load() == false) {
|
while (stopController.load() == false) {
|
||||||
while (stopController.load() == false &&
|
while (stopController.load() == false &&
|
||||||
controllerQueue_rx.pop(currentPacket)) {
|
controllerQueue_rx.pop(currentPacket)) {
|
||||||
INFO << "Controller processing a packet";
|
DEBUG << "Controller processing a packet";
|
||||||
|
|
||||||
// execute the packet command
|
// execute the packet command
|
||||||
switch (currentPacket->command) {
|
switch (currentPacket->command) {
|
||||||
case 1:
|
case 1:
|
||||||
INFO << "Packet command 1";
|
DEBUG << "Packet command 1";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
INFO << "Packet command 2";
|
DEBUG << "Packet command 2";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR << "Unknown packet command";
|
ERROR << "Unknown packet command";
|
||||||
@ -92,7 +92,7 @@ void controller::controllerLoop()
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void controller::controllerPause()
|
void controller::controllerPause()
|
||||||
{
|
{
|
||||||
INFO << "Pausing pipeline";
|
DEBUG << "Pausing pipeline";
|
||||||
processorThread->processorPause();
|
processorThread->processorPause();
|
||||||
triggerThread->triggerPause();
|
triggerThread->triggerPause();
|
||||||
postProcessorThread->postProcessorPause();
|
postProcessorThread->postProcessorPause();
|
||||||
@ -111,7 +111,7 @@ void controller::controllerPause()
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void controller::controllerUnPause()
|
void controller::controllerUnPause()
|
||||||
{
|
{
|
||||||
INFO << "Unpausing pipeline";
|
DEBUG << "Unpausing pipeline";
|
||||||
processorThread->processorUnpause();
|
processorThread->processorUnpause();
|
||||||
triggerThread->triggerUnpause();
|
triggerThread->triggerUnpause();
|
||||||
postProcessorThread->postProcessorUnpause();
|
postProcessorThread->postProcessorUnpause();
|
||||||
@ -152,19 +152,19 @@ void controller::controllerFlush()
|
|||||||
// Clear queues
|
// Clear queues
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
count = (*dataQueue).consume_all(bufferFunctor);
|
count = (*dataQueue).consume_all(bufferFunctor);
|
||||||
INFO << "Flushed inputQueue: " << count;
|
DEBUG << "Flushed inputQueue: " << count;
|
||||||
|
|
||||||
count = triggerProcessorQueue.consume_all(bufferFunctor);
|
count = triggerProcessorQueue.consume_all(bufferFunctor);
|
||||||
INFO << "Flushed triggeredQueue: " << count;
|
DEBUG << "Flushed triggeredQueue: " << count;
|
||||||
|
|
||||||
// Clear persistence buffer
|
// Clear persistence buffer
|
||||||
processorThread->flushPersistence();
|
processorThread->flushPersistence();
|
||||||
INFO << "Flushed persistence buffer";
|
DEBUG << "Flushed persistence buffer";
|
||||||
// count = preProcessorQueue.consume_all(bufferFunctor);
|
// count = preProcessorQueue.consume_all(bufferFunctor);
|
||||||
// INFO << "Flushed preProcessorQueue: " << count;
|
// DEBUG << "Flushed preProcessorQueue: " << count;
|
||||||
|
|
||||||
count = processorPostProcessorQueue_1.consume_all(free);
|
count = processorPostProcessorQueue_1.consume_all(free);
|
||||||
INFO << "Flushed postProcessorQueue: " << count;
|
DEBUG << "Flushed postProcessorQueue: " << count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
|
|
||||||
namespace attrs = boost::log::attributes;
|
//namespace attrs = boost::log::attributes;
|
||||||
namespace expr = boost::log::expressions;
|
namespace expr = boost::log::expressions;
|
||||||
namespace logging = boost::log;
|
namespace logging = boost::log;
|
||||||
|
|
||||||
@ -45,3 +45,23 @@ BOOST_LOG_GLOBAL_LOGGER_INIT(my_logger, logger_t)
|
|||||||
|
|
||||||
return lg;
|
return lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* convert_int()
|
||||||
|
*
|
||||||
|
* converts an integer to a hex string.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* int n - integer to convert.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* string - integer n as an uppercase string.
|
||||||
|
******************************************************************************/
|
||||||
|
std::string convert_int(int n)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::uppercase << std::hex;
|
||||||
|
ss << n;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -184,8 +184,7 @@ void runCli() {
|
|||||||
|
|
||||||
bool parseThings = true;
|
bool parseThings = true;
|
||||||
while(parseThings) {
|
while(parseThings) {
|
||||||
INFO << "Input a command";
|
INFO << "Input a command\n>";
|
||||||
printf("> ");
|
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(std::cin, line);
|
std::getline(std::cin, line);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ postProcessor::~postProcessor(void)
|
|||||||
postProcessorStop();
|
postProcessorStop();
|
||||||
postProcessorThread.join();
|
postProcessorThread.join();
|
||||||
|
|
||||||
INFO << "Destroyed post processor";
|
DEBUG << "Destroyed post processor";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -80,7 +80,7 @@ void postProcessor::coreLoop()
|
|||||||
while (pauseTransfer.load() == false &&
|
while (pauseTransfer.load() == false &&
|
||||||
inputQueue->pop(currentWindow)) {
|
inputQueue->pop(currentWindow)) {
|
||||||
|
|
||||||
INFO << "post processing next window";
|
DEBUG << "post processing next window";
|
||||||
|
|
||||||
// TODO: Could do each channel in parrallel
|
// TODO: Could do each channel in parrallel
|
||||||
for (uint8_t j = 0; j < numCh; j++) {
|
for (uint8_t j = 0; j < numCh; j++) {
|
||||||
@ -89,12 +89,12 @@ void postProcessor::coreLoop()
|
|||||||
|
|
||||||
// Post process window
|
// Post process window
|
||||||
// TODO: Add interpolation here.
|
// TODO: Add interpolation here.
|
||||||
std::cout << "Post Processed window";
|
std::string dbgMsg = "Post Processed window ";
|
||||||
for (uint32_t i = 0; i < windowSize; i++) {
|
for (uint32_t i = 0; i < windowSize; i++) {
|
||||||
postWindow[i] = currentWindow[i * numCh + j];
|
postWindow[i] = currentWindow[i * numCh + j];
|
||||||
std::cout << " " << (int)currentWindow[i * numCh + j];
|
dbgMsg += std::to_string(currentWindow[i * numCh + j]) + " ";
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
DEBUG << dbgMsg;
|
||||||
|
|
||||||
// Pass processed window to next stage
|
// Pass processed window to next stage
|
||||||
currentPacket = (EVPacket*)malloc(sizeof(EVPacket));
|
currentPacket = (EVPacket*)malloc(sizeof(EVPacket));
|
||||||
@ -143,7 +143,7 @@ void postProcessor::setCh (int8_t newCh)
|
|||||||
void postProcessor::postProcessorStart()
|
void postProcessor::postProcessorStart()
|
||||||
{
|
{
|
||||||
stopTransfer.store(false);
|
stopTransfer.store(false);
|
||||||
INFO << "Starting post processing";
|
DEBUG << "Starting post processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -160,7 +160,7 @@ void postProcessor::postProcessorStart()
|
|||||||
void postProcessor::postProcessorStop()
|
void postProcessor::postProcessorStop()
|
||||||
{
|
{
|
||||||
stopTransfer.store(true);
|
stopTransfer.store(true);
|
||||||
INFO << "Stopping post processing";
|
DEBUG << "Stopping post processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -177,7 +177,7 @@ void postProcessor::postProcessorStop()
|
|||||||
void postProcessor::postProcessorUnpause()
|
void postProcessor::postProcessorUnpause()
|
||||||
{
|
{
|
||||||
pauseTransfer.store(false);
|
pauseTransfer.store(false);
|
||||||
INFO << "unpausing post processing";
|
DEBUG << "unpausing post processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -194,5 +194,5 @@ void postProcessor::postProcessorUnpause()
|
|||||||
void postProcessor::postProcessorPause()
|
void postProcessor::postProcessorPause()
|
||||||
{
|
{
|
||||||
pauseTransfer.store(true);
|
pauseTransfer.store(true);
|
||||||
INFO << "pausing post processing";
|
DEBUG << "pausing post processing";
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
#define DBG
|
|
||||||
|
|
||||||
Processor::Processor(
|
Processor::Processor(
|
||||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *inputQ,
|
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *inputQ,
|
||||||
boost::lockfree::queue<int8_t*, boost::lockfree::fixed_sized<false>> *outputQ)
|
boost::lockfree::queue<int8_t*, boost::lockfree::fixed_sized<false>> *outputQ)
|
||||||
@ -34,36 +32,36 @@ Processor::Processor(
|
|||||||
|
|
||||||
Processor::~Processor(void)
|
Processor::~Processor(void)
|
||||||
{
|
{
|
||||||
INFO << "Processor Destructor Called";
|
DEBUG << "Processor Destructor Called";
|
||||||
|
|
||||||
// Stop the transer and join thread
|
// Stop the transer and join thread
|
||||||
processorPause();
|
processorPause();
|
||||||
processorStop();
|
processorStop();
|
||||||
processorThread.join();
|
processorThread.join();
|
||||||
|
|
||||||
INFO << "Destroyed processor thread";
|
DEBUG << "Destroyed processor thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the offset of the next trigger in the current buffer
|
// Returns the offset of the next trigger in the current buffer
|
||||||
bool Processor::findNextTrigger(buffer *currentBuffer, uint32_t* p_bufCol)
|
bool Processor::findNextTrigger(buffer *currentBuffer, uint32_t* p_bufCol)
|
||||||
{
|
{
|
||||||
INFO << "** Finding Next Trigger **";
|
DEBUG << "** Finding Next Trigger **";
|
||||||
INFO << "p_bufCol: " << *p_bufCol;
|
DEBUG << "p_bufCol: " << *p_bufCol;
|
||||||
uint32_t t_offset = 0;
|
uint32_t t_offset = 0;
|
||||||
|
|
||||||
// Find which 64 block the buffer is in
|
// Find which 64 block the buffer is in
|
||||||
uint32_t t_64offset = (*p_bufCol / 64);
|
uint32_t t_64offset = (*p_bufCol / 64);
|
||||||
INFO << "p_bufCol: " << *p_bufCol
|
DEBUG << "p_bufCol: " << *p_bufCol
|
||||||
<< " t_offset: " << t_offset
|
<< " t_offset: " << t_offset
|
||||||
<< " t_64offset: " << t_64offset;
|
<< " t_64offset: " << t_64offset;
|
||||||
|
|
||||||
if (windowCol != 0) {
|
if (windowCol != 0) {
|
||||||
// Partialy filled window
|
// Partialy filled window
|
||||||
if (*p_bufCol == 0) {
|
if (*p_bufCol == 0) {
|
||||||
INFO << "Partial Window. Fill the rest of the widow";
|
DEBUG << "Partial Window. Fill the rest of the widow";
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
INFO << "Partial Window. bufferCol = 0 and get new buffer";
|
DEBUG << "Partial Window. bufferCol = 0 and get new buffer";
|
||||||
*p_bufCol = 0;
|
*p_bufCol = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,13 +74,13 @@ bool Processor::findNextTrigger(buffer *currentBuffer, uint32_t* p_bufCol)
|
|||||||
// Found a trigger, find exact position
|
// Found a trigger, find exact position
|
||||||
t_offset = (int)(log2(currentBuffer->trigger[t_64offset]));
|
t_offset = (int)(log2(currentBuffer->trigger[t_64offset]));
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
INFO << "found Trigger in 64: " << t_64offset
|
DEBUG << "found Trigger in 64: " << t_64offset
|
||||||
<< " with val: " << currentBuffer->trigger[t_64offset]
|
<< " with val: " << currentBuffer->trigger[t_64offset]
|
||||||
<< " t_offset: " << t_offset;
|
<< " t_offset: " << t_offset;
|
||||||
#endif
|
#endif
|
||||||
t_offset = (64 - 1) - t_offset;
|
t_offset = (64 - 1) - t_offset;
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
INFO << "t_64offset corrected: " << t_64offset;
|
DEBUG << "t_64offset corrected: " << t_64offset;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -91,11 +89,11 @@ bool Processor::findNextTrigger(buffer *currentBuffer, uint32_t* p_bufCol)
|
|||||||
if (t_64offset >= BUFFER_SIZE/64) {
|
if (t_64offset >= BUFFER_SIZE/64) {
|
||||||
// No trigger found in buffer
|
// No trigger found in buffer
|
||||||
*p_bufCol = BUFFER_SIZE;
|
*p_bufCol = BUFFER_SIZE;
|
||||||
INFO << "End of buffer reached, go to next one";
|
DEBUG << "End of buffer reached, go to next one";
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
*p_bufCol = ((t_offset) + (t_64offset * 64));
|
*p_bufCol = ((t_offset) + (t_64offset * 64));
|
||||||
INFO << "t_offset: " << t_offset
|
DEBUG << "t_offset: " << t_offset
|
||||||
<< " t_64_offset: " << t_64offset;
|
<< " t_64_offset: " << t_64offset;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -120,7 +118,7 @@ void Processor::coreLoop()
|
|||||||
windowStored.load() == false &&
|
windowStored.load() == false &&
|
||||||
inputQueue->pop(currentBuffer)) {
|
inputQueue->pop(currentBuffer)) {
|
||||||
|
|
||||||
INFO << "*** New Buffer ***";
|
DEBUG << "*** New Buffer ***";
|
||||||
// New buffer, reset variables
|
// New buffer, reset variables
|
||||||
count++;
|
count++;
|
||||||
bufferCol = 0;
|
bufferCol = 0;
|
||||||
@ -133,7 +131,7 @@ void Processor::coreLoop()
|
|||||||
// - remaining space in a buffer
|
// - remaining space in a buffer
|
||||||
copyCount = std::min(windowSize - windowCol, BUFFER_SIZE/numCh - bufferCol);
|
copyCount = std::min(windowSize - windowCol, BUFFER_SIZE/numCh - bufferCol);
|
||||||
|
|
||||||
INFO << "bufferCol: " << bufferCol
|
DEBUG << "bufferCol: " << bufferCol
|
||||||
<< " copyCount: " << copyCount;
|
<< " copyCount: " << copyCount;
|
||||||
|
|
||||||
// Copy samples into the window
|
// Copy samples into the window
|
||||||
@ -144,7 +142,7 @@ void Processor::coreLoop()
|
|||||||
bufferCol += copyCount;
|
bufferCol += copyCount;
|
||||||
windowCol += copyCount;
|
windowCol += copyCount;
|
||||||
|
|
||||||
INFO << "bufferCol: " << bufferCol
|
DEBUG << "bufferCol: " << bufferCol
|
||||||
<< " windowCol: " << windowCol
|
<< " windowCol: " << windowCol
|
||||||
<< " windowSize: " << windowSize
|
<< " windowSize: " << windowSize
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -162,11 +160,11 @@ void Processor::coreLoop()
|
|||||||
// Push it into the next 64 space so we don't
|
// Push it into the next 64 space so we don't
|
||||||
// trigger on the same spot twice
|
// trigger on the same spot twice
|
||||||
bufferCol += 64;
|
bufferCol += 64;
|
||||||
INFO << "full window. windowCol: "
|
DEBUG << "full window. windowCol: "
|
||||||
<< windowCol;
|
<< windowCol;
|
||||||
} else {
|
} else {
|
||||||
// Partial window coppied
|
// Partial window coppied
|
||||||
INFO << "partial window. windowCol: "
|
DEBUG << "partial window. windowCol: "
|
||||||
<< windowCol;
|
<< windowCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,26 +249,26 @@ std::chrono::high_resolution_clock::time_point Processor::getTimeWritten()
|
|||||||
void Processor::processorStart()
|
void Processor::processorStart()
|
||||||
{
|
{
|
||||||
stopTransfer.store(false);
|
stopTransfer.store(false);
|
||||||
INFO << "Starting processing";
|
DEBUG << "Starting processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Processor::processorStop()
|
void Processor::processorStop()
|
||||||
{
|
{
|
||||||
stopTransfer.store(true);
|
stopTransfer.store(true);
|
||||||
INFO << "Stopping processing";
|
DEBUG << "Stopping processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control the inner loop
|
// Control the inner loop
|
||||||
void Processor::processorUnpause()
|
void Processor::processorUnpause()
|
||||||
{
|
{
|
||||||
pauseTransfer.store(false);
|
pauseTransfer.store(false);
|
||||||
INFO << "unpausing processing";
|
DEBUG << "unpausing processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Processor::processorPause()
|
void Processor::processorPause()
|
||||||
{
|
{
|
||||||
pauseTransfer.store(true);
|
pauseTransfer.store(true);
|
||||||
INFO << "pausing processing";
|
DEBUG << "pausing processing";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statistics
|
// Statistics
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "trigger.hpp"
|
#include "trigger.hpp"
|
||||||
#define DBG
|
|
||||||
|
|
||||||
Trigger::Trigger(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *inputQ,
|
Trigger::Trigger(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *inputQ,
|
||||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQ,
|
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQ,
|
||||||
@ -36,14 +35,14 @@ Trigger::Trigger(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<fa
|
|||||||
|
|
||||||
Trigger::~Trigger(void)
|
Trigger::~Trigger(void)
|
||||||
{
|
{
|
||||||
INFO << "Trigger Destructor Called";
|
DEBUG << "Trigger Destructor Called";
|
||||||
|
|
||||||
// Stop the transer and join thread
|
// Stop the transer and join thread
|
||||||
stopTrigger.store(true);
|
stopTrigger.store(true);
|
||||||
pauseTrigger.store(true);
|
pauseTrigger.store(true);
|
||||||
triggerThread.join();
|
triggerThread.join();
|
||||||
|
|
||||||
INFO << "Destroyed Trigger Thread";
|
DEBUG << "Destroyed Trigger Thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
@ -52,9 +51,7 @@ uint32_t temp = 0;
|
|||||||
|
|
||||||
void Trigger::checkTriggerFalling(buffer* currentBuffer)
|
void Trigger::checkTriggerFalling(buffer* currentBuffer)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
DEBUG << "Checking a Trigger with #ch: " << (int)numCh << " triggering on ch: " << (int)triggerCh;
|
||||||
INFO << "Checking a Trigger with #ch: " << (int)numCh << " triggering on ch: " << (int)triggerCh;
|
|
||||||
#endif
|
|
||||||
// Compute the trigger
|
// Compute the trigger
|
||||||
for (int i = 0; i < (BUFFER_SIZE/64)/numCh; i++) {
|
for (int i = 0; i < (BUFFER_SIZE/64)/numCh; i++) {
|
||||||
currentBuffer->trigger[i] =
|
currentBuffer->trigger[i] =
|
||||||
@ -189,7 +186,7 @@ void Trigger::checkTriggerFalling(buffer* currentBuffer)
|
|||||||
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
if (temp < 32) {
|
if (temp < 32) {
|
||||||
INFO << "Trigger index: " << i << " value: " << std::hex << currentBuffer->trigger[i];
|
DEBUG << "Trigger index: " << i << " value: " << std::hex << currentBuffer->trigger[i];
|
||||||
temp++;
|
temp++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -198,9 +195,7 @@ void Trigger::checkTriggerFalling(buffer* currentBuffer)
|
|||||||
|
|
||||||
void Trigger::checkTriggerRising(buffer* currentBuffer)
|
void Trigger::checkTriggerRising(buffer* currentBuffer)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
DEBUG << "Checking a Trigger with #ch: " << (int)numCh << " triggering on ch: " << (int)triggerCh;
|
||||||
INFO << "Checking a Trigger with #ch: " << (int)numCh << " triggering on ch: " << (int)triggerCh;
|
|
||||||
#endif
|
|
||||||
// Compute the trigger
|
// Compute the trigger
|
||||||
for (int i = 0; i < (BUFFER_SIZE/64)/numCh; i++) {
|
for (int i = 0; i < (BUFFER_SIZE/64)/numCh; i++) {
|
||||||
currentBuffer->trigger[i] =
|
currentBuffer->trigger[i] =
|
||||||
@ -335,7 +330,7 @@ void Trigger::checkTriggerRising(buffer* currentBuffer)
|
|||||||
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
if (temp < 32) {
|
if (temp < 32) {
|
||||||
INFO << "Trigger index: " << i << " value: " << std::hex << currentBuffer->trigger[i];
|
DEBUG << "Trigger index: " << i << " value: " << std::hex << currentBuffer->trigger[i];
|
||||||
temp++;
|
temp++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -352,10 +347,10 @@ void Trigger::coreLoop()
|
|||||||
ERROR << "Input Queue null in trigger core loop";
|
ERROR << "Input Queue null in trigger core loop";
|
||||||
} else {
|
} else {
|
||||||
while (inputQueue->pop(currentBuffer) == false && stopTrigger.load() == false) {
|
while (inputQueue->pop(currentBuffer) == false && stopTrigger.load() == false) {
|
||||||
// INFO << "Waiting for first data element";
|
// DEBUG << "Waiting for first data element";
|
||||||
std::this_thread::sleep_for(std::chrono::microseconds(100));
|
std::this_thread::sleep_for(std::chrono::microseconds(100));
|
||||||
};
|
};
|
||||||
INFO << "Core Loop Entered";
|
DEBUG << "Core Loop Entered";
|
||||||
|
|
||||||
// Outer loop
|
// Outer loop
|
||||||
while (stopTrigger.load() == false) {
|
while (stopTrigger.load() == false) {
|
||||||
@ -367,7 +362,7 @@ void Trigger::coreLoop()
|
|||||||
if (inputQueue->pop(nextBuffer)) {
|
if (inputQueue->pop(nextBuffer)) {
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
INFO << "trigger next buffer";
|
DEBUG << "trigger next buffer";
|
||||||
|
|
||||||
// copy first value from next buffer to current buffer
|
// copy first value from next buffer to current buffer
|
||||||
currentBuffer->data[BUFFER_SIZE] = nextBuffer->data[0];
|
currentBuffer->data[BUFFER_SIZE] = nextBuffer->data[0];
|
||||||
@ -422,14 +417,14 @@ void Trigger::setRising()
|
|||||||
{
|
{
|
||||||
triggerPause();
|
triggerPause();
|
||||||
risingEdge = true;
|
risingEdge = true;
|
||||||
INFO << "Triggering on rising edge";
|
DEBUG << "Triggering on rising edge";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::setFalling()
|
void Trigger::setFalling()
|
||||||
{
|
{
|
||||||
triggerPause();
|
triggerPause();
|
||||||
risingEdge = false;
|
risingEdge = false;
|
||||||
INFO << "Triggering on falling edge";
|
DEBUG << "Triggering on falling edge";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trigger::getTriggerStatus()
|
bool Trigger::getTriggerStatus()
|
||||||
@ -440,25 +435,25 @@ bool Trigger::getTriggerStatus()
|
|||||||
void Trigger::triggerStop()
|
void Trigger::triggerStop()
|
||||||
{
|
{
|
||||||
stopTrigger.store(true);
|
stopTrigger.store(true);
|
||||||
INFO << "Stopping Trigger";
|
DEBUG << "Stopping Trigger";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::triggerStart()
|
void Trigger::triggerStart()
|
||||||
{
|
{
|
||||||
stopTrigger.store(false);
|
stopTrigger.store(false);
|
||||||
INFO << "Starting Trigger";
|
DEBUG << "Starting Trigger";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::triggerPause()
|
void Trigger::triggerPause()
|
||||||
{
|
{
|
||||||
pauseTrigger.store(true);
|
pauseTrigger.store(true);
|
||||||
INFO << "Pausing Trigger";
|
DEBUG << "Pausing Trigger";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::triggerUnpause()
|
void Trigger::triggerUnpause()
|
||||||
{
|
{
|
||||||
pauseTrigger.store(false);
|
pauseTrigger.store(false);
|
||||||
INFO << "Unpausing Trigger";
|
DEBUG << "Unpausing Trigger";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Trigger::getCount()
|
uint32_t Trigger::getCount()
|
||||||
|
Loading…
Reference in New Issue
Block a user