From 0fa106a9a739c23f7dd1b82c7ed369db22c9b56e Mon Sep 17 00:00:00 2001 From: Mohacsi Istvan Date: Tue, 13 Jul 2021 14:14:34 +0200 Subject: [PATCH] Compiling and running --- jfj-combined/include/JfjFrameCache.hpp | 14 +++++++++----- jfj-combined/include/ZmqImagePublisher.hpp | 10 ++++------ jfj-combined/src/main.cpp | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/jfj-combined/include/JfjFrameCache.hpp b/jfj-combined/include/JfjFrameCache.hpp index 81c6a8d..609048d 100644 --- a/jfj-combined/include/JfjFrameCache.hpp +++ b/jfj-combined/include/JfjFrameCache.hpp @@ -3,6 +3,8 @@ #include #include +#include +#include #include #include #include @@ -81,7 +83,7 @@ public: // Queue for draining if(m_fill[idx]==m_MOD-1){ - std::cout << "Complete frame at " << idx << "\t(queued for draining)" < drain_queue(); + std::deque drain_queue; }; diff --git a/jfj-combined/include/ZmqImagePublisher.hpp b/jfj-combined/include/ZmqImagePublisher.hpp index 2a77d5f..31d4932 100644 --- a/jfj-combined/include/ZmqImagePublisher.hpp +++ b/jfj-combined/include/ZmqImagePublisher.hpp @@ -29,7 +29,6 @@ It also has an internal mutex that can be used for thread-safe access to the underlying connection; **/ -template class ZmqPublisher { protected: const uint16_t m_port; @@ -39,8 +38,8 @@ class ZmqPublisher { std::mutex g_zmq_socket; public: - ZmqPublisher(std::string ip, uint16_t port) : - m_port(port), m_address("tcp://*:" + std::to_string(port)), m_ctx(ZMQ_PUB_IO_THREADS), m_socket(m_ctx, ZMQ_PUB) { + ZmqPublisher(std::string ip, uint16_t port, uint32_t n_threads) : + m_port(port), m_address("tcp://*:" + std::to_string(port)), m_ctx(n_threads), m_socket(m_ctx, ZMQ_PUB) { // Bind the socket m_socket.bind(m_address.c_str()); std::cout << "Initialized ZMQ publisher at " << m_address << std::endl; @@ -55,10 +54,9 @@ class ZmqPublisher { Specialized publisher to send 'ImageBinaryFormat' data format as multipart message. It also takes care of thread safety. **/ -template -class ZmqImagePublisher: public ZmqPublisher { +class ZmqImagePublisher: public ZmqPublisher { public: - ZmqImagePublisher(std::string ip, uint16_t port) : ZmqPublisher(ip, port) {}; + ZmqImagePublisher(std::string ip, uint16_t port, uint32_t n_threads) : ZmqPublisher(ip, port, n_threads) {}; const std::string topic = "IMAGEDATA"; void sendImage(ImageBinaryFormat& image){ diff --git a/jfj-combined/src/main.cpp b/jfj-combined/src/main.cpp index eec7e80..1006f1d 100644 --- a/jfj-combined/src/main.cpp +++ b/jfj-combined/src/main.cpp @@ -20,7 +20,7 @@ int main (int argc, char *argv[]) { std::cout << "Creating ZMQ socket..." << std::endl; - ZmqImagePublisher<2> pub("*", 5200); + ZmqImagePublisher pub("*", 5200, 2); // ... and extracting sender function std::function zmq_publish = std::bind(&ZmqImagePublisher::sendImage, &pub, std::placeholders::_1);