F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
DpContainer.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpContainer.hpp
3 // \author bocchino
4 // \brief hpp file for DpContainer
5 // ======================================================================
6 
7 #ifndef Fw_DpContainer_HPP
8 #define Fw_DpContainer_HPP
9 
10 #include "Fw/Buffer/Buffer.hpp"
11 #include "Fw/Dp/DpStateEnumAc.hpp"
12 #include "Fw/Time/Time.hpp"
13 #include "Utils/Hash/Hash.hpp"
16 
17 namespace Fw {
18 
20 class DpContainer {
21  public:
22  // ----------------------------------------------------------------------
23  // Constants and Types
24  // ----------------------------------------------------------------------
25 
27  struct Header {
31  static constexpr FwSizeType PACKET_DESCRIPTOR_OFFSET = 0;
35  static constexpr FwDpPriorityType PRIORITY_OFFSET = ID_OFFSET + sizeof(FwDpIdType);
47  static constexpr FwSizeType SIZE = DATA_SIZE_OFFSET + sizeof(FwSizeType);
48  };
49 
58 
59  public:
60  // ----------------------------------------------------------------------
61  // Constructor
62  // ----------------------------------------------------------------------
63 
66  const Fw::Buffer& buffer
67  );
68 
70  DpContainer();
71 
72  public:
73  // ----------------------------------------------------------------------
74  // Public member functions
75  // ----------------------------------------------------------------------
76 
79  FwDpIdType getId() const { return this->m_id; }
80 
83  FwSizeType getDataSize() const { return this->m_dataSize; }
84 
87  Fw::Buffer getBuffer() const { return this->m_buffer; }
88 
91 
94  FwDpPriorityType getPriority() const { return this->m_priority; }
95 
98  Fw::Time getTimeTag() const { return this->m_timeTag; }
99 
103 
108 
111  void serializeHeader();
112 
114  void setId(FwDpIdType id
115  ) {
116  this->m_id = id;
117  }
118 
121  ) {
122  this->m_priority = priority;
123  }
124 
126  void setTimeTag(Fw::Time timeTag
127  ) {
128  this->m_timeTag = timeTag;
129  }
130 
133  ) {
134  this->m_procTypes = procTypes;
135  }
136 
138  void setDpState(DpState dpState
139  ) {
140  this->m_dpState = dpState;
141  }
142 
144  void setDataSize(FwSizeType dataSize
145  ) {
146  this->m_dataSize = dataSize;
147  }
148 
150  void setBuffer(const Buffer& buffer
151  );
152 
154  void updateHeaderHash();
155 
158  // Data hash goes after the header, the header hash, and the data
159  return Header::SIZE + HASH_DIGEST_LENGTH + this->m_dataSize;
160  }
161 
163  void updateDataHash();
164 
165  public:
166  // ----------------------------------------------------------------------
167  // Public static functions
168  // ----------------------------------------------------------------------
169 
171  static constexpr FwSizeType getPacketSizeForDataSize(FwSizeType dataSize
172  ) {
173  return Header::SIZE + dataSize + 2 * HASH_DIGEST_LENGTH;
174  }
175 
176  PRIVATE:
177  // ----------------------------------------------------------------------
178  // Private member functions
179  // ----------------------------------------------------------------------
180 
182  void initUserDataField();
183 
184  public:
185  // ----------------------------------------------------------------------
186  // Public member variables
187  // ----------------------------------------------------------------------
188 
191 
192  PROTECTED:
193  // ----------------------------------------------------------------------
194  // Protected member variables
195  // ----------------------------------------------------------------------
196 
200 
203 
206 
209 
212 
215 
218 
221 };
222 
223 } // end namespace Fw
224 
225 #endif
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define HASH_DIGEST_LENGTH
Definition: CRC32.hpp:18
U32 FwDpPriorityType
Definition: FpConfig.h:74
U32 FwDpIdType
Definition: FpConfig.h:71
U32 FwPacketDescriptorType
Definition: FpConfig.h:53
PlatformSizeType FwSizeType
Definition: FpConfig.h:18
U8 SerialType
The serial representation type.
A data product Container.
Definition: DpContainer.hpp:20
DpCfg::ProcType::SerialType m_procTypes
The processing types.
void setPriority(FwDpPriorityType priority)
Set the priority.
Fw::Time getTimeTag() const
Definition: DpContainer.hpp:98
static constexpr FwSizeType DATA_OFFSET
The data offset.
Definition: DpContainer.hpp:53
DpContainer()
Constructor for container with default initialization.
Definition: DpContainer.cpp:28
DpCfg::ProcType::SerialType getProcTypes() const
FwDpPriorityType m_priority
The priority.
Fw::ExternalSerializeBuffer m_dataBuffer
The data buffer.
Header::UserData m_userData
The user data.
FwDpIdType getId() const
Definition: DpContainer.hpp:79
void setId(FwDpIdType id)
Set the id.
static constexpr FwSizeType MIN_PACKET_SIZE
Definition: DpContainer.hpp:57
void updateHeaderHash()
Update the header hash.
void setTimeTag(Fw::Time timeTag)
Set the time tag.
void setDpState(DpState dpState)
Set the data product state.
FwDpPriorityType getPriority() const
Definition: DpContainer.hpp:94
Fw::Buffer getBuffer() const
Definition: DpContainer.hpp:87
Fw::SerializeStatus deserializeHeader()
Definition: DpContainer.cpp:38
Time m_timeTag
The time tag.
FwDpIdType m_id
void serializeHeader()
Definition: DpContainer.cpp:92
static constexpr FwSizeType getPacketSizeForDataSize(FwSizeType dataSize)
Get the packet size for a given data size.
FwSizeType getPacketSize() const
Get the packet size corresponding to the data size.
Definition: DpContainer.hpp:90
Buffer m_buffer
The packet buffer.
FwSizeType m_dataSize
The data size.
FwSizeType getDataSize() const
Definition: DpContainer.hpp:83
void setBuffer(const Buffer &buffer)
Set the packet buffer.
FwSizeType getDataHashOffset() const
Get the data hash offset.
static constexpr FwSizeType HEADER_HASH_OFFSET
The header hash offset.
Definition: DpContainer.hpp:51
void setDataSize(FwSizeType dataSize)
Set the data size.
void updateDataHash()
Update the data hash.
DpState m_dpState
The data product state.
void setProcTypes(DpCfg::ProcType::SerialType procTypes)
Set the processing types bit mask.
@ SERIALIZED_SIZE
The size of the serial representation.
Definition: Time.hpp:9
@ SERIALIZED_SIZE
Definition: Time.hpp:13
@ CONTAINER_USER_DATA_SIZE
SerializeStatus
forward declaration for string
A DpContainer packet header.
Definition: DpContainer.hpp:27
static constexpr FwSizeType ID_OFFSET
The offset for the id field.
Definition: DpContainer.hpp:33
static constexpr FwSizeType TIME_TAG_OFFSET
The offset for the time tag field.
Definition: DpContainer.hpp:37
static constexpr FwSizeType DP_STATE_OFFSET
The offset of the data product state field.
Definition: DpContainer.hpp:43
static constexpr FwSizeType PACKET_DESCRIPTOR_OFFSET
The offset for the packet descriptor field.
Definition: DpContainer.hpp:31
static constexpr FwSizeType PROC_TYPES_OFFSET
The offset for the processing types field.
Definition: DpContainer.hpp:39
static constexpr FwSizeType DATA_SIZE_OFFSET
The offset for the data size field.
Definition: DpContainer.hpp:45
static constexpr FwSizeType SIZE
The header size.
Definition: DpContainer.hpp:47
U8[DpCfg::CONTAINER_USER_DATA_SIZE] UserData
The type of user data.
Definition: DpContainer.hpp:29
static constexpr FwSizeType USER_DATA_OFFSET
The offset for the user data field.
Definition: DpContainer.hpp:41
static constexpr FwDpPriorityType PRIORITY_OFFSET
The offset for the priority field.
Definition: DpContainer.hpp:35