rogue
Loading...
Searching...
No Matches
Transport.cpp
Go to the documentation of this file.
1
17#include "rogue/Directives.h"
18
20
21#include <memory>
22
23#include "rogue/GeneralError.h"
24#include "rogue/GilRelease.h"
25#include "rogue/Logging.h"
29
32
33#ifndef NO_PYTHON
34 #include <boost/python.hpp>
35namespace bp = boost::python;
36#endif
37
39rpp::TransportPtr rpp::Transport::create() {
40 rpp::TransportPtr r = std::make_shared<rpp::Transport>();
41 return (r);
42}
43
44void rpp::Transport::setup_python() {
45#ifndef NO_PYTHON
46
47 bp::class_<rpp::Transport, rpp::TransportPtr, bp::bases<ris::Master, ris::Slave>, boost::noncopyable>("Transport",
48 bp::init<>());
49
50 bp::implicitly_convertible<rpp::TransportPtr, ris::MasterPtr>();
51 bp::implicitly_convertible<rpp::TransportPtr, ris::SlavePtr>();
52#endif
53}
54
56rpp::Transport::Transport() {}
57
59rpp::Transport::~Transport() {
60 threadEn_ = false;
61 cntl_->stopQueue();
62 thread_->join();
63}
64
66void rpp::Transport::setController(rpp::ControllerPtr cntl) {
67 cntl_ = cntl;
68
69 // Start read thread
70 threadEn_ = true;
71 thread_ = new std::thread(&rpp::Transport::runThread, this);
72
73 // Set a thread name
74#ifndef __MACH__
75 pthread_setname_np(thread_->native_handle(), "PackTrans");
76#endif
77}
78
80void rpp::Transport::acceptFrame(ris::FramePtr frame) {
81 cntl_->transportRx(frame);
82}
83
85void rpp::Transport::runThread() {
86 ris::FramePtr frame;
87 Logging log("packetizer.Transport");
88 log.logThreadId();
89
90 while (threadEn_) {
91 if ((frame = cntl_->transportTx()) != NULL) sendFrame(frame);
92 }
93}
Structured Rogue logging helper.
Definition Logging.h:58
std::shared_ptr< rogue::interfaces::stream::Frame > FramePtr
Shared pointer alias for Frame.
Definition Frame.h:549
std::shared_ptr< rogue::protocols::packetizer::Transport > TransportPtr
Definition Transport.h:109
std::shared_ptr< rogue::protocols::packetizer::Controller > ControllerPtr
Definition Controller.h:140