F´ Flight Software - C/C++ Documentation  NASA-v2.1.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Sequence.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Sequence.cpp
3 // \author Bocchino/Canham
4 // \brief Implementation file for CmdSequencer::Sequence
5 //
6 // Copyright (C) 2009-2018 California Institute of Technology.
7 // ALL RIGHTS RESERVED. United States Government Sponsorship
8 // acknowledged.
9 
10 #include <Fw/Types/Assert.hpp>
12 
13 namespace Svc {
14 
17  m_component(component),
18  m_events(*this),
19  m_allocatorId(0)
20  {
21 
22  };
23 
26  {
27 
28  }
29 
31  Header(void) :
32  m_fileSize(0),
33  m_numRecords(0),
34  m_timeBase(TB_DONT_CARE),
35  m_timeContext(FW_CONTEXT_DONT_CARE)
36  {
37 
38  }
39 
42  {
43  Fw::Time validTime = component.getTime();
44  Events& events = component.m_sequence->m_events;
45  // Time base
46  const TimeBase validTimeBase = validTime.getTimeBase();
47  if (
48  (this->m_timeBase != validTimeBase) and
49  (this->m_timeBase != TB_DONT_CARE)
50  ) {
51  events.timeBaseMismatch(
52  validTimeBase,
53  this->m_timeBase
54  );
55  return false;
56  }
57  // Time context
58  const FwTimeContextStoreType validContext = validTime.getContext();
59  if (
60  (this->m_timeContext != validContext) and
61  (this->m_timeContext != FW_CONTEXT_DONT_CARE)
62  ) {
63  events.timeContextMismatch(
64  validContext,
65  this->m_timeContext
66  );
67  return false;
68  }
69  // Canonicalize time
70  this->m_timeBase = validTimeBase;
71  this->m_timeContext = validContext;
72  return true;
73  }
74 
77  NATIVE_INT_TYPE identifier,
78  Fw::MemAllocator& allocator,
79  NATIVE_UINT_TYPE bytes
80  )
81  {
82  // has to be at least as big as a header
84  bool recoverable;
85  this->m_allocatorId = identifier;
86  this->m_buffer.setExtBuffer(
87  static_cast<U8*>(allocator.allocate(identifier,bytes,recoverable)),
88  bytes
89  );
90  }
91 
94  {
95  allocator.deallocate(
96  this->m_allocatorId,
97  this->m_buffer.getBuffAddr()
98  );
99  this->m_buffer.clear();
100  }
101 
104  getHeader(void) const
105  {
106  return this->m_header;
107  }
108 
111  {
112  this->m_fileName = fileName;
113  this->m_logFileName = fileName;
114  }
115 
118  {
119  return this->m_fileName;
120  }
121 
124  {
125  return this->m_logFileName;
126  }
127 
128 }
129 
Svc::CmdSequencerComponentImpl::Sequence::Sequence
Sequence(CmdSequencerComponentImpl &component)
Construct a Sequence object.
Definition: Sequence.cpp:16
Svc::CmdSequencerComponentImpl::Sequence::m_allocatorId
NATIVE_INT_TYPE m_allocatorId
The allocator ID.
Definition: CmdSequencerImpl.hpp:308
Svc::CmdSequencerComponentImpl::Sequence::deallocateBuffer
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
Definition: Sequence.cpp:93
Svc::CmdSequencerComponentImpl::Sequence::Header::validateTime
bool validateTime(CmdSequencerComponentImpl &component)
Definition: Sequence.cpp:41
Svc::CmdSequencerComponentImpl::Sequence::Header::SERIALIZED_SIZE
@ SERIALIZED_SIZE
Serialized size of header.
Definition: CmdSequencerImpl.hpp:165
Svc::CmdSequencerComponentImpl::Sequence::Events::timeContextMismatch
void timeContextMismatch(const U32 currTimeContext, const U32 seqTimeContext)
Time context mismatch.
Definition: Events.cpp:161
Fw::Time
Definition: Time.hpp:10
Svc::CmdSequencerComponentImpl::Sequence::m_header
Header m_header
The sequence header.
Definition: CmdSequencerImpl.hpp:311
Fw::Time::getTimeBase
TimeBase getTimeBase(void) const
Definition: Time.cpp:142
Fw::LogStringArg
Definition: LogString.hpp:11
Fw::MemAllocator::deallocate
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
FW_CONTEXT_DONT_CARE
#define FW_CONTEXT_DONT_CARE
Don't care value for time contexts in sequences.
Definition: FpConfig.hpp:341
Svc::CmdSequencerComponentImpl::Sequence::m_fileName
Fw::CmdStringArg m_fileName
The sequence file name.
Definition: CmdSequencerImpl.hpp:299
Svc::CmdSequencerComponentImpl::Sequence::~Sequence
virtual ~Sequence(void)
Destroy a Sequence object.
Definition: Sequence.cpp:25
Fw::MemAllocator::allocate
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
TimeBase
TimeBase
Definition: FpConfig.hpp:327
Fw::CmdStringArg
Definition: CmdString.hpp:11
FwTimeContextStoreType
#define FwTimeContextStoreType
Storage conversion for time context in scripts/ground interface.
Definition: FpConfig.hpp:340
Assert.hpp
Fw::ExternalSerializeBuffer::clear
void clear(void)
clear external buffer
Definition: Serializable.cpp:711
Svc::CmdSequencerComponentImpl::Sequence::m_logFileName
Fw::LogStringArg m_logFileName
Copy of file name for events.
Definition: CmdSequencerImpl.hpp:302
TB_DONT_CARE
@ TB_DONT_CARE
Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed.
Definition: FpConfig.hpp:331
Svc::CmdSequencerComponentImpl::Sequence::Events::timeBaseMismatch
void timeBaseMismatch(const U32 currTimeBase, const U32 seqTimeBase)
Time base mismatch.
Definition: Events.cpp:148
Svc::CmdSequencerComponentImpl::Sequence::getFileName
Fw::CmdStringArg & getFileName(void)
Definition: Sequence.cpp:117
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
Fw::ExternalSerializeBuffer::setExtBuffer
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
Definition: Serializable.cpp:705
Fw::Time::getContext
FwTimeContextStoreType getContext(void) const
Definition: Time.cpp:146
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Svc::CmdSequencerComponentImpl::Sequence::Events
Sequence event reporting.
Definition: CmdSequencerImpl.hpp:55
Svc::CmdSequencerComponentImpl::Sequence::setFileName
void setFileName(const Fw::CmdStringArg &fileName)
Set the file name. Also sets the log file name.
Definition: Sequence.cpp:110
Svc::CmdSequencerComponentImpl::Sequence::getHeader
const Header & getHeader(void) const
Get the sequence header.
Definition: Sequence.cpp:104
Fw::MemAllocator
Definition: MemAllocator.hpp:44
Svc::CmdSequencerComponentImpl::Sequence::Header
A sequence header.
Definition: CmdSequencerImpl.hpp:159
Svc::CmdSequencerComponentImpl::Sequence::Header::Header
Header(void)
Construct a Header object.
Definition: Sequence.cpp:31
Svc::CmdSequencerComponentImpl::Sequence::m_events
Events m_events
Event reporting.
Definition: CmdSequencerImpl.hpp:296
Svc
Definition: ActiveRateGroupImplCfg.hpp:18
Svc::CmdSequencerComponentImpl::Sequence::getLogFileName
Fw::LogStringArg & getLogFileName(void)
Definition: Sequence.cpp:123
Svc::CmdSequencerComponentImpl
Definition: CmdSequencerImpl.hpp:21
CmdSequencerImpl.hpp
Svc::CmdSequencerComponentImpl::Sequence::m_buffer
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
Definition: CmdSequencerImpl.hpp:305
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Svc::CmdSequencerComponentImpl::Sequence::allocateBuffer
void allocateBuffer(NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, NATIVE_UINT_TYPE bytes)
Give the sequence representation a memory buffer.
Definition: Sequence.cpp:76
Fw::ExternalSerializeBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: Serializable.cpp:720