F´ Flight Software - C/C++ Documentation
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 
17  : m_component(component), m_events(*this), m_allocatorId(0) {}
18 
20 
22  : m_fileSize(0), m_numRecords(0), m_timeBase(TimeBase::TB_DONT_CARE), m_timeContext(FW_CONTEXT_DONT_CARE) {}
23 
25  Fw::Time validTime = component.getTime();
26  Events& events = component.m_sequence->m_events;
27  // Time base
28  const TimeBase validTimeBase = validTime.getTimeBase();
29  if ((this->m_timeBase != validTimeBase) and (this->m_timeBase != TimeBase::TB_DONT_CARE)) {
30  events.timeBaseMismatch(validTimeBase, this->m_timeBase);
31  return false;
32  }
33  // Time context
34  const FwTimeContextStoreType validContext = validTime.getContext();
35  if ((this->m_timeContext != validContext) and (this->m_timeContext != FW_CONTEXT_DONT_CARE)) {
36  events.timeContextMismatch(validContext, this->m_timeContext);
37  return false;
38  }
39  // Canonicalize time
40  this->m_timeBase = validTimeBase;
41  this->m_timeContext = validContext;
42  return true;
43 }
44 
46  Fw::MemAllocator& allocator,
47  FwSizeType bytes) {
48  // has to be at least as big as a header
50  bool recoverable;
51  this->m_allocatorId = identifier;
52  this->m_buffer.setExtBuffer(static_cast<U8*>(allocator.allocate(identifier, bytes, recoverable)), bytes);
53 }
54 
56  allocator.deallocate(this->m_allocatorId, this->m_buffer.getBuffAddr());
57  this->m_buffer.clear();
58 }
59 
61  return this->m_header;
62 }
63 
65  this->m_fileName = fileName;
66  this->m_logFileName = fileName;
67  this->m_stringFileName = fileName;
68 }
69 
71  return this->m_fileName;
72 }
73 
75  return this->m_logFileName;
76 }
77 
79  return this->m_stringFileName;
80 }
81 
82 } // namespace Svc
void clear()
clear external buffer
PlatformSizeType FwSizeType
I32 FwEnumStoreType
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable)=0
Allocate memory.
Don&#39;t care value for sequences. If FwTimeBaseStoreType is changed, value should be changed (Required)...
TimeBase getTimeBase() const
Definition: Time.cpp:94
U8 FwTimeContextStoreType
The type used to serialize a time context value.
void allocateBuffer(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType bytes)
Give the sequence representation a memory buffer.
Definition: Sequence.cpp:45
void setFileName(const Fw::StringBase &fileName)
Set the file name. Also sets the log file name.
Definition: Sequence.cpp:64
#define FW_CONTEXT_DONT_CARE
Don&#39;t care value for time contexts in sequences.
Definition: FpConfig.h:24
void timeContextMismatch(const FwTimeContextStoreType currTimeContext, const FwTimeContextStoreType seqTimeContext)
Time context mismatch.
Definition: Events.cpp:76
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
Fw::CmdStringArg m_fileName
The sequence file name.
Fw::LogStringArg m_logFileName
Copy of file name for events.
FwEnumStoreType m_allocatorId
The allocator ID.
void timeBaseMismatch(const TimeBase currTimeBase, const TimeBase seqTimeBase)
Time base mismatch.
Definition: Events.cpp:68
void deallocateBuffer(Fw::MemAllocator &allocator)
Deallocate the buffer.
Definition: Sequence.cpp:55
Sequence(CmdSequencerComponentImpl &component)
Construct a Sequence object.
Definition: Sequence.cpp:16
void setExtBuffer(U8 *buffPtr, Serializable::SizeType size)
FwTimeContextStoreType getContext() const
Definition: Time.cpp:98
virtual ~Sequence()
Destroy a Sequence object.
Definition: Sequence.cpp:19
RateGroupDivider component implementation.
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Deallocate memory.
Define enumeration for Time base types.
bool validateTime(CmdSequencerComponentImpl &component)
Definition: Sequence.cpp:24
Fw::String m_stringFileName
Copy of file name for ports.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
const Header & getHeader() const
Get the sequence header.
Definition: Sequence.cpp:60
U8 * getBuffAddr()
gets buffer address for data filling