fprime/Svc/CmdSequencer/Sequence.cpp
M Starch ec08d43dd3
Removes NATIVE_INT_TYPE, NATIVE_UINT_TYPE, and POINTER_CAST from Fw (#3286)
* NATIVE_INT_TYPE use in toString

* NATIVE_INT_TYPE use in SimpleObjRegistry

* NATIVE_INT_TYPE use in Asserts

* NATIVE_INT_TYPE use in Fw/Comp

* NATIVE_INT_TYPE use in getCapacity

* NATIVE_INT_TYPE use in getEntries

* NATIVE_INT_TYPE use in size/length

* NATIVE_INT_TYPE use in FILE_NAME_ARG

* NATIVE_INT_TYPE use in Fw (misc)

* NATIVE_INT_TYPE use in identifier

* NATIVE_INT_TYPE use in Fw (misc II)

* POINTER_CAST in Buffer

* POINTER_CAST in Serializable

* sp

* Removing no longer used DefaultTypes.hpp

* Fixes to accomidate Fw refactor

* Unit-test and CI fixes

* Fixing review comments - pt 1
2025-03-04 14:42:48 -08:00

138 lines
3.6 KiB
C++

// ======================================================================
// \title Sequence.cpp
// \author Bocchino/Canham
// \brief Implementation file for CmdSequencer::Sequence
//
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
#include <Fw/Types/Assert.hpp>
#include <Svc/CmdSequencer/CmdSequencerImpl.hpp>
namespace Svc {
CmdSequencerComponentImpl::Sequence ::
Sequence(CmdSequencerComponentImpl& component) :
m_component(component),
m_events(*this),
m_allocatorId(0)
{
}
CmdSequencerComponentImpl::Sequence ::
~Sequence()
{
}
CmdSequencerComponentImpl::Sequence::Header ::
Header() :
m_fileSize(0),
m_numRecords(0),
m_timeBase(TB_DONT_CARE),
m_timeContext(FW_CONTEXT_DONT_CARE)
{
}
bool CmdSequencerComponentImpl::Sequence::Header ::
validateTime(CmdSequencerComponentImpl& component)
{
Fw::Time validTime = component.getTime();
Events& events = component.m_sequence->m_events;
// Time base
const TimeBase validTimeBase = validTime.getTimeBase();
if (
(this->m_timeBase != validTimeBase) and
(this->m_timeBase != TB_DONT_CARE)
) {
events.timeBaseMismatch(
validTimeBase,
this->m_timeBase
);
return false;
}
// Time context
const FwTimeContextStoreType validContext = validTime.getContext();
if (
(this->m_timeContext != validContext) and
(this->m_timeContext != FW_CONTEXT_DONT_CARE)
) {
events.timeContextMismatch(
validContext,
this->m_timeContext
);
return false;
}
// Canonicalize time
this->m_timeBase = validTimeBase;
this->m_timeContext = validContext;
return true;
}
void CmdSequencerComponentImpl::Sequence ::
allocateBuffer(
FwEnumStoreType identifier,
Fw::MemAllocator& allocator,
FwSizeType bytes
)
{
// has to be at least as big as a header
FW_ASSERT(bytes >= Sequence::Header::SERIALIZED_SIZE);
bool recoverable;
this->m_allocatorId = identifier;
this->m_buffer.setExtBuffer(
static_cast<U8*>(allocator.allocate(identifier,bytes,recoverable)),
bytes
);
}
void CmdSequencerComponentImpl::Sequence ::
deallocateBuffer(Fw::MemAllocator& allocator)
{
allocator.deallocate(
this->m_allocatorId,
this->m_buffer.getBuffAddr()
);
this->m_buffer.clear();
}
const CmdSequencerComponentImpl::Sequence::Header&
CmdSequencerComponentImpl::Sequence ::
getHeader() const
{
return this->m_header;
}
void CmdSequencerComponentImpl::Sequence ::
setFileName(const Fw::StringBase& fileName)
{
this->m_fileName = fileName;
this->m_logFileName = fileName;
this->m_stringFileName = fileName;
}
Fw::CmdStringArg& CmdSequencerComponentImpl::Sequence ::
getFileName()
{
return this->m_fileName;
}
Fw::LogStringArg& CmdSequencerComponentImpl::Sequence ::
getLogFileName()
{
return this->m_logFileName;
}
Fw::String& CmdSequencerComponentImpl::Sequence ::
getStringFileName()
{
return this->m_stringFileName;
}
}