Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ case class ComponentCppWriter (
}

private def getCppIncludes: CppDoc.Member = {
val userHeaders = List(
val prmValidHeader = if hasParameters then List("Fw/Prm/ParamValid.hpp") else Nil
val userHeaders = (List(
"Fw/Types/Assert.hpp",
"Fw/Types/ExternalString.hpp",
"Fw/Types/String.hpp",
s.getIncludePath(componentSymbol, fileName)
).sorted.map(CppWriter.headerString).flatMap({
) ++ prmValidHeader).sorted.map(CppWriter.headerString).flatMap({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val prmValidHeader = if hasParameters then List("Fw/Prm/ParamValid.hpp") else Nil
val userHeaders = (List(
"Fw/Types/Assert.hpp",
"Fw/Types/ExternalString.hpp",
"Fw/Types/String.hpp",
s.getIncludePath(componentSymbol, fileName)
).sorted.map(CppWriter.headerString).flatMap({
) ++ prmValidHeader).sorted.map(CppWriter.headerString).flatMap({
val userHeaders = List.concat(
guardedList (hasParameters) (List("Fw/Prm/ParamValid.hpp")),
List(
"Fw/Types/Assert.hpp",
"Fw/Types/ExternalString.hpp",
"Fw/Types/String.hpp",
s.getIncludePath(componentSymbol, fileName)
)
).sorted.map(CppWriter.headerString).flatMap({

case s: "#include \"Fw/Types/String.hpp\"" =>
lines(
s"""|#if FW_ENABLE_TEXT_LOGGING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ case class ComponentParameters (
"Parameter hook functions",
List(
getParamUpdateHookFunction,
getParamLoadHookFunction
getParamLoadHookFunction,
getParamLoadedHookFunction

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, let's rename getParamLoadedHookFunction to getParamsLoadHookFunction.

)
)
}
Expand Down Expand Up @@ -225,7 +226,9 @@ case class ComponentParameters (
Some(
s"""|\\brief Called whenever parameters are loaded
|
|This function does nothing by default. You may override it.
|By default this notifies the component of each parameter via
|parameterUpdated. You may override it, for example to suppress
|notification on load.
|"""
),
"parametersLoaded",
Expand All @@ -235,6 +238,36 @@ case class ComponentParameters (
CppDoc.Function.Virtual
)

private def getParamLoadedHookFunction = functionClassMember(
Some(
s"""|\\brief Called for each parameter when parameters are loaded
|
|By default this notifies the component via parameterUpdated when
|the parameter loaded successfully (valid or default). You may
|override it, for example to distinguish load from update.
|"""
),
"parameterLoaded",
List(
CppDoc.Function.Param(
CppDoc.Type("FwPrmIdType"),
"id",
Some("The parameter ID")
),
CppDoc.Function.Param(
CppDoc.Type("Fw::ParamValid"),
"valid",
Some("The parameter validity status")
)
),
CppDoc.Type("void"),
wrapInIf(
"FW_PARAM_OK(valid)",
lines("this->parameterUpdated(id);")
),
CppDoc.Function.Virtual
)

private def getParamUpdateHookFunction = functionClassMember(
Some(
s"""|\\brief Called whenever a parameter is updated
Expand Down Expand Up @@ -448,6 +481,9 @@ case class ComponentParameters (
lines(
"""|
|this->m_paramLock.unlock();"""
),
lines(
s"this->parameterLoaded(${paramIdConstantName(param.getName)}, this->${paramValidityFlagName(param.getName)});"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// ======================================================================

#include "ActiveExternalParamsComponentAc.hpp"
#include "Fw/Prm/ParamValid.hpp"
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/ExternalString.hpp"
#if FW_ENABLE_TEXT_LOGGING
Expand Down Expand Up @@ -1689,6 +1690,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMI32EXT, this->m_param_ParamI32Ext_valid);

_id = _baseId + PARAMID_PARAMF64EXT;

Expand All @@ -1714,6 +1716,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMF64EXT, this->m_param_ParamF64Ext_valid);

_id = _baseId + PARAMID_PARAMSTRINGEXT;

Expand Down Expand Up @@ -1760,6 +1763,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRINGEXT, this->m_param_ParamStringExt_valid);

_id = _baseId + PARAMID_PARAMENUMEXT;

Expand All @@ -1785,6 +1789,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMENUMEXT, this->m_param_ParamEnumExt_valid);

_id = _baseId + PARAMID_PARAMARRAYEXT;

Expand Down Expand Up @@ -1831,6 +1836,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMARRAYEXT, this->m_param_ParamArrayExt_valid);

_id = _baseId + PARAMID_PARAMSTRUCTEXT;

Expand All @@ -1856,6 +1862,7 @@ void ActiveExternalParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRUCTEXT, this->m_param_ParamStructExt_valid);

// Call notifier
this->parametersLoaded();
Expand Down Expand Up @@ -3495,6 +3502,17 @@ void ActiveExternalParamsComponentBase ::
// Do nothing by default
}

void ActiveExternalParamsComponentBase ::
parameterLoaded(
FwPrmIdType id,
Fw::ParamValid valid
)
{
if (FW_PARAM_OK(valid)) {
this->parameterUpdated(id);
}
}

// ----------------------------------------------------------------------
// Parameter get functions
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,21 @@ class ActiveExternalParamsComponentBase :

//! \brief Called whenever parameters are loaded
//!
//! This function does nothing by default. You may override it.
//! By default this notifies the component of each parameter via
//! parameterUpdated. You may override it, for example to suppress
//! notification on load.
virtual void parametersLoaded();

//! \brief Called for each parameter when parameters are loaded
//!
//! By default this notifies the component via parameterUpdated when
//! the parameter loaded successfully (valid or default). You may
//! override it, for example to distinguish load from update.
virtual void parameterLoaded(
FwPrmIdType id, //!< The parameter ID
Fw::ParamValid valid //!< The parameter validity status
);

protected:

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// ======================================================================

#include "ActiveParamsComponentAc.hpp"
#include "Fw/Prm/ParamValid.hpp"
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/ExternalString.hpp"
#if FW_ENABLE_TEXT_LOGGING
Expand Down Expand Up @@ -1685,6 +1686,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMU32, this->m_param_ParamU32_valid);

_id = _baseId + PARAMID_PARAMF64;

Expand All @@ -1706,6 +1708,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMF64, this->m_param_ParamF64_valid);

_id = _baseId + PARAMID_PARAMSTRING;

Expand Down Expand Up @@ -1733,6 +1736,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRING, this->m_param_ParamString_valid);

_id = _baseId + PARAMID_PARAMENUM;

Expand All @@ -1754,6 +1758,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMENUM, this->m_param_ParamEnum_valid);

_id = _baseId + PARAMID_PARAMARRAY;

Expand Down Expand Up @@ -1781,6 +1786,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMARRAY, this->m_param_ParamArray_valid);

_id = _baseId + PARAMID_PARAMSTRUCT;

Expand All @@ -1802,6 +1808,7 @@ void ActiveParamsComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRUCT, this->m_param_ParamStruct_valid);

// Call notifier
this->parametersLoaded();
Expand Down Expand Up @@ -3441,6 +3448,17 @@ void ActiveParamsComponentBase ::
// Do nothing by default
}

void ActiveParamsComponentBase ::
parameterLoaded(
FwPrmIdType id,
Fw::ParamValid valid
)
{
if (FW_PARAM_OK(valid)) {
this->parameterUpdated(id);
}
}

// ----------------------------------------------------------------------
// Parameter get functions
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1543,9 +1543,21 @@ class ActiveParamsComponentBase :

//! \brief Called whenever parameters are loaded
//!
//! This function does nothing by default. You may override it.
//! By default this notifies the component of each parameter via
//! parameterUpdated. You may override it, for example to suppress
//! notification on load.
virtual void parametersLoaded();

//! \brief Called for each parameter when parameters are loaded
//!
//! By default this notifies the component via parameterUpdated when
//! the parameter loaded successfully (valid or default). You may
//! override it, for example to distinguish load from update.
virtual void parameterLoaded(
FwPrmIdType id, //!< The parameter ID
Fw::ParamValid valid //!< The parameter validity status
);

protected:

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// ======================================================================

#include "ActiveSerialComponentAc.hpp"
#include "Fw/Prm/ParamValid.hpp"
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/ExternalString.hpp"
#if FW_ENABLE_TEXT_LOGGING
Expand Down Expand Up @@ -2147,6 +2148,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMU32, this->m_param_ParamU32_valid);

_id = _baseId + PARAMID_PARAMF64;

Expand All @@ -2168,6 +2170,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMF64, this->m_param_ParamF64_valid);

_id = _baseId + PARAMID_PARAMSTRING;

Expand Down Expand Up @@ -2195,6 +2198,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRING, this->m_param_ParamString_valid);

_id = _baseId + PARAMID_PARAMENUM;

Expand All @@ -2216,6 +2220,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMENUM, this->m_param_ParamEnum_valid);

_id = _baseId + PARAMID_PARAMARRAY;

Expand Down Expand Up @@ -2243,6 +2248,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMARRAY, this->m_param_ParamArray_valid);

_id = _baseId + PARAMID_PARAMSTRUCT;

Expand All @@ -2264,6 +2270,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRUCT, this->m_param_ParamStruct_valid);

_id = _baseId + PARAMID_PARAMI32EXT;

Expand All @@ -2289,6 +2296,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMI32EXT, this->m_param_ParamI32Ext_valid);

_id = _baseId + PARAMID_PARAMF64EXT;

Expand All @@ -2314,6 +2322,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMF64EXT, this->m_param_ParamF64Ext_valid);

_id = _baseId + PARAMID_PARAMSTRINGEXT;

Expand Down Expand Up @@ -2360,6 +2369,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRINGEXT, this->m_param_ParamStringExt_valid);

_id = _baseId + PARAMID_PARAMENUMEXT;

Expand All @@ -2385,6 +2395,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMENUMEXT, this->m_param_ParamEnumExt_valid);

_id = _baseId + PARAMID_PARAMARRAYEXT;

Expand Down Expand Up @@ -2431,6 +2442,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMARRAYEXT, this->m_param_ParamArrayExt_valid);

_id = _baseId + PARAMID_PARAMSTRUCTEXT;

Expand All @@ -2456,6 +2468,7 @@ void ActiveSerialComponentBase ::
}

this->m_paramLock.unlock();
this->parameterLoaded(PARAMID_PARAMSTRUCTEXT, this->m_param_ParamStructExt_valid);

// Call notifier
this->parametersLoaded();
Expand Down Expand Up @@ -7120,6 +7133,17 @@ void ActiveSerialComponentBase ::
// Do nothing by default
}

void ActiveSerialComponentBase ::
parameterLoaded(
FwPrmIdType id,
Fw::ParamValid valid
)
{
if (FW_PARAM_OK(valid)) {
this->parameterUpdated(id);
}
}

// ----------------------------------------------------------------------
// Parameter get functions
// ----------------------------------------------------------------------
Expand Down
Loading