rogue
Loading...
Searching...
No Matches
Application.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
30namespace rpr = rogue::protocols::rssi;
32
33#ifndef NO_PYTHON
34 #include <boost/python.hpp>
35namespace bp = boost::python;
36#endif
37
39rpr::ApplicationPtr rpr::Application::create() {
40 rpr::ApplicationPtr r = std::make_shared<rpr::Application>();
41 return (r);
42}
43
44void rpr::Application::setup_python() {
45#ifndef NO_PYTHON
46
47 bp::class_<rpr::Application, rpr::ApplicationPtr, bp::bases<ris::Master, ris::Slave>, boost::noncopyable>(
48 "Application",
49 bp::init<>());
50
51 bp::implicitly_convertible<rpr::ApplicationPtr, ris::MasterPtr>();
52 bp::implicitly_convertible<rpr::ApplicationPtr, ris::SlavePtr>();
53#endif
54}
55
57rpr::Application::Application() {}
58
60rpr::Application::~Application() {
61 threadEn_ = false;
62 cntl_->stopQueue();
63 thread_->join();
64}
65
67void rpr::Application::setController(rpr::ControllerPtr cntl) {
68 cntl_ = cntl;
69
70 // Start read thread
71 threadEn_ = true;
72 thread_ = new std::thread(&rpr::Application::runThread, this);
73
74 // Set a thread name
75#ifndef __MACH__
76 pthread_setname_np(thread_->native_handle(), "RssiApp");
77#endif
78}
79
81ris::FramePtr rpr::Application::acceptReq(uint32_t size, bool zeroCopyEn) {
82 return (cntl_->reqFrame(size));
83}
84
86void rpr::Application::acceptFrame(ris::FramePtr frame) {
87 cntl_->applicationRx(frame);
88}
89
91void rpr::Application::runThread() {
92 ris::FramePtr frame;
93 Logging log("rssi.Application");
94 log.logThreadId();
95
96 while (threadEn_) {
97 if ((frame = cntl_->applicationTx()) != NULL) sendFrame(frame);
98 }
99}
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::rssi::Application > ApplicationPtr
std::shared_ptr< rogue::protocols::rssi::Controller > ControllerPtr
Definition Controller.h:448