Skip to content

Commit 2542b60

Browse files
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 <[email protected]>
1 parent 99da827 commit 2542b60

File tree

24 files changed

+1063
-49
lines changed

24 files changed

+1063
-49
lines changed

.github/actions/spelling/expect.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ calcu
102102
callergraph
103103
callgraph
104104
caltech
105+
Campuzano
105106
carg
106107
caselessmatch
107108
CBF
@@ -698,11 +699,17 @@ packetizer
698699
Packetizing
699700
Paetz
700701
PARAMARRAY
702+
PARAMARRAYEXTERNAL
701703
PARAMBOOL
704+
PARAMBOOLEXTERNAL
702705
PARAMDOC
703706
PARAMENUM
707+
PARAMENUMEXTERNAL
708+
PARAMI
704709
PARAMSTRING
710+
PARAMSTRINGEXTERNAL
705711
PARAMSTRUCT
712+
PARAMSTRUCTEXTERNAL
706713
PARAMU
707714
parseable
708715
PASSIVERATEGROUP

FppTest/component/active/CMakeLists.txt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# ======================================================================
1+
# ======================================================================
22
# CMakeLists.txt
3-
# ======================================================================
3+
# ======================================================================
44

55
set(SOURCE_FILES
6+
"${CMAKE_CURRENT_LIST_DIR}/ActiveTest.cpp"
67
"${CMAKE_CURRENT_LIST_DIR}/active.fpp"
7-
"${CMAKE_CURRENT_LIST_DIR}/port_types.fpp"
8-
"${CMAKE_CURRENT_LIST_DIR}/port_index_enums.fpp"
98
"${CMAKE_CURRENT_LIST_DIR}/fpp_types.fpp"
10-
"${CMAKE_CURRENT_LIST_DIR}/ActiveTest.cpp"
9+
"${CMAKE_CURRENT_LIST_DIR}/port_index_enums.fpp"
10+
"${CMAKE_CURRENT_LIST_DIR}/port_types.fpp"
1111
)
1212

1313
register_fprime_module()
@@ -31,29 +31,30 @@ set(UT_MOD_DEPS
3131
# Add unit test directory
3232
# UT_SOURCE_FILES: Sources for unit test
3333
set(UT_SOURCE_FILES
34-
"${CMAKE_CURRENT_LIST_DIR}/active.fpp"
35-
"${CMAKE_CURRENT_LIST_DIR}/port_types.fpp"
36-
"${CMAKE_CURRENT_LIST_DIR}/port_index_enums.fpp"
37-
"${CMAKE_CURRENT_LIST_DIR}/fpp_types.fpp"
38-
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp"
39-
"${CMAKE_CURRENT_LIST_DIR}/../tests/TestMain.cpp"
40-
"${CMAKE_CURRENT_LIST_DIR}/../tests/Tests.cpp"
41-
"${CMAKE_CURRENT_LIST_DIR}/../tests/TesterHandlers.cpp"
42-
"${CMAKE_CURRENT_LIST_DIR}/../tests/TesterHelpers.cpp"
43-
"${CMAKE_CURRENT_LIST_DIR}/../tests/PortTests.cpp"
34+
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"
35+
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncCmdTests.cpp"
36+
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncPortTests.cpp"
37+
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncTesterHelpers.cpp"
38+
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncTests.cpp"
4439
"${CMAKE_CURRENT_LIST_DIR}/../tests/CmdTests.cpp"
4540
"${CMAKE_CURRENT_LIST_DIR}/../tests/EventTests.cpp"
46-
"${CMAKE_CURRENT_LIST_DIR}/../tests/TlmTests.cpp"
47-
"${CMAKE_CURRENT_LIST_DIR}/../tests/ParamTests.cpp"
48-
"${CMAKE_CURRENT_LIST_DIR}/../tests/TimeTests.cpp"
41+
"${CMAKE_CURRENT_LIST_DIR}/../tests/ExternalParamTests.cpp"
4942
"${CMAKE_CURRENT_LIST_DIR}/../tests/InternalInterfaceTests.cpp"
50-
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncTests.cpp"
51-
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncTesterHelpers.cpp"
52-
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncPortTests.cpp"
53-
"${CMAKE_CURRENT_LIST_DIR}/../tests/AsyncCmdTests.cpp"
5443
"${CMAKE_CURRENT_LIST_DIR}/../tests/OverflowTests.cpp"
44+
"${CMAKE_CURRENT_LIST_DIR}/../tests/ParamTests.cpp"
45+
"${CMAKE_CURRENT_LIST_DIR}/../tests/PortTests.cpp"
46+
"${CMAKE_CURRENT_LIST_DIR}/../tests/TestMain.cpp"
47+
"${CMAKE_CURRENT_LIST_DIR}/../tests/TesterHandlers.cpp"
48+
"${CMAKE_CURRENT_LIST_DIR}/../tests/TesterHelpers.cpp"
49+
"${CMAKE_CURRENT_LIST_DIR}/../tests/Tests.cpp"
50+
"${CMAKE_CURRENT_LIST_DIR}/../tests/TimeTests.cpp"
51+
"${CMAKE_CURRENT_LIST_DIR}/../tests/TlmTests.cpp"
5552
"${CMAKE_CURRENT_LIST_DIR}/../types/FormalParamTypes.cpp"
56-
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"
53+
"${CMAKE_CURRENT_LIST_DIR}/active.fpp"
54+
"${CMAKE_CURRENT_LIST_DIR}/fpp_types.fpp"
55+
"${CMAKE_CURRENT_LIST_DIR}/port_index_enums.fpp"
56+
"${CMAKE_CURRENT_LIST_DIR}/port_types.fpp"
57+
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp"
5758
)
5859
# Needed for compiling files using Tester.hpp from outside the directory
5960
include_directories("${CMAKE_CURRENT_LIST_DIR}/test/ut")

FppTest/component/active/active.fpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
@ An active component
22
active component ActiveTest {
33

4-
include "../include/typed_ports.fppi"
5-
include "../include/typed_ports_async.fppi"
4+
include "../include/internal_ports.fppi"
65
include "../include/serial_ports.fppi"
76
include "../include/serial_ports_async.fppi"
87
include "../include/special_ports.fppi"
9-
include "../include/internal_ports.fppi"
8+
include "../include/typed_ports.fppi"
9+
include "../include/typed_ports_async.fppi"
1010

1111
include "../include/output_ports.fppi"
1212

1313
include "../include/commands.fppi"
1414
include "../include/commands_async.fppi"
1515
include "../include/events.fppi"
16-
include "../include/telemetry.fppi"
16+
include "../include/external_params.fppi"
1717
include "../include/params.fppi"
18+
include "../include/telemetry.fppi"
1819

1920
}

FppTest/component/active/test/ut/Tester.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Tester ::Tester()
2525
this->initComponents();
2626
this->connectPorts();
2727
this->connectAsyncPorts();
28+
this->component.registerExternalParameters(&this->paramTesterDelegate);
2829
}
2930

3031
Tester ::~Tester() {}
@@ -119,3 +120,99 @@ void Tester ::from_prmSetIn_handler(const FwIndexType portNum, FwPrmIdType id, F
119120

120121
this->pushFromPortEntry_prmSetIn(id, val);
121122
}
123+
124+
125+
// ----------------------------------------------------------------------
126+
// Unit test implementation of external parameter delegate serialization/deserialization
127+
// ----------------------------------------------------------------------
128+
129+
Fw::SerializeStatus Tester::ActiveTestComponentBaseParamExternalDelegate ::
130+
deserializeParam(
131+
const FwPrmIdType base_id,
132+
const FwPrmIdType local_id,
133+
const Fw::ParamValid prmStat,
134+
Fw::SerializeBufferBase& buff
135+
)
136+
{
137+
Fw::SerializeStatus stat;
138+
(void) base_id;
139+
140+
// Serialize the parameter based on ID
141+
switch(local_id)
142+
{
143+
// ParamBoolExternal
144+
case ActiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
145+
stat = buff.deserialize(this->m_param_ParamBoolExternal);
146+
break;
147+
// ParamI32External
148+
case ActiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
149+
stat = buff.deserialize(this->m_param_ParamI32External);
150+
break;
151+
// ParamStringExternal
152+
case ActiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
153+
stat = buff.deserialize(this->m_param_ParamStringExternal);
154+
break;
155+
// ParamEnumExternal
156+
case ActiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
157+
stat = buff.deserialize(this->m_param_ParamEnumExternal);
158+
break;
159+
// ParamArrayExternal
160+
case ActiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
161+
stat = buff.deserialize(this->m_param_ParamArrayExternal);
162+
break;
163+
// ParamStructExternal
164+
case ActiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
165+
stat = buff.deserialize(this->m_param_ParamStructExternal);
166+
break;
167+
default:
168+
// Unknown ID should not have gotten here
169+
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
170+
}
171+
172+
return stat;
173+
}
174+
175+
Fw::SerializeStatus Tester::ActiveTestComponentBaseParamExternalDelegate ::
176+
serializeParam(
177+
const FwPrmIdType base_id,
178+
const FwPrmIdType local_id,
179+
Fw::SerializeBufferBase& buff
180+
) const
181+
{
182+
Fw::SerializeStatus stat;
183+
(void) base_id;
184+
185+
// Serialize the parameter based on ID
186+
switch(local_id)
187+
{
188+
// ParamBoolExternal
189+
case ActiveTestComponentBase::PARAMID_PARAMBOOLEXTERNAL:
190+
stat = buff.serialize(this->m_param_ParamBoolExternal);
191+
break;
192+
// ParamI32External
193+
case ActiveTestComponentBase::PARAMID_PARAMI32EXTERNAL:
194+
stat = buff.serialize(this->m_param_ParamI32External);
195+
break;
196+
// ParamStringExternal
197+
case ActiveTestComponentBase::PARAMID_PARAMSTRINGEXTERNAL:
198+
stat = buff.serialize(this->m_param_ParamStringExternal);
199+
break;
200+
// ParamEnumExternal
201+
case ActiveTestComponentBase::PARAMID_PARAMENUMEXTERNAL:
202+
stat = buff.serialize(this->m_param_ParamEnumExternal);
203+
break;
204+
// ParamArrayExternal
205+
case ActiveTestComponentBase::PARAMID_PARAMARRAYEXTERNAL:
206+
stat = buff.serialize(this->m_param_ParamArrayExternal);
207+
break;
208+
// ParamStructExternal
209+
case ActiveTestComponentBase::PARAMID_PARAMSTRUCTEXTERNAL:
210+
stat = buff.serialize(this->m_param_ParamStructExternal);
211+
break;
212+
default:
213+
// Unknown ID should not have gotten here
214+
FW_ASSERT(false, static_cast<FwAssertArgType>(local_id));
215+
}
216+
217+
return stat;
218+
}

FppTest/component/active/test/ut/Tester.hpp

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "FppTest/component/tests/EventTests.hpp"
1616
#include "FppTest/component/tests/InternalInterfaceTests.hpp"
1717
#include "FppTest/component/tests/ParamTests.hpp"
18+
#include "FppTest/component/tests/ExternalParamTests.hpp"
1819
#include "FppTest/component/tests/PortTests.hpp"
1920
#include "FppTest/component/tests/TlmTests.hpp"
2021
#include "FppTest/component/types/FormalParamTypes.hpp"
@@ -59,6 +60,9 @@ class Tester : public ActiveTestGTestBase {
5960
void testParam();
6061
PARAM_CMD_TEST_DECLS
6162

63+
void testExternalParam();
64+
EXTERNAL_PARAM_CMD_TEST_DECLS
65+
6266
INTERNAL_INT_TEST_DECLS
6367

6468
void testTime();
@@ -164,8 +168,91 @@ class Tester : public ActiveTestGTestBase {
164168
FppTest::Types::StructParam structPrm;
165169
Fw::ParamValid prmValid;
166170

167-
// Time test values
168171
Fw::Time time;
172+
173+
//! External Parameter Delegate
174+
class ActiveTestComponentBaseParamExternalDelegate :
175+
public Fw::ParamExternalDelegate
176+
{
177+
178+
public:
179+
180+
// ----------------------------------------------------------------------
181+
// Parameter validity flags
182+
// ----------------------------------------------------------------------
183+
184+
//! True if ParamBoolExternal was successfully received
185+
Fw::ParamValid m_param_ParamBoolExternal_valid;
186+
187+
//! True if ParamI32External was successfully received
188+
Fw::ParamValid m_param_ParamI32External_valid;
189+
190+
//! True if ParamStringExternal was successfully received
191+
Fw::ParamValid m_param_ParamStringExternal_valid;
192+
193+
//! True if ParamEnumExternal was successfully received
194+
Fw::ParamValid m_param_ParamEnumExternal_valid;
195+
196+
//! True if ParamArrayExternal was successfully received
197+
Fw::ParamValid m_param_ParamArrayExternal_valid;
198+
199+
//! True if ParamStructExternal was successfully received
200+
Fw::ParamValid m_param_ParamStructExternal_valid;
201+
202+
public:
203+
204+
// ----------------------------------------------------------------------
205+
// Parameter variables
206+
// ----------------------------------------------------------------------
207+
208+
//! Parameter ParamBoolExternal
209+
bool m_param_ParamBoolExternal;
210+
211+
//! Parameter ParamI32External
212+
I32 m_param_ParamI32External;
213+
214+
//! Parameter ParamStringExternal
215+
Fw::ParamString m_param_ParamStringExternal;
216+
217+
//! Parameter ParamEnumExternal
218+
FormalParamEnum m_param_ParamEnumExternal;
219+
220+
//! Parameter ParamArrayExternal
221+
FormalParamArray m_param_ParamArrayExternal;
222+
223+
//! Parameter ParamStructExternal
224+
FormalParamStruct m_param_ParamStructExternal;
225+
226+
public:
227+
228+
// ----------------------------------------------------------------------
229+
// Unit test implementation of external parameter delegate serialization/deserialization
230+
// ----------------------------------------------------------------------
231+
232+
//! Parameter deserialization function for external parameter unit testing
233+
Fw::SerializeStatus deserializeParam(
234+
const FwPrmIdType base_id, //!< The component base parameter ID to deserialize
235+
const FwPrmIdType local_id, //!< The parameter local ID to deserialize
236+
const Fw::ParamValid prmStat, //!< The parameter validity status
237+
Fw::SerializeBufferBase& buff //!< The buffer containing the parameter to deserialize
238+
) override;
239+
240+
//! Parameter serialization function for external parameter unit testing
241+
Fw::SerializeStatus serializeParam(
242+
const FwPrmIdType base_id, //!< The component base parameter ID to serialize
243+
const FwPrmIdType local_id, //!< The parameter local ID to serialize
244+
Fw::SerializeBufferBase& buff //!< The buffer to serialize the parameter into
245+
) const override;
246+
247+
};
248+
249+
// ----------------------------------------------------------------------
250+
// Parameter delegates
251+
// ----------------------------------------------------------------------
252+
253+
//! Delegate to serialize/deserialize an externally stored parameter
254+
ActiveTestComponentBaseParamExternalDelegate paramTesterDelegate;
255+
169256
};
170257

171258
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
external param ParamBoolExternal: bool
2+
3+
external param ParamI32External: I32
4+
5+
external param ParamStringExternal: string \
6+
default "external default"
7+
8+
external param ParamEnumExternal: FormalParamEnum \
9+
id 0x50
10+
11+
external param ParamArrayExternal: FormalParamArray \
12+
default [ 1.0, 2.0, 3.0 ] \
13+
save opcode 0x75
14+
15+
external param ParamStructExternal: FormalParamStruct \
16+
set opcode 0x80 \
17+
save opcode 0x85

FppTest/component/passive/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# ======================================================================
1+
# ======================================================================
22
# CMakeLists.txt
3-
# ======================================================================
3+
# ======================================================================
44

55
set(SOURCE_FILES
66
"${CMAKE_CURRENT_LIST_DIR}/passive.fpp"
@@ -39,6 +39,7 @@ set(UT_SOURCE_FILES
3939
"${CMAKE_CURRENT_LIST_DIR}/../tests/EventTests.cpp"
4040
"${CMAKE_CURRENT_LIST_DIR}/../tests/TlmTests.cpp"
4141
"${CMAKE_CURRENT_LIST_DIR}/../tests/ParamTests.cpp"
42+
"${CMAKE_CURRENT_LIST_DIR}/../tests/ExternalParamTests.cpp"
4243
"${CMAKE_CURRENT_LIST_DIR}/../tests/TimeTests.cpp"
4344
"${CMAKE_CURRENT_LIST_DIR}/../types/FormalParamTypes.cpp"
4445
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"

FppTest/component/passive/passive.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ passive component PassiveTest {
1313
include "../include/events.fppi"
1414
include "../include/telemetry.fppi"
1515
include "../include/params.fppi"
16+
include "../include/external_params.fppi"
1617

1718
}

0 commit comments

Comments
 (0)