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 <memory>
24
25#include "rogue/Logging.h"
26#include "rogue/Queue.h"
29
30namespace rogue {
31namespace protocols {
32namespace packetizer {
33
34class Application;
35class Transport;
36class Header;
37
46 protected:
47 // parameters
48 bool enSsi_;
49 uint32_t appIndex_;
50 uint32_t tranIndex_;
51 bool transSof_[256];
52 uint32_t tranCount_[256];
53 uint32_t crc_[256];
54 uint8_t tranDest_;
55 uint32_t dropCount_;
56 uint32_t headSize_;
57 uint32_t tailSize_;
58 uint32_t alignSize_;
59
60 struct timeval timeout_;
61
62 std::shared_ptr<rogue::Logging> log_;
63
64 std::shared_ptr<rogue::interfaces::stream::Frame> tranFrame_[256];
65
66 std::mutex appMtx_;
67 std::mutex tranMtx_;
68
69 std::shared_ptr<rogue::protocols::packetizer::Transport> tran_;
70 std::shared_ptr<rogue::protocols::packetizer::Application>* app_;
71
73
74 public:
84 Controller(std::shared_ptr<rogue::protocols::packetizer::Transport> tran,
85 std::shared_ptr<rogue::protocols::packetizer::Application>* app,
86 uint32_t headSize,
87 uint32_t tailSize,
88 uint32_t alignSize,
89 bool enSsi);
90
93
99 std::shared_ptr<rogue::interfaces::stream::Frame> reqFrame(uint32_t size);
100
105 virtual void transportRx(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
106
108 void stopQueue();
109
111 void stop();
112
117 std::shared_ptr<rogue::interfaces::stream::Frame> transportTx();
118
124 virtual void applicationRx(std::shared_ptr<rogue::interfaces::stream::Frame> frame, uint8_t id);
125
130 uint32_t getDropCount();
131
136 void setTimeout(uint32_t timeout);
137};
138
139// Convenience
140typedef std::shared_ptr<rogue::protocols::packetizer::Controller> ControllerPtr;
141
142} // namespace packetizer
143} // namespace protocols
144}; // namespace rogue
145
146#endif
Thread-safe bounded queue with optional busy threshold.
Definition Queue.h:38
Packetizer base controller.
Definition Controller.h:45
rogue::Queue< std::shared_ptr< rogue::interfaces::stream::Frame > > tranQueue_
Definition Controller.h:72
std::shared_ptr< rogue::interfaces::stream::Frame > tranFrame_[256]
Definition Controller.h:64
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:70
std::shared_ptr< rogue::protocols::packetizer::Transport > tran_
Definition Controller.h:69
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:62
std::shared_ptr< rogue::protocols::packetizer::Controller > ControllerPtr
Definition Controller.h:140