Skip to content
Open
Show file tree
Hide file tree
Changes from all 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,11 +144,14 @@ case class ComponentCppWriter (
}

private def getCppIncludes: CppDoc.Member = {
val userHeaders = List(
"Fw/Types/Assert.hpp",
"Fw/Types/ExternalString.hpp",
"Fw/Types/String.hpp",
s.getIncludePath(componentSymbol, fileName)
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(
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,
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 getParamsLoadHookFunction = 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
Loading