mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
* Pull in framework changes from data-products branch * Pull in changes to DpManager from data-products branch * Pull in DpWriter from data-products branch * Fix spelling * Revise FileNameString * Fix warnings in CI * Fix static analysis warnings * Fix static analysis warnings * Revise formatting and comments * Revise banner comments * Revise FileNameString per PR comment * Revise path names in config headers If a header H.hpp exists in the F Prime source base, then is dangerous. Because [project root] and [fprime root] are both in the list of include paths, it's not clear whether this means "include [project root]/config/H.hpp" or "include [fprime root]/config/H.hpp." On the other hand, or has no such ambiguity, because only one of [project root]/config and [fprime root]/config is in the list of include paths. * Revise path names in config headers If a header H.hpp exists in the F Prime source base, then `#include "config/H.hpp"` is dangerous. Because [project root] and [fprime root] are both in the list of include paths, it's not clear whether this means "include [project root]/config/H.hpp" or "include [fprime root]/config/H.hpp." On the other hand, include <config/H.hpp> or `#include "config/H.hpp"` has no such ambiguity, because only one of [project root]/config and [fprime root]/config is in the list of include paths.
128 lines
3.9 KiB
C++
128 lines
3.9 KiB
C++
// ======================================================================
|
|
// \title AbstractState.hpp
|
|
// \author Rob Bocchino
|
|
// \brief Header file for abstract state
|
|
//
|
|
// \copyright
|
|
// Copyright (C) 2023 California Institute of Technology.
|
|
// ALL RIGHTS RESERVED. United States Government sponsorship
|
|
// acknowledged.
|
|
// ======================================================================
|
|
|
|
#ifndef Svc_AbstractState_HPP
|
|
#define Svc_AbstractState_HPP
|
|
|
|
#include <cstring>
|
|
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "STest/Pick/Pick.hpp"
|
|
#include "Svc/DpManager/DpManager.hpp"
|
|
#include "TestUtils/OnChangeChannel.hpp"
|
|
#include "TestUtils/Option.hpp"
|
|
|
|
namespace Svc {
|
|
|
|
class AbstractState {
|
|
public:
|
|
// ----------------------------------------------------------------------
|
|
// Constants
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The minimum buffer size
|
|
static constexpr FwSizeType MIN_BUFFER_SIZE = 1;
|
|
|
|
//! The maximum buffer size
|
|
static constexpr FwSizeType MAX_BUFFER_SIZE = 1024;
|
|
|
|
public:
|
|
// ----------------------------------------------------------------------
|
|
// Types
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The type of the buffer get status
|
|
enum class BufferGetStatus {
|
|
//! Valid
|
|
VALID,
|
|
//! Invalid
|
|
INVALID
|
|
};
|
|
|
|
public:
|
|
// ----------------------------------------------------------------------
|
|
// Constructors
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Construct an AbstractState object
|
|
AbstractState()
|
|
: bufferSizeOpt(),
|
|
bufferGetStatus(BufferGetStatus::VALID),
|
|
NumSuccessfulAllocations(0),
|
|
NumFailedAllocations(0),
|
|
NumDataProducts(0),
|
|
NumBytes(0),
|
|
bufferGetOutPortNumOpt(),
|
|
productResponseOutPortNumOpt(),
|
|
productSendOutPortNumOpt(),
|
|
bufferAllocationFailedEventCount(0) {}
|
|
|
|
public:
|
|
// ----------------------------------------------------------------------
|
|
// Accessor methods
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Get the buffer size
|
|
FwSizeType getBufferSize() const {
|
|
return this->bufferSizeOpt.getOrElse(STest::Pick::lowerUpper(MIN_BUFFER_SIZE, MAX_BUFFER_SIZE));
|
|
}
|
|
|
|
//! Set the buffer size
|
|
void setBufferSize(FwSizeType bufferSize) { this->bufferSizeOpt.set(bufferSize); }
|
|
|
|
private:
|
|
// ----------------------------------------------------------------------
|
|
// Private state variables
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The current buffer size
|
|
TestUtils::Option<FwSizeType> bufferSizeOpt;
|
|
|
|
public:
|
|
// ----------------------------------------------------------------------
|
|
// Public state variables
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The buffer get status
|
|
BufferGetStatus bufferGetStatus;
|
|
|
|
//! The number of successful buffer allocations
|
|
TestUtils::OnChangeChannel<U32> NumSuccessfulAllocations;
|
|
|
|
//! The number of failed buffer allocations
|
|
TestUtils::OnChangeChannel<U32> NumFailedAllocations;
|
|
|
|
//! The number of data products handled
|
|
TestUtils::OnChangeChannel<U32> NumDataProducts;
|
|
|
|
//! The number of bytes handled
|
|
TestUtils::OnChangeChannel<U64> NumBytes;
|
|
|
|
//! Data for buffers
|
|
U8 bufferData[MAX_BUFFER_SIZE];
|
|
|
|
//! The last port number used for bufferGetOut
|
|
TestUtils::Option<FwIndexType> bufferGetOutPortNumOpt;
|
|
|
|
//! The last port number used for productResponseOut
|
|
TestUtils::Option<FwIndexType> productResponseOutPortNumOpt;
|
|
|
|
//! The last port number used for productSendOut
|
|
TestUtils::Option<FwIndexType> productSendOutPortNumOpt;
|
|
|
|
//! The number of buffer allocation failed events since the last throttle clear
|
|
FwSizeType bufferAllocationFailedEventCount;
|
|
};
|
|
|
|
} // namespace Svc
|
|
|
|
#endif
|