F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
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
7 // Copyright (C) 2009-2018 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #include <Fw/Types/Assert.hpp>
15 
16 namespace Svc {
17 
20  m_component(component),
21  m_events(*this),
22  m_allocatorId(0)
23  {
24 
25  };
26 
29  {
30 
31  }
32 
34  Header(void) :
35  m_fileSize(0),
36  m_numRecords(0),
37  m_timeBase(TB_DONT_CARE),
38  m_timeContext(FW_CONTEXT_DONT_CARE)
39  {
40 
41  }
42 
45  {
46  Fw::Time validTime = component.getTime();
47  Events& events = component.m_sequence->m_events;
48  // Time base
49  const TimeBase validTimeBase = validTime.getTimeBase();
50  if (
51  (this->m_timeBase != validTimeBase) and
52  (this->m_timeBase != TB_DONT_CARE)
53  ) {
54  events.timeBaseMismatch(
55  validTimeBase,
56  this->m_timeBase
57  );
58  return false;
59  }
60  // Time context
61  const FwTimeContextStoreType validContext = validTime.getContext();
62  if (
63  (this->m_timeContext != validContext) and
64  (this->m_timeContext != FW_CONTEXT_DONT_CARE)
65  ) {
66  events.timeContextMismatch(
67  validContext,
68  this->m_timeContext
69  );
70  return false;
71  }
72  // Canonicalize time
73  this->m_timeBase = validTimeBase;
74  this->m_timeContext = validContext;
75  return true;
76  }
77 
80  const NATIVE_INT_TYPE identifier,
81  Fw::MemAllocator& allocator,
82  const NATIVE_UINT_TYPE bytes
83  )
84  {
85  // has to be at least as big as a header
87  bool recoverable; // don't care, since sequencer buffers don't need to survive reboot
88  this->m_allocatorId = identifier;
89  NATIVE_UINT_TYPE actualSize = bytes; // set size to requested size
90 
91  U8* mem = static_cast<U8*>(allocator.allocate(identifier,actualSize,recoverable));
92  FW_ASSERT(mem);
93  this->m_buffer.setExtBuffer(
94  mem,
95  actualSize
96  );
97  }
98 
101  {
102  allocator.deallocate(
103  this->m_allocatorId,
104  this->m_buffer.getBuffAddr()
105  );
106  this->m_buffer.clear();
107  }
108 
111  getHeader(void) const
112  {
113  return this->m_header;
114  }
115 
118  {
119  this->m_fileName = fileName;
120  this->m_logFileName = fileName;
121  }
122 
125  {
126  return this->m_fileName;
127  }
128 
131  {
132  return this->m_logFileName;
133  }
134 
135 }
136 
Svc::CmdSequencerComponentImpl::Sequence::Sequence
Sequence(CmdSequencerComponentImpl &component)
Construct a Sequence object.
Definition: Sequence.cpp:19
Svc::CmdSequencerComponentImpl::Sequence::m_allocatorId
NATIVE_INT_TYPE m_allocatorId
The allocator ID.
Definition: CmdSequencerImpl.hpp:311
Svc::CmdSequencerComponentImpl::Sequence::deallocateBuffer
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
Definition: Sequence.cpp:100
Svc::CmdSequencerComponentImpl::Sequence::Header::validateTime
bool validateTime(CmdSequencerComponentImpl &component)
Definition: Sequence.cpp:44
Svc::CmdSequencerComponentImpl::Sequence::Header::SERIALIZED_SIZE
@ SERIALIZED_SIZE
Serialized size of header.
Definition: CmdSequencerImpl.hpp:168
Fw::Time
Definition: Time.hpp:10
Svc::CmdSequencerComponentImpl::Sequence::m_header
Header m_header
The sequence header.
Definition: CmdSequencerImpl.hpp:314
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:337
Svc::CmdSequencerComponentImpl::Sequence::m_fileName
Fw::CmdStringArg m_fileName
The sequence file name.
Definition: CmdSequencerImpl.hpp:302
Svc::CmdSequencerComponentImpl::Sequence::~Sequence
virtual ~Sequence(void)
Destroy a Sequence object.
Definition: Sequence.cpp:28
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:323
Fw::CmdStringArg
Definition: CmdString.hpp:11
FwTimeContextStoreType
#define FwTimeContextStoreType
Storage conversion for time context in scripts/ground interface.
Definition: FpConfig.hpp:336
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:305
TB_DONT_CARE
@ TB_DONT_CARE
Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed.
Definition: FpConfig.hpp:327
Svc::CmdSequencerComponentImpl::Sequence::Events::timeContextMismatch
void timeContextMismatch(const FwTimeContextStoreType currTimeContext, const FwTimeContextStoreType seqTimeContext)
Time context mismatch.
Definition: Events.cpp:164
Svc::CmdSequencerComponentImpl::Sequence::getFileName
Fw::CmdStringArg & getFileName(void)
Definition: Sequence.cpp:124
Svc::CmdSequencerComponentImpl::Sequence::allocateBuffer
void allocateBuffer(const NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, const NATIVE_UINT_TYPE bytes)
Give the sequence representation a memory buffer.
Definition: Sequence.cpp:79
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
Svc::CmdSequencerComponentImpl::Sequence::Events::timeBaseMismatch
void timeBaseMismatch(const FwTimeBaseStoreType currTimeBase, const FwTimeBaseStoreType seqTimeBase)
Time base mismatch.
Definition: Events.cpp:151
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:58
Svc::CmdSequencerComponentImpl::Sequence::setFileName
void setFileName(const Fw::CmdStringArg &fileName)
Set the file name. Also sets the log file name.
Definition: Sequence.cpp:117
Svc::CmdSequencerComponentImpl::Sequence::getHeader
const Header & getHeader(void) const
Get the sequence header.
Definition: Sequence.cpp:111
Fw::MemAllocator
Definition: MemAllocator.hpp:44
Svc::CmdSequencerComponentImpl::Sequence::Header
A sequence header.
Definition: CmdSequencerImpl.hpp:162
Svc::CmdSequencerComponentImpl::Sequence::Header::Header
Header(void)
Construct a Header object.
Definition: Sequence.cpp:34
Svc::CmdSequencerComponentImpl::Sequence::m_events
Events m_events
Event reporting.
Definition: CmdSequencerImpl.hpp:299
Svc
Definition: ActiveRateGroupImplCfg.hpp:18
Svc::CmdSequencerComponentImpl::Sequence::getLogFileName
Fw::LogStringArg & getLogFileName(void)
Definition: Sequence.cpp:130
Svc::CmdSequencerComponentImpl
Definition: CmdSequencerImpl.hpp:24
CmdSequencerImpl.hpp
Svc::CmdSequencerComponentImpl::Sequence::m_buffer
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
Definition: CmdSequencerImpl.hpp:308
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Fw::ExternalSerializeBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: Serializable.cpp:720