F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
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 
11 #include <Fw/Types/Assert.hpp>
13 
14 namespace Svc {
15 
18  m_component(component),
19  m_events(*this),
20  m_allocatorId(0)
21  {
22 
23  };
24 
27  {
28 
29  }
30 
33  m_fileSize(0),
34  m_numRecords(0),
35  m_timeBase(TB_DONT_CARE),
36  m_timeContext(FW_CONTEXT_DONT_CARE)
37  {
38 
39  }
40 
43  {
44  Fw::Time validTime = component.getTime();
45  Events& events = component.m_sequence->m_events;
46  // Time base
47  const TimeBase validTimeBase = validTime.getTimeBase();
48  if (
49  (this->m_timeBase != validTimeBase) and
50  (this->m_timeBase != TB_DONT_CARE)
51  ) {
52  events.timeBaseMismatch(
53  validTimeBase,
54  this->m_timeBase
55  );
56  return false;
57  }
58  // Time context
59  const FwTimeContextStoreType validContext = validTime.getContext();
60  if (
61  (this->m_timeContext != validContext) and
62  (this->m_timeContext != FW_CONTEXT_DONT_CARE)
63  ) {
64  events.timeContextMismatch(
65  validContext,
66  this->m_timeContext
67  );
68  return false;
69  }
70  // Canonicalize time
71  this->m_timeBase = validTimeBase;
72  this->m_timeContext = validContext;
73  return true;
74  }
75 
78  NATIVE_INT_TYPE identifier,
79  Fw::MemAllocator& allocator,
80  NATIVE_UINT_TYPE bytes
81  )
82  {
83  // has to be at least as big as a header
85  bool recoverable;
86  this->m_allocatorId = identifier;
87  this->m_buffer.setExtBuffer(
88  static_cast<U8*>(allocator.allocate(identifier,bytes,recoverable)),
89  bytes
90  );
91  }
92 
95  {
96  allocator.deallocate(
97  this->m_allocatorId,
98  this->m_buffer.getBuffAddr()
99  );
100  this->m_buffer.clear();
101  }
102 
105  getHeader() const
106  {
107  return this->m_header;
108  }
109 
112  {
113  this->m_fileName = fileName;
114  this->m_logFileName = fileName;
115  }
116 
119  {
120  return this->m_fileName;
121  }
122 
125  {
126  return this->m_logFileName;
127  }
128 
129 }
130 
Svc::CmdSequencerComponentImpl::Sequence::Sequence
Sequence(CmdSequencerComponentImpl &component)
Construct a Sequence object.
Definition: Sequence.cpp:17
Svc::CmdSequencerComponentImpl::Sequence::m_allocatorId
NATIVE_INT_TYPE m_allocatorId
The allocator ID.
Definition: CmdSequencerImpl.hpp:284
Svc::CmdSequencerComponentImpl::Sequence::deallocateBuffer
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
Definition: Sequence.cpp:94
FwTimeContextStoreType
#define FwTimeContextStoreType
Storage conversion for time context in scripts/ground interface.
Definition: FpConfig.hpp:328
Svc::CmdSequencerComponentImpl::Sequence::Header::validateTime
bool validateTime(CmdSequencerComponentImpl &component)
Definition: Sequence.cpp:42
Svc::CmdSequencerComponentImpl::Sequence::Header::SERIALIZED_SIZE
@ SERIALIZED_SIZE
Serialized size of header.
Definition: CmdSequencerImpl.hpp:141
Fw::Time
Definition: Time.hpp:10
Svc::CmdSequencerComponentImpl::Sequence::m_header
Header m_header
The sequence header.
Definition: CmdSequencerImpl.hpp:287
Svc::CmdSequencerComponentImpl::Sequence::~Sequence
virtual ~Sequence()
Destroy a Sequence object.
Definition: Sequence.cpp:26
Svc::CmdSequencerComponentImpl::Sequence::Events::timeBaseMismatch
void timeBaseMismatch(const TimeBase currTimeBase, const TimeBase seqTimeBase)
Time base mismatch.
Definition: Events.cpp:106
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:73
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:28
Svc::CmdSequencerComponentImpl::Sequence::m_fileName
Fw::CmdStringArg m_fileName
The sequence file name.
Definition: CmdSequencerImpl.hpp:275
TimeBase
TimeBase
Definition: FpConfig.hpp:315
Fw::MemAllocator::allocate
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
Fw::CmdStringArg
Definition: CmdString.hpp:11
Svc::CmdSequencerComponentImpl::Sequence::getFileName
Fw::CmdStringArg & getFileName()
Definition: Sequence.cpp:118
Svc::CmdSequencerComponentImpl::Sequence::getLogFileName
Fw::LogStringArg & getLogFileName()
Definition: Sequence.cpp:124
Fw::ExternalSerializeBuffer::clear
void clear(void)
clear external buffer
Definition: Serializable.cpp:718
Svc::CmdSequencerComponentImpl::Sequence::m_logFileName
Fw::LogStringArg m_logFileName
Copy of file name for events.
Definition: CmdSequencerImpl.hpp:278
TB_DONT_CARE
@ TB_DONT_CARE
Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed.
Definition: FpConfig.hpp:319
Svc::CmdSequencerComponentImpl::Sequence::getHeader
const Header & getHeader() const
Get the sequence header.
Definition: Sequence.cpp:105
Fw::Time::getContext
FwTimeContextStoreType getContext() const
Definition: Time.cpp:147
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Svc::CmdSequencerComponentImpl::Sequence::Events::timeContextMismatch
void timeContextMismatch(const FwTimeContextStoreType currTimeContext, const FwTimeContextStoreType seqTimeContext)
Time context mismatch.
Definition: Events.cpp:119
Fw::ExternalSerializeBuffer::setExtBuffer
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
Definition: Serializable.cpp:712
Svc::CmdSequencerComponentImpl::Sequence::Header::Header
Header()
Construct a Header object.
Definition: Sequence.cpp:32
Svc::CmdSequencerComponentImpl::Sequence::Events
Sequence event reporting.
Definition: CmdSequencerImpl.hpp:56
Svc::CmdSequencerComponentImpl::Sequence::setFileName
void setFileName(const Fw::CmdStringArg &fileName)
Set the file name. Also sets the log file name.
Definition: Sequence.cpp:111
Fw::MemAllocator
Definition: MemAllocator.hpp:44
Svc::CmdSequencerComponentImpl::Sequence::Header
A sequence header.
Definition: CmdSequencerImpl.hpp:135
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::Time::getTimeBase
TimeBase getTimeBase() const
Definition: Time.cpp:143
Svc::CmdSequencerComponentImpl::Sequence::m_events
Events m_events
Event reporting.
Definition: CmdSequencerImpl.hpp:272
Svc
Definition: ActiveRateGroupCfg.hpp:18
Fw::ExternalSerializeBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: Serializable.cpp:727
FW_CONTEXT_DONT_CARE
#define FW_CONTEXT_DONT_CARE
Don't care value for time contexts in sequences.
Definition: FpConfig.hpp:329
Svc::CmdSequencerComponentImpl
Definition: CmdSequencerImpl.hpp:22
CmdSequencerImpl.hpp
Svc::CmdSequencerComponentImpl::Sequence::m_buffer
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
Definition: CmdSequencerImpl.hpp:281
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:77