Brian Campuzano 2542b604b4
Extern params (#3608)
* Initial prototype of external parameter types

* Change external parameter interface to be an abstract base class

* Renamed external parameter delegate

* Sync parameter delegate interfaces with GNC

* Finshed interface sync with GNC

* Fixed missing include

* Added external parameter delgate documentation

* Added parameter base ID to the parameter external delegate interface

* Added external parameters to FPP component UTs

* Add external parameter UTs and got them to build

* Completed external paramter UTs

* Updated parameter delegate to accept a serial buffer base instead of a parameter buffer

* Renamed to fix spelling

* Bumped Fpp version

* Added external parameters documentation to the user's guide

* Fixed config include path

* Updated spelling expect file for external parameter names

* Revise FppTest

Add static casts in assertions to avoid conversion warnings

* Bumped FPP version to the 10th alpha release of 3.0.0

* Revise FppTest

Sort file lists

---------

Co-authored-by: Rob Bocchino <bocchino@jpl.nasa.gov>
2025-05-15 10:09:57 -07:00

217 lines
7.2 KiB
C++

// ======================================================================
// \title PassiveTest/test/ut/Tester.cpp
// \author tiffany
// \brief cpp file for PassiveTest test harness implementation class
// ======================================================================
#include "STest/Pick/Pick.hpp"
#include "Tester.hpp"
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
Tester ::Tester()
: PassiveTestGTestBase("Tester", Tester::MAX_HISTORY_SIZE),
component("PassiveTest"),
primitiveBuf(primitiveData, sizeof(primitiveData)),
stringBuf(stringData, sizeof(stringData)),
enumBuf(enumData, sizeof(enumData)),
arrayBuf(arrayData, sizeof(arrayData)),
structBuf(structData, sizeof(structData)),
serialBuf(serialData, sizeof(serialData)),
time(STest::Pick::any(), STest::Pick::any()) {
this->initComponents();
this->connectPorts();
this->component.registerExternalParameters(&this->paramTesterDelegate);
}
Tester ::~Tester() {}
void Tester ::initComponents() {
this->init();
this->component.init(Tester::TEST_INSTANCE_ID);
}
Fw::ParamValid Tester ::from_prmGetIn_handler(const FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {
val.resetSer();
Fw::SerializeStatus status;
U32 id_base = component.getIdBase();
FW_ASSERT(id >= id_base);
switch (id - id_base) {
case PassiveTestComponentBase::PARAMID_PARAMBOOL:
status = val.serialize(boolPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMU32:
status = val.serialize(u32Prm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMSTRING:
status = val.serialize(stringPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMENUM:
status = val.serialize(enumPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMARRAY:
status = val.serialize(arrayPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMSTRUCT:
status = val.serialize(structPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
}
this->pushFromPortEntry_prmGetIn(id, val);
return prmValid;
}
void Tester ::from_prmSetIn_handler(const FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {
Fw::SerializeStatus status;
U32 id_base = component.getIdBase();
FW_ASSERT(id >= id_base);
switch (id - id_base) {
case PassiveTestComponentBase::PARAMID_PARAMBOOL:
status = val.deserialize(boolPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMU32:
status = val.deserialize(u32Prm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMSTRING:
status = val.deserialize(stringPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMENUM:
status = val.deserialize(enumPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMARRAY:
status = val.deserialize(arrayPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
case PassiveTestComponentBase::PARAMID_PARAMSTRUCT:
status = val.deserialize(structPrm.args.val);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
break;
}
this->pushFromPortEntry_prmSetIn(id, val);
}
// ----------------------------------------------------------------------
// Unit test implementation of external parameter delegate serialization/deserialization
// ----------------------------------------------------------------------
Fw::SerializeStatus Tester::PassiveTestComponentBaseParamExternalDelegate ::
deserializeParam(
const FwPrmIdType base_id,
const FwPrmIdType local_id,
const Fw::ParamValid prmStat,
Fw::SerializeBufferBase& buff
)
{
Fw::SerializeStatus stat;
(void) base_id;
// Serialize the parameter based on ID
switch(local_id)
{
// ParamBoolExternal
case PassiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
stat = buff.deserialize(this->m_param_ParamBoolExternal);
break;
// ParamI32External
case PassiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
stat = buff.deserialize(this->m_param_ParamI32External);
break;
// ParamStringExternal
case PassiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
stat = buff.deserialize(this->m_param_ParamStringExternal);
break;
// ParamEnumExternal
case PassiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
stat = buff.deserialize(this->m_param_ParamEnumExternal);
break;
// ParamArrayExternal
case PassiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
stat = buff.deserialize(this->m_param_ParamArrayExternal);
break;
// ParamStructExternal
case PassiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
stat = buff.deserialize(this->m_param_ParamStructExternal);
break;
default:
// Unknown ID should not have gotten here
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
}
return stat;
}
Fw::SerializeStatus Tester::PassiveTestComponentBaseParamExternalDelegate ::
serializeParam(
const FwPrmIdType base_id,
const FwPrmIdType local_id,
Fw::SerializeBufferBase& buff
) const
{
Fw::SerializeStatus stat;
(void) base_id;
// Serialize the parameter based on ID
switch(local_id)
{
// ParamBoolExternal
case PassiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
stat = buff.serialize(this->m_param_ParamBoolExternal);
break;
// ParamI32External
case PassiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
stat = buff.serialize(this->m_param_ParamI32External);
break;
// ParamStringExternal
case PassiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
stat = buff.serialize(this->m_param_ParamStringExternal);
break;
// ParamEnumExternal
case PassiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
stat = buff.serialize(this->m_param_ParamEnumExternal);
break;
// ParamArrayExternal
case PassiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
stat = buff.serialize(this->m_param_ParamArrayExternal);
break;
// ParamStructExternal
case PassiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
stat = buff.serialize(this->m_param_ParamStructExternal);
break;
default:
// Unknown ID should not have gotten here
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
}
return stat;
}