| Line | Branch | Exec | Source |
|---|---|---|---|
| 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> | ||
| 12 | #include <Svc/CmdSequencer/CmdSequencerImpl.hpp> | ||
| 13 | |||
| 14 | namespace Svc { | ||
| 15 | |||
| 16 | 148 | CmdSequencerComponentImpl::Sequence ::Sequence(CmdSequencerComponentImpl& component) | |
| 17 |
4/4✓ Branch 19 taken 148 times.
✓ Branch 25 taken 148 times.
✓ Branch 31 taken 148 times.
✓ Branch 41 taken 148 times.
|
148 | : m_component(component), m_events(*this), m_allocatorId(0) {} |
| 18 | |||
| 19 | 296 | CmdSequencerComponentImpl::Sequence ::~Sequence() {} | |
| 20 | |||
| 21 | 148 | CmdSequencerComponentImpl::Sequence::Header ::Header() | |
| 22 | 148 | : m_fileSize(0), m_numRecords(0), m_timeBase(TimeBase::TB_DONT_CARE), m_timeContext(FW_CONTEXT_DONT_CARE) {} | |
| 23 | |||
| 24 | 95 | bool CmdSequencerComponentImpl::Sequence::Header ::validateTime(CmdSequencerComponentImpl& component) { | |
| 25 |
1/1✓ Branch 3 taken 95 times.
|
95 | Fw::Time validTime = component.getTime(); |
| 26 | 95 | Events& events = component.m_sequence->m_events; | |
| 27 | // Time base | ||
| 28 |
1/1✓ Branch 2 taken 95 times.
|
95 | const TimeBase validTimeBase = validTime.getTimeBase(); |
| 29 |
6/6✓ Branch 8 taken 29 times.
✓ Branch 9 taken 66 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 28 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 94 times.
|
95 | if ((this->m_timeBase != validTimeBase) and (this->m_timeBase != TimeBase::TB_DONT_CARE)) { |
| 30 |
3/3✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | events.timeBaseMismatch(validTimeBase, this->m_timeBase); |
| 31 | 1 | return false; | |
| 32 | } | ||
| 33 | // Time context | ||
| 34 |
1/1✓ Branch 2 taken 94 times.
|
94 | const FwTimeContextStoreType validContext = validTime.getContext(); |
| 35 |
4/4✓ Branch 2 taken 29 times.
✓ Branch 3 taken 65 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 28 times.
|
94 | if ((this->m_timeContext != validContext) and (this->m_timeContext != FW_CONTEXT_DONT_CARE)) { |
| 36 |
1/1✓ Branch 4 taken 1 times.
|
1 | events.timeContextMismatch(validContext, this->m_timeContext); |
| 37 | 1 | return false; | |
| 38 | } | ||
| 39 | // Canonicalize time | ||
| 40 |
1/1✓ Branch 6 taken 93 times.
|
93 | this->m_timeBase = validTimeBase; |
| 41 | 93 | this->m_timeContext = validContext; | |
| 42 | 93 | return true; | |
| 43 | 95 | } | |
| 44 | |||
| 45 | 74 | void CmdSequencerComponentImpl::Sequence ::allocateBuffer(FwEnumStoreType identifier, | |
| 46 | Fw::MemAllocator& allocator, | ||
| 47 | FwSizeType bytes) { | ||
| 48 | // has to be at least as big as a header | ||
| 49 | 74 | FW_ASSERT(bytes >= Sequence::Header::SERIALIZED_SIZE); | |
| 50 | 74 | bool recoverable; | |
| 51 | 74 | this->m_allocatorId = identifier; | |
| 52 |
2/2✓ Branch 11 taken 74 times.
✓ Branch 14 taken 74 times.
|
74 | this->m_buffer.setExtBuffer(static_cast<U8*>(allocator.allocate(identifier, bytes, recoverable)), bytes); |
| 53 | 74 | } | |
| 54 | |||
| 55 | 74 | void CmdSequencerComponentImpl::Sequence ::deallocateBuffer(Fw::MemAllocator& allocator) { | |
| 56 | 74 | allocator.deallocate(this->m_allocatorId, this->m_buffer.getBuffAddr()); | |
| 57 | 74 | this->m_buffer.clear(); | |
| 58 | 74 | } | |
| 59 | |||
| 60 | 136 | const CmdSequencerComponentImpl::Sequence::Header& CmdSequencerComponentImpl::Sequence ::getHeader() const { | |
| 61 | 136 | return this->m_header; | |
| 62 | } | ||
| 63 | |||
| 64 | 190 | void CmdSequencerComponentImpl::Sequence ::setFileName(const Fw::ConstStringBase& fileName) { | |
| 65 | 190 | this->m_fileName = fileName; | |
| 66 | 190 | this->m_logFileName = fileName; | |
| 67 | 190 | this->m_stringFileName = fileName; | |
| 68 | 190 | } | |
| 69 | |||
| 70 | ✗ | Fw::CmdStringArg& CmdSequencerComponentImpl::Sequence ::getFileName() { | |
| 71 | ✗ | return this->m_fileName; | |
| 72 | } | ||
| 73 | |||
| 74 | 343 | Fw::LogStringArg& CmdSequencerComponentImpl::Sequence ::getLogFileName() { | |
| 75 | 343 | return this->m_logFileName; | |
| 76 | } | ||
| 77 | |||
| 78 | 37 | Fw::String& CmdSequencerComponentImpl::Sequence ::getStringFileName() { | |
| 79 | 37 | return this->m_stringFileName; | |
| 80 | } | ||
| 81 | |||
| 82 | } // namespace Svc | ||
| 83 |