CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
CCSDSManager.h
Go to the documentation of this file.
1#ifndef CCSDS_MANAGER_H
2#define CCSDS_MANAGER_H
3
4#include <utility>
5#include "CCSDSPacket.h"
6#include "CCSDSResult.h"
7#include "CCSDSValidator.h"
8
9namespace CCSDS {
18 class Manager {
19 public:
23 Manager() = default;
24
30 explicit Manager(Packet packet) : m_templatePacket(std::move(packet)) {
31 m_templateIsSet = true;
33 m_validator.configure(true, true, true);
34
35 }
36
43 void setSyncPattern(uint32_t syncPattern);
44
50 uint32_t getSyncPattern() const;
51
57 void setSyncPatternEnable(bool enable);
58
64 bool getSyncPatternEnable() const;
65
71 [[nodiscard]] ResultBool setPacketTemplate(Packet packet);
72
78 void setDatFieldSize( uint16_t size );
79
86 ResultBool setApplicationData( const std::vector<uint8_t> &data );
87
93 void setAutoUpdateEnable( bool enable );
94
100 void setAutoValidateEnable( bool enable );
101
108
115 ResultBuffer getPacketBufferAtIndex( uint16_t index );
116
117
123 std::vector<uint8_t> getPacketsBuffer() const;
124
131
139
145 [[nodiscard]] uint16_t getTotalPackets() const;
146
152 [[nodiscard]] bool getAutoUpdateEnable() const { return m_updateEnable; }
153
160
166 std::vector<Packet> getPackets();
167
173 [[nodiscard]] ResultBool addPacket(Packet packet);
174
180 [[nodiscard]] ResultBool addPacketFromBuffer(const std::vector<uint8_t>& packetBuffer);
181
187 [[nodiscard]] ResultBool load(const std::vector<Packet>& packets);
188
194 [[nodiscard]] ResultBool load(const std::vector<uint8_t>& packetsBuffer);
195
201 [[nodiscard]] ResultBool read(const std::string& binaryFile);
202
208 [[nodiscard]] ResultBool write(const std::string& binaryFile) const;
209
215 [[nodiscard]] ResultBool readTemplate(const std::string& filename);
216
220 void clear();
221
225 void clearPackets();
226
233
239 std::vector<Packet>& getPacketsReference() { return m_packets; }
240
241 private:
243 bool m_templateIsSet { false };
244 bool m_updateEnable { true };
245 bool m_validateEnable { true };
246 bool m_syncPattEnable { false };
247 std::vector<Packet> m_packets;
248 uint16_t m_sequenceCount{ 0 };
249
251 uint32_t m_syncPattern{0x1ACFFC1D};
252 };
253} // namespace CCSDS
254
255#endif // CCSDS_MANAGER_H
Defines the Validator class for CCSDS packet validation.
Manages CCSDS packets and their templates.
bool m_templateIsSet
Boolean to indicate if Template has been set or not.
ResultBool setPacketTemplate(Packet packet)
Sets a new packet template.
std::vector< Packet > getPackets()
Retrieves all stored packets.
ResultBuffer getPacketTemplate()
Retrieves the packet template in serialized form.
std::vector< uint8_t > getPacketsBuffer() const
Retrieves a buffer containing all the stored packets sequentially.
uint16_t m_sequenceCount
void setDatFieldSize(uint16_t size)
Sets the size of the data field.
void setSyncPatternEnable(bool enable)
enable sync pattern utilization both in serialization, deserialization, read and write.
ResultBool setApplicationData(const std::vector< uint8_t > &data)
Sets the application data for the packet.
std::vector< Packet > m_packets
Collection of stored packets.
bool m_validateEnable
bool indicating whether automatic validation is enabled (default: true).
ResultBool readTemplate(const std::string &filename)
Load a template packet from a binary or configuration file.
std::vector< Packet > & getPacketsReference()
Returns a reference to the packets vector.
ResultBool load(const std::vector< Packet > &packets)
Load a vector of packets.
ResultBool addPacket(Packet packet)
Adds a new packet to the list.
uint32_t getSyncPattern() const
returns the currently set sync pattern.
bool m_syncPattEnable
bool indicating whether automatic sync pattern insertion is enabled (default: false).
uint16_t getTotalPackets() const
Retrieves the total number of packets managed.
Packet getTemplate()
Retrieves the packet template.
ResultBuffer getApplicationDataBuffer()
Retrieves the application data from the packets.
uint32_t m_syncPattern
void setSyncPattern(uint32_t syncPattern)
set sync pattern that should indicate the start of a CCSDS packet.
ResultBuffer getApplicationDataBufferAtIndex(uint16_t index)
Retrieves the application data from a packet at the given index.
ResultBool read(const std::string &binaryFile)
Load a packet or a series of packets from a binary file.
void clearPackets()
Clears the packets and sets the counter to 0.
Packet m_templatePacket
The template packet used for generating new packets.
void setAutoUpdateEnable(bool enable)
Enables or disables automatic updates for packets.
Manager(Packet packet)
Constructs a Manager with a given packet template.
bool getSyncPatternEnable() const
returns the current settings of the sync pattern enable
bool getAutoUpdateEnable() const
Checks if automatic updates are enabled.
void clear()
Clears the manager, removes all packets and template.
bool m_updateEnable
bool indicating whether automatic updates are enabled (default: true).
ResultBool addPacketFromBuffer(const std::vector< uint8_t > &packetBuffer)
Adds a new packet to the list.
void setAutoValidateEnable(bool enable)
Enables or disables automatic validation of packets.
Validator & getValidatorReference()
Returns a reverence to the manager's Validator.
ResultBool write(const std::string &binaryFile) const
Write a packet or a series of packets to a binary file.
Manager()=default
Default constructor.
ResultBuffer getPacketBufferAtIndex(uint16_t index)
Retrieves a packet at the specified index.
Validator m_validator
Represents a CCSDS (Consultative Committee for Space Data Systems) packet.
Definition CCSDSPacket.h:60
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:81
Handles validation of CCSDS packets.
void configure(bool validatePacketCoherence, bool validateSequenceCount, bool validateAgainstTemplate)
Configures validation options.
void setTemplatePacket(const Packet &templatePacket)
Sets the template packet for validation.
Contains definitions and classes for handling CCSDS headers.