rogue
Loading...
Searching...
No Matches
TcpClient.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_INTERFACES_MEMORY_TCP_CLIENT_H__
18#define __ROGUE_INTERFACES_MEMORY_TCP_CLIENT_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <atomic>
24#include <memory>
25#include <string>
26#include <thread>
27#include <condition_variable>
28
29#include "rogue/Logging.h"
31
32namespace rogue {
33namespace interfaces {
34namespace memory {
35
55 // Inbound Address
56 std::string reqAddr_;
57
58 // Outbound Address
59 std::string respAddr_;
60
61 void* zmqCtx_ = nullptr;
62 void* zmqReq_ = nullptr;
63 void* zmqResp_ = nullptr;
64
65 // Thread background
66 void runThread();
67
68 // Log
69 std::shared_ptr<rogue::Logging> bridgeLog_;
70
72 protected:
73 std::unique_ptr<std::thread> thread_;
74 std::atomic<bool> threadEn_{false};
76
77 private:
78 // Lock
79 std::mutex bridgeMtx_;
80
81 // Probe state
82 std::mutex probeMtx_;
83 std::condition_variable probeCond_;
84 uint32_t probeSeq_;
85 uint32_t probeId_;
86 bool probeDone_;
87 std::string probeResult_;
88 bool waitReadyOnStart_;
89
90 public:
108 static std::shared_ptr<rogue::interfaces::memory::TcpClient> create(std::string addr, uint16_t port, bool waitReady = false);
109
113 static void setup_python();
114
134 TcpClient(std::string addr, uint16_t port, bool waitReady = false);
135
139 ~TcpClient();
140
146 [[deprecated("Use stop() instead")]] void close();
147
151 void stop();
152
166 bool waitReady(double timeout, double period);
167
176 void start();
177
183 void doTransaction(std::shared_ptr<rogue::interfaces::memory::Transaction> tran);
184};
185
189typedef std::shared_ptr<rogue::interfaces::memory::TcpClient> TcpClientPtr;
190
191} // namespace memory
192} // namespace interfaces
193}; // namespace rogue
194
195#endif
Memory slave device.
Definition Slave.h:54
Memory TCP bridge client.
Definition TcpClient.h:54
void close()
Closes bridge connections.
static std::shared_ptr< rogue::interfaces::memory::TcpClient > create(std::string addr, uint16_t port, bool waitReady=false)
Creates a TCP memory bridge client.
Definition TcpClient.cpp:49
~TcpClient()
Destroys the TCP client and releases transport resources.
bool waitReady(double timeout, double period)
Wait for the remote TcpServer path to respond to a bridge probe.
void stop()
Stops the bridge interface and worker thread.
void start()
Managed-lifecycle startup hook.
static void setup_python()
Registers this type with Python bindings.
void doTransaction(std::shared_ptr< rogue::interfaces::memory::Transaction > tran)
Processes a transaction received from the upstream master.
std::shared_ptr< rogue::interfaces::memory::TcpClient > TcpClientPtr
Shared pointer alias for TcpClient.
Definition TcpClient.h:189