rogue
Loading...
Searching...
No Matches
Controller.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_PROTOCOLS_PACKETIZER_CONTROLLER_H__
18#define __ROGUE_PROTOCOLS_PACKETIZER_CONTROLLER_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <atomic>
24#include <memory>
25
26#include "rogue/Logging.h"
27#include "rogue/Queue.h"
30
31namespace rogue {
32namespace protocols {
33namespace packetizer {
34
35class Application;
36class Transport;
37class Header;
38
47 protected:
48 // parameters
49 bool enSsi_;
50 uint32_t appIndex_;
51 uint32_t tranIndex_;
52 bool transSof_[256];
53 uint32_t tranCount_[256];
54 uint32_t crc_[256];
55 uint8_t tranDest_;
56 std::atomic<uint32_t> dropCount_;
57 uint32_t headSize_;
58 uint32_t tailSize_;
59 uint32_t alignSize_;
60
61 struct timeval timeout_;
62
63 std::shared_ptr<rogue::Logging> log_;
64
65 std::shared_ptr<rogue::interfaces::stream::Frame> tranFrame_[256];
66
67 std::mutex appMtx_;
68 std::mutex tranMtx_;
69
70 std::shared_ptr<rogue::protocols::packetizer::Transport> tran_;
71 std::shared_ptr<rogue::protocols::packetizer::Application>* app_;
72
74
75 public:
85 Controller(std::shared_ptr<rogue::protocols::packetizer::Transport> tran,
86 std::shared_ptr<rogue::protocols::packetizer::Application>* app,
87 uint32_t headSize,
88 uint32_t tailSize,
89 uint32_t alignSize,
90 bool enSsi);
91
94
100 std::shared_ptr<rogue::interfaces::stream::Frame> reqFrame(uint32_t size);
101
106 virtual void transportRx(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
107
109 void stopQueue();
110
112 void stop();
113
118 std::shared_ptr<rogue::interfaces::stream::Frame> transportTx();
119
125 virtual void applicationRx(std::shared_ptr<rogue::interfaces::stream::Frame> frame, uint8_t id);
126
131 uint32_t getDropCount();
132
137 void setTimeout(uint32_t timeout);
138};
139
140// Convenience
141typedef std::shared_ptr<rogue::protocols::packetizer::Controller> ControllerPtr;
142
143} // namespace packetizer
144} // namespace protocols
145}; // namespace rogue
146
147#endif
Thread-safe bounded queue with optional busy threshold.
Definition Queue.h:39
Packetizer base controller.
Definition Controller.h:46
rogue::Queue< std::shared_ptr< rogue::interfaces::stream::Frame > > tranQueue_
Definition Controller.h:73
std::atomic< uint32_t > dropCount_
Definition Controller.h:56
std::shared_ptr< rogue::interfaces::stream::Frame > tranFrame_[256]
Definition Controller.h:65
virtual void transportRx(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Processes a frame received from transport.
void stopQueue()
Stops the internal transmit queue.
void stop()
Stops controller processing.
~Controller()
Destroys the packetizer controller base.
virtual void applicationRx(std::shared_ptr< rogue::interfaces::stream::Frame > frame, uint8_t id)
Processes a frame received from an application endpoint.
std::shared_ptr< rogue::protocols::packetizer::Application > * app_
Definition Controller.h:71
std::shared_ptr< rogue::protocols::packetizer::Transport > tran_
Definition Controller.h:70
std::shared_ptr< rogue::interfaces::stream::Frame > transportTx()
Returns the next frame for transport transmission.
std::shared_ptr< rogue::interfaces::stream::Frame > reqFrame(uint32_t size)
Allocates a transport-path frame.
uint32_t getDropCount()
Returns dropped-frame counter.
void setTimeout(uint32_t timeout)
Sets timeout in microseconds for frame transmits.
std::shared_ptr< rogue::Logging > log_
Definition Controller.h:63
std::shared_ptr< rogue::protocols::packetizer::Controller > ControllerPtr
Definition Controller.h:141