IpbusMock  1.0.0
Library which integrates IPbus use in Phoenix
Loading...
Searching...
No Matches
HwInterface.h
Go to the documentation of this file.
1#pragma once
2
3#include "PGenericSocketManager.h"
4#include "PIpBusBackend.h"
5#include "PMockBackend.h"
6#include "data_stream_assert.h"
7#include "uhal/uhal.hpp"
8#include <map>
9#include <memory>
10#include <string>
11
12namespace PIpBusInterface {
13
14typedef PGenericSocketManager<std::string, PIpBusBackend, PMockBackend> SocketManager;
15typedef SocketManager::Backend Backend;
16typedef SocketManager::Mock Mock;
17class HwInterface;
18
19class Node {
20public:
21 Node(HwInterface *_hwInterface, const std::string _nodeId);
22 ~Node();
23
24 uint32_t read() const;
25 std::vector<uint32_t> readBlock(const uint32_t &aSize) const;
26 // ValVector< uint32_t > uhal::Node::readBlock(const uint32_t & aSize) const;
27
28 bool write(const uint32_t &aValue) const;
29 bool writeBlock(const std::vector<uint32_t> &aValues) const;
30 // ValHeader uhal::Node::writeBlock ( const std::vector< uint32_t > &
31 // aValues ) const
32
33private:
35 std::string nodeId;
36};
37
39public:
40 friend Node;
41 // Constructor
42 HwInterface(std::string connectionFilePath, std::string connectionId,
43 PSocketMode::PSocketMode _mock_mode,
44 std::string mock_directory = "");
45 // Destructor
46 virtual ~HwInterface();
47 Node &getNode(const std::string nodeId);
48
49protected:
50 std::string connectionFilePath;
51 std::string connectionId;
52 PSocketMode::PSocketMode mock_mode;
53 std::string mock_directory;
54 static SocketManager manager; // Mock mode
55 std::map<std::string, std::unique_ptr<Node>> nodes;
56 bool write(const std::string &nodeId, const uint32_t &aValue);
57 uint32_t read(const std::string nodeId) const;
58 bool writeBlock(const std::string &nodeId,
59 const std::vector<uint32_t> &aValues) const;
60 std::vector<uint32_t> readBlock(const std::string &nodeId,
61 const uint32_t &aSize) const;
62};
63
64} // namespace PIpBusInterface
PSocketMode::PSocketMode mock_mode
Definition HwInterface.h:52
virtual ~HwInterface()
Destructor for the HwInterface class.
std::vector< uint32_t > readBlock(const std::string &nodeId, const uint32_t &aSize) const
Reads a block of data from a specific node.
bool write(const std::string &nodeId, const uint32_t &aValue)
Writes data to a specific node.
Node & getNode(const std::string nodeId)
Retrieves a node by its identifier.
bool writeBlock(const std::string &nodeId, const std::vector< uint32_t > &aValues) const
Writes a block of data to a specific node.
static SocketManager manager
Definition HwInterface.h:54
std::map< std::string, std::unique_ptr< Node > > nodes
Definition HwInterface.h:55
uint32_t read(const std::string nodeId) const
Reads data from a specific node.
HwInterface(std::string connectionFilePath, std::string connectionId, PSocketMode::PSocketMode _mock_mode, std::string mock_directory="")
Constructor for the HwInterface class.
bool writeBlock(const std::vector< uint32_t > &aValues) const
Writes a block of data to a specific node.
uint32_t read() const
Reads a value from the node.
~Node()
Destructor for the Node class.
Node(HwInterface *_hwInterface, const std::string _nodeId)
Constructor for the Node class.
bool write(const uint32_t &aValue) const
Writes a value to the node.
std::vector< uint32_t > readBlock(const uint32_t &aSize) const
Reads a block of data from the node.
HwInterface * hwInterface
Definition HwInterface.h:34
SocketManager::Backend Backend
Definition HwInterface.h:15
PGenericSocketManager< std::string, PIpBusBackend, PMockBackend > SocketManager
Definition HwInterface.h:14
SocketManager::Mock Mock
Definition HwInterface.h:16