F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
14namespace Svc {
15
16 CmdSequencerComponentImpl::Sequence ::
17 Sequence(CmdSequencerComponentImpl& component) :
18 m_component(component),
19 m_events(*this),
20 m_allocatorId(0)
21 {
22
23 };
24
25 CmdSequencerComponentImpl::Sequence ::
26 ~Sequence()
27 {
28
29 }
30
31 CmdSequencerComponentImpl::Sequence::Header ::
32 Header() :
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
41 bool CmdSequencerComponentImpl::Sequence::Header ::
42 validateTime(CmdSequencerComponentImpl& component)
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 ) {
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
76 void CmdSequencerComponentImpl::Sequence ::
77 allocateBuffer(
78 NATIVE_INT_TYPE identifier,
79 Fw::MemAllocator& allocator,
81 )
82 {
83 // has to be at least as big as a header
85 bool recoverable;
86 this->m_allocatorId = identifier;
88 static_cast<U8*>(allocator.allocate(identifier,bytes,recoverable)),
89 bytes
90 );
91 }
92
93 void CmdSequencerComponentImpl::Sequence ::
94 deallocateBuffer(Fw::MemAllocator& allocator)
95 {
96 allocator.deallocate(
97 this->m_allocatorId,
98 this->m_buffer.getBuffAddr()
99 );
100 this->m_buffer.clear();
101 }
102
104 CmdSequencerComponentImpl::Sequence ::
105 getHeader() const
106 {
107 return this->m_header;
108 }
109
110 void CmdSequencerComponentImpl::Sequence ::
111 setFileName(const Fw::CmdStringArg& fileName)
112 {
113 this->m_fileName = fileName;
114 this->m_logFileName = fileName;
115 }
116
117 Fw::CmdStringArg& CmdSequencerComponentImpl::Sequence ::
118 getFileName()
119 {
120 return this->m_fileName;
121 }
122
123 Fw::LogStringArg& CmdSequencerComponentImpl::Sequence ::
124 getLogFileName()
125 {
126 return this->m_logFileName;
127 }
128
129}
130
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
TimeBase
Definition FpConfig.h:38
@ TB_DONT_CARE
Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed.
Definition FpConfig.h:42
#define FW_CONTEXT_DONT_CARE
Don't care value for time contexts in sequences.
Definition FpConfig.h:45
U8 FwTimeContextStoreType
Definition FpConfig.h:50
U8 * getBuffAddr()
gets buffer address for data filling
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
void clear()
clear external buffer
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
FwTimeContextStoreType getContext() const
Definition Time.cpp:147
TimeBase getTimeBase() const
Definition Time.cpp:143
void timeBaseMismatch(const TimeBase currTimeBase, const TimeBase seqTimeBase)
Time base mismatch.
Definition Events.cpp:106
void timeContextMismatch(const FwTimeContextStoreType currTimeContext, const FwTimeContextStoreType seqTimeContext)
Time context mismatch.
Definition Events.cpp:119
Fw::LogStringArg m_logFileName
Copy of file name for events.
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
NATIVE_INT_TYPE m_allocatorId
The allocator ID.
Fw::CmdStringArg m_fileName
The sequence file name.