mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
adding namespace sls to public receiver api
This commit is contained in:
parent
121a3ad733
commit
2020407438
@ -11,6 +11,8 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls{
|
||||||
|
|
||||||
/** Circular Fifo (a.k.a. Circular Buffer)
|
/** Circular Fifo (a.k.a. Circular Buffer)
|
||||||
* Thread safe for one reader, and one writer */
|
* Thread safe for one reader, and one writer */
|
||||||
template <typename Element> class CircularFifo {
|
template <typename Element> class CircularFifo {
|
||||||
@ -127,3 +129,5 @@ size_t CircularFifo<Element>::increment(size_t i) const {
|
|||||||
i = (i + 1) % capacity;
|
i = (i + 1) % capacity;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
class ClientInterface;
|
class ClientInterface;
|
||||||
|
|
||||||
|
namespace sls
|
||||||
|
{
|
||||||
|
|
||||||
class Receiver : private virtual slsDetectorDefs {
|
class Receiver : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -86,3 +89,5 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<ClientInterface> tcpipInterface;
|
std::unique_ptr<ClientInterface> tcpipInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
@ -33,9 +33,9 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
|||||||
DestroyFifos();
|
DestroyFifos();
|
||||||
|
|
||||||
// create fifos
|
// create fifos
|
||||||
fifoBound = new CircularFifo<char>(fifoDepth);
|
fifoBound = new sls::CircularFifo<char>(fifoDepth);
|
||||||
fifoFree = new CircularFifo<char>(fifoDepth);
|
fifoFree = new sls::CircularFifo<char>(fifoDepth);
|
||||||
fifoStream = new CircularFifo<char>(fifoDepth);
|
fifoStream = new sls::CircularFifo<char>(fifoDepth);
|
||||||
// allocate memory
|
// allocate memory
|
||||||
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
||||||
memory = (char *)malloc(mem_len);
|
memory = (char *)malloc(mem_len);
|
||||||
|
@ -92,13 +92,13 @@ class Fifo : private virtual slsDetectorDefs {
|
|||||||
char *memory;
|
char *memory;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of bound data in memory */
|
/** Circular Fifo pointing to addresses of bound data in memory */
|
||||||
CircularFifo<char> *fifoBound;
|
sls::CircularFifo<char> *fifoBound;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of freed data in memory */
|
/** Circular Fifo pointing to addresses of freed data in memory */
|
||||||
CircularFifo<char> *fifoFree;
|
sls::CircularFifo<char> *fifoFree;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
||||||
CircularFifo<char> *fifoStream;
|
sls::CircularFifo<char> *fifoStream;
|
||||||
|
|
||||||
/** Fifo depth set */
|
/** Fifo depth set */
|
||||||
int fifoDepth;
|
int fifoDepth;
|
||||||
|
@ -216,9 +216,9 @@ int main(int argc, char *argv[]) {
|
|||||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
|
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
|
||||||
(long)syscall(SYS_gettid));
|
(long)syscall(SYS_gettid));
|
||||||
|
|
||||||
std::unique_ptr<Receiver> receiver = nullptr;
|
std::unique_ptr<sls::Receiver> receiver = nullptr;
|
||||||
try {
|
try {
|
||||||
receiver = sls::make_unique<Receiver>(startTCPPort + i);
|
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG(logINFOBLUE)
|
LOG(logINFOBLUE)
|
||||||
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)
|
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls{
|
||||||
|
|
||||||
Receiver::~Receiver() = default;
|
Receiver::~Receiver() = default;
|
||||||
|
|
||||||
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||||
@ -142,3 +144,5 @@ void Receiver::registerCallBackRawDataModifyReady(
|
|||||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
||||||
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Receiver r(argc, argv);
|
sls::Receiver r(argc, argv);
|
||||||
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||||
sem_wait(&semaphore);
|
sem_wait(&semaphore);
|
||||||
sem_destroy(&semaphore);
|
sem_destroy(&semaphore);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
using sls::CircularFifo;
|
||||||
|
|
||||||
TEST_CASE("Empty buffer") {
|
TEST_CASE("Empty buffer") {
|
||||||
CircularFifo<char> fifo(0);
|
CircularFifo<char> fifo(0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user