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 // Weak references: Core owns the applications; slots fill via setApplication().
72 std::weak_ptr<rogue::protocols::packetizer::Application> app_[256];
73
75
76 public:
85 Controller(std::shared_ptr<rogue::protocols::packetizer::Transport> tran,
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
144 void setApplication(uint8_t dest, std::shared_ptr<rogue::protocols::packetizer::Application> app);
145};
146
147// Convenience
148typedef std::shared_ptr<rogue::protocols::packetizer::Controller> ControllerPtr;
149
150} // namespace packetizer
151} // namespace protocols
152}; // namespace rogue
153
154#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:74
void setApplication(uint8_t dest, std::shared_ptr< rogue::protocols::packetizer::Application > app)
Registers the application endpoint for a destination.
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.
std::weak_ptr< rogue::protocols::packetizer::Application > app_[256]
Definition Controller.h:72
~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::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:148