From b5bdf003bcd0b26e3b61d9fdecc895c063aa711d Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Thu, 7 Nov 2024 13:32:13 -0600 Subject: [PATCH 1/4] Adding blinker component --- .../Top/BroncoDeploymentPackets.xml | 6 + BroncoDeployment/Top/instances.fpp | 9 +- BroncoDeployment/Top/topology.fpp | 11 ++ Components/CMakeLists.txt | 2 +- Components/LedBlinker/CMakeLists.txt | 29 ++++ Components/LedBlinker/LedBlinker.cpp | 143 ++++++++++++++++++ Components/LedBlinker/LedBlinker.fpp | 76 ++++++++++ Components/LedBlinker/LedBlinker.hpp | 88 +++++++++++ Components/LedBlinker/docs/sdd.md | 66 ++++++++ .../test/int/led_integration_tests.py | 6 + .../LedBlinker/test/ut/LedBlinkerTestMain.cpp | 17 +++ .../LedBlinker/test/ut/LedBlinkerTester.cpp | 55 +++++++ .../LedBlinker/test/ut/LedBlinkerTester.hpp | 83 ++++++++++ .../test/ut/LedBlinkerTesterHelpers.cpp | 52 +++++++ 14 files changed, 640 insertions(+), 3 deletions(-) create mode 100644 Components/LedBlinker/CMakeLists.txt create mode 100644 Components/LedBlinker/LedBlinker.cpp create mode 100644 Components/LedBlinker/LedBlinker.fpp create mode 100644 Components/LedBlinker/LedBlinker.hpp create mode 100644 Components/LedBlinker/docs/sdd.md create mode 100644 Components/LedBlinker/test/int/led_integration_tests.py create mode 100644 Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp create mode 100644 Components/LedBlinker/test/ut/LedBlinkerTester.cpp create mode 100644 Components/LedBlinker/test/ut/LedBlinkerTester.hpp create mode 100644 Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp diff --git a/BroncoDeployment/Top/BroncoDeploymentPackets.xml b/BroncoDeployment/Top/BroncoDeploymentPackets.xml index 76445dc..44224b9 100644 --- a/BroncoDeployment/Top/BroncoDeploymentPackets.xml +++ b/BroncoDeployment/Top/BroncoDeploymentPackets.xml @@ -53,6 +53,12 @@ + + + + + + diff --git a/BroncoDeployment/Top/instances.fpp b/BroncoDeployment/Top/instances.fpp index 336e878..1f36080 100644 --- a/BroncoDeployment/Top/instances.fpp +++ b/BroncoDeployment/Top/instances.fpp @@ -27,6 +27,11 @@ module BroncoDeployment { queue size Default.QUEUE_SIZE \ stack size Default.STACK_SIZE \ priority 97 + + instance ledBlinker: Components.LedBlinker base id 0x0E00 \ + queue size Default.QUEUE_SIZE \ + stack size Default.STACK_SIZE \ + priority 95 # ---------------------------------------------------------------------- # Queued component instances @@ -60,6 +65,8 @@ module BroncoDeployment { instance rateDriver: Arduino.HardwareRateDriver base id 0x4A00 + instance neoPixelDriver: Drv.NeoPixelDriver base id 0x4C00 + # Hub Connections instance hub: Svc.GenericHub base id 0x5000 @@ -70,8 +77,6 @@ module BroncoDeployment { instance hubComDriver: Radio.RFM69 base id 0x5300 - - # Custom Connections instance broncoOreMessageHandler: Components.BroncoOreMessageHandler base id 0x6000 diff --git a/BroncoDeployment/Top/topology.fpp b/BroncoDeployment/Top/topology.fpp index 0f6a974..a48a187 100644 --- a/BroncoDeployment/Top/topology.fpp +++ b/BroncoDeployment/Top/topology.fpp @@ -44,6 +44,8 @@ module BroncoDeployment { #custom instances instance broncoOreMessageHandler + instance ledBlinker + instance neoPixelDriver # ---------------------------------------------------------------------- # Pattern graph specifiers @@ -126,6 +128,15 @@ module BroncoDeployment { hubDeframer.bufferOut -> hub.dataIn hub.dataInDeallocate -> bufferManager.bufferSendIn } + + # Named connection group + connections LedConnections { + # Rate Group 1 (1Hz cycle) ouput is connected to led's run input + rateGroup1.RateGroupMemberOut[3] -> ledBlinker.run + # led's neopixel output is connected to neoPixelDriver's neoPixelOnOff input + ledBlinker.neoPixelSet -> neoPixelDriver.neoPixelSet + } + } } diff --git a/Components/CMakeLists.txt b/Components/CMakeLists.txt index 40b944f..bedc4d2 100644 --- a/Components/CMakeLists.txt +++ b/Components/CMakeLists.txt @@ -4,5 +4,5 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BroncoOreMessageHandler/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Radio/") - +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LedBlinker/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/") diff --git a/Components/LedBlinker/CMakeLists.txt b/Components/LedBlinker/CMakeLists.txt new file mode 100644 index 0000000..56c1d7c --- /dev/null +++ b/Components/LedBlinker/CMakeLists.txt @@ -0,0 +1,29 @@ +#### +# F prime CMakeLists.txt: +# +# SOURCE_FILES: combined list of source and autocoding files +# MOD_DEPS: (optional) module dependencies +# UT_SOURCE_FILES: list of source files for unit tests +# +#### +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.fpp" + "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.cpp" +) + +# Uncomment and add any modules that this component depends on, else +# they might not be available when cmake tries to build this component. + +# set(MOD_DEPS +# Adafruit_NeoPixel +# ) + +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/LedBlinkerTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/LedBlinkerTester.cpp" +) +set(UT_AUTO_HELPERS ON) # Additional Unit-Test autocoding +register_fprime_ut() diff --git a/Components/LedBlinker/LedBlinker.cpp b/Components/LedBlinker/LedBlinker.cpp new file mode 100644 index 0000000..ab8a87b --- /dev/null +++ b/Components/LedBlinker/LedBlinker.cpp @@ -0,0 +1,143 @@ +// ====================================================================== +// \title LedBlinker.cpp +// \author nateinaction +// \brief cpp file for LedBlinker component implementation class +// ====================================================================== + +#include "Components/LedBlinker/LedBlinker.hpp" +#include "FpConfig.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- +LedBlinker ::LedBlinker(const char* const compName) : LedBlinkerComponentBase(compName) {} + +LedBlinker ::~LedBlinker() {} + +// ---------------------------------------------------------------------- +// Handler implementations for user-defined typed input ports +// ---------------------------------------------------------------------- + + void LedBlinker :: + run_handler( + const NATIVE_INT_TYPE portNum, + NATIVE_UINT_TYPE context) + { + // Only perform actions when set to blinking + if (this->blinkingState) { + // Blink the LED + blink(); + } else { + // Turn off the LED + this->neoPixelSet_out(0, Drv::NeoPixelColor(0, 0, 0)); + } + + // Report the number of blinks via a telemetry channel + this->tlmWrite_LedBlinks(this->blinkCount); + } + + void LedBlinker ::blink() { + // Get interval from parameter or use default + U32 interval = this->intervalParamOrDefault(); + + // Get color from parameter or use default + Drv::NeoPixelColor color = this->colorParamOrDefault(); + + // Set the LED color or turn it off based on cycle count + this->neoPixelSet_out(0, (this->cycleCount < (interval / 2)) ? color : Drv::NeoPixelColor(0, 0, 0)); + + // Increment blink count at the start of a cycle + this->blinkCount += (this->cycleCount == 0); + + // Increment cycle count + this->cycleCount = (this->cycleCount + 1) % interval; + } + + Drv::NeoPixelColor LedBlinker ::colorParamOrDefault() { + // Read back the parameter value + Fw::ParamValid isColorValid; + Drv::NeoPixelColor color = this->paramGet_BLINK_COLOR(isColorValid); + + // Force color to be red when invalid or not set + return ((Fw::ParamValid::INVALID == isColorValid) || (Fw::ParamValid::UNINIT == isColorValid)) ? Drv::NeoPixelColor(50, 0, 0) : color; + } + + U32 LedBlinker ::intervalParamOrDefault() { + // Read back the parameter value + Fw::ParamValid isIntervalValid; + U32 interval = this->paramGet_BLINK_INTERVAL(isIntervalValid); + + // Force interval to be 10 when invalid or not set + return ((Fw::ParamValid::INVALID == isIntervalValid) || (Fw::ParamValid::UNINIT == isIntervalValid)) ? 10 : interval; + } + + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + void LedBlinker ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On blinking_state) { + // Create a variable to represent the command response + auto cmdResp = Fw::CmdResponse::OK; + + // Set blinking state + this->blinkingState = blinking_state; + + // Reset cycle count + this->cycleCount = 0; + + // Reports the state as an event + this->log_ACTIVITY_HI_SetBlinkingState(blinking_state); + + // Report the blinking state via a telemetry channel. + this->tlmWrite_BlinkingState(blinking_state); + + // Provide command response + this->cmdResponse_out(opCode, cmdSeq, cmdResp); + } + + void LedBlinker ::parameterUpdated(FwPrmIdType id) { + switch (id) + { + case PARAMID_BLINK_COLOR: + // Validate and set the color parameter on update + this->parameterValidateColor(); + break; + case PARAMID_BLINK_INTERVAL: + // Validate and set the interval parameter on update + this->parameterValidateInterval(); + break; + default: + FW_ASSERT(1, id); // Should never reach, invalid parameter ID + break; + } + } + + void LedBlinker ::parameterValidateColor() { + // Read back the parameter value + Fw::ParamValid isValid; + Drv::NeoPixelColor color = this->paramGet_BLINK_COLOR(isValid); + + // Fail if the color is invalid + FW_ASSERT(isValid == Fw::ParamValid::VALID, isValid); + + // Log the color change + this->log_ACTIVITY_HI_BlinkColorSet(color); + + // Report the color via a telemetry channel + this->tlmWrite_BlinkingColor(color); + } + + void LedBlinker ::parameterValidateInterval() { + // Read back the parameter value + Fw::ParamValid isValid; + U32 interval = this->paramGet_BLINK_INTERVAL(isValid); + + // Fail if the interval is invalid + FW_ASSERT(isValid == Fw::ParamValid::VALID, isValid); + + // Log the interval change + this->log_ACTIVITY_HI_BlinkIntervalSet(interval); + } +} // namespace Components diff --git a/Components/LedBlinker/LedBlinker.fpp b/Components/LedBlinker/LedBlinker.fpp new file mode 100644 index 0000000..579664c --- /dev/null +++ b/Components/LedBlinker/LedBlinker.fpp @@ -0,0 +1,76 @@ +module Components { + @ Component to blink an LED driven by a rate group + active component LedBlinker { + @ Command to turn on or off the blinking LED + async command BLINKING_ON_OFF( + blinking_state: Fw.On @< Turn the LED blinking on or off. + ) + + @ Reports the state we set to blinking. + event SetBlinkingState(state: Fw.On) \ + severity activity high \ + format "Set blinking state to {}." + + @ Reports the color that has been set + event BlinkColorSet(color: Drv.NeoPixelColor) \ + severity activity high \ + format "LED blink color set to {}" + + @ Reports the interval that has been set + event BlinkIntervalSet(interval: U32) \ + severity activity high \ + format "LED blink interval set to {}" + + @ Telemetry channel to report blinking state. + telemetry BlinkingState: Fw.On + + @ Telemetry channel to report blinking state. + telemetry BlinkingColor: Drv.NeoPixelColor + + @ Telemetry channel to report the LED state. + telemetry LedBlinks: U64 + + @ Blinking interval in rate group ticks + param BLINK_INTERVAL: U32 + + @ Blinking interval in rate group ticks + param BLINK_COLOR: Drv.NeoPixelColor + + @ Port receiving calls from the rate group + sync input port run: Svc.Sched + + @ Port sending calls to the GPIO driver + output port neoPixelSet: Drv.NeoPixelSet + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + @ Port for sending command registrations + command reg port cmdRegOut + + @ Port for receiving commands + command recv port cmdIn + + @ Port for sending command responses + command resp port cmdResponseOut + + @ Port for sending textual representation of events + text event port logTextOut + + @ Port for sending events to downlink + event port logOut + + @ Port for sending telemetry channels to downlink + telemetry port tlmOut + + @ Port to return the value of a parameter + param get port prmGetOut + + @Port to set the value of a parameter + param set port prmSetOut + + } +} diff --git a/Components/LedBlinker/LedBlinker.hpp b/Components/LedBlinker/LedBlinker.hpp new file mode 100644 index 0000000..4e5bc9c --- /dev/null +++ b/Components/LedBlinker/LedBlinker.hpp @@ -0,0 +1,88 @@ +// ====================================================================== +// \title LedBlinker.hpp +// \author nateinaction +// \brief hpp file for LedBlinker component implementation class +// ====================================================================== + +#ifndef Components_LedBlinker_HPP +#define Components_LedBlinker_HPP + +#include "Components/LedBlinker/LedBlinkerComponentAc.hpp" + +namespace Components { + +class LedBlinker : public LedBlinkerComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct LedBlinker object + LedBlinker(const char* const compName //!< The component name + ); + + //! Destroy LedBlinker object + ~LedBlinker(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for user-defined typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for run + //! + //! Port receiving calls from the rate group + void run_handler(NATIVE_INT_TYPE portNum, //!< The port number + NATIVE_UINT_TYPE context //!< The call order + ) override; + + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + //! Implementation for BLINKING_ON_OFF command handler + //! Command to turn on or off the blinking LED + void BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode + U32 cmdSeq, //!< The command sequence number + Fw::On blinking_state //!< Color to blink + ) override; + + //! Emit parameter updated EVR + //! + void parameterUpdated(FwPrmIdType id /*!< The parameter ID*/ + ); + + //! Validate and set the color parameter on update + //! + void parameterValidateColor( + ); + + //! Validate and set the interval parameter on update + //! + void parameterValidateInterval( + ); + + //! Choose the color to blink + //! + Drv::NeoPixelColor colorParamOrDefault( + ); + + //! Choose the interval to blink + //! + U32 intervalParamOrDefault( + ); + + //! The LED blinker behavior + //! + void blink( + ); + + // Private member variables + Fw::On blinkingState; //!< Whether the LED is blinking or not + U64 blinkCount; //! The number of on/off transitions that have occurred from FSW boot up + U32 cycleCount; //! Keeps track of how many ticks the LED has been on for +}; + +} // namespace Components + +#endif diff --git a/Components/LedBlinker/docs/sdd.md b/Components/LedBlinker/docs/sdd.md new file mode 100644 index 0000000..fc8f77f --- /dev/null +++ b/Components/LedBlinker/docs/sdd.md @@ -0,0 +1,66 @@ +# Components::LedBlinker + +Component to blink an LED driven by a rate group + +## Usage Examples +Add usage examples here + +### Diagrams +Add diagrams here + +### Typical Usage +And the typical usage of the component here + +## Class Diagram +Add a class diagram here + +## Port Descriptions +| Name | Description | +|---|---| +|---|---| + +## Component States +Add component states in the chart below +| Name | Description | +|---|---| +|---|---| + +## Sequence Diagrams +Add sequence diagrams here + +## Parameters +| Name | Description | +|---|---| +|---|---| + +## Commands +| Name | Description | +|---|---| +|---|---| + +## Events +| Name | Description | +|---|---| +|---|---| + +## Telemetry +| Name | Description | +|---|---| +|---|---| + +## Unit Tests +Add unit test descriptions in the chart below +| Name | Description | Output | Coverage | +|---|---|---|---| +|---|---|---|---| + +## Requirements +Add requirements in the chart below +| Name | Description | Validation | +|---|---|---| +|---|---|---| + +## Change Log +| Date | Description | +|---|---| +|---| Initial Draft | diff --git a/Components/LedBlinker/test/int/led_integration_tests.py b/Components/LedBlinker/test/int/led_integration_tests.py new file mode 100644 index 0000000..35528a2 --- /dev/null +++ b/Components/LedBlinker/test/int/led_integration_tests.py @@ -0,0 +1,6 @@ +def test_cmd_no_op(fprime_test_api): + """Test command CMD_NO_OP + + Test that CMD_NO_OP can be sent and return without and errors + """ + fprime_test_api.send_and_assert_command("cmdDisp.CMD_NO_OP") diff --git a/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp b/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp new file mode 100644 index 0000000..a7feb55 --- /dev/null +++ b/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp @@ -0,0 +1,17 @@ +// ====================================================================== +// \title LedBlinkerTestMain.cpp +// \author nate +// \brief cpp file for LedBlinker component test main function +// ====================================================================== + +#include "LedBlinkerTester.hpp" + +TEST(Nominal, TestBlinking) { + Components::LedBlinkerTester tester; + tester.testBlinking(); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/Components/LedBlinker/test/ut/LedBlinkerTester.cpp b/Components/LedBlinker/test/ut/LedBlinkerTester.cpp new file mode 100644 index 0000000..a961b5f --- /dev/null +++ b/Components/LedBlinker/test/ut/LedBlinkerTester.cpp @@ -0,0 +1,55 @@ +// ====================================================================== +// \title LedBlinkerTester.cpp +// \author nate +// \brief cpp file for LedBlinker component test harness implementation class +// ====================================================================== + +#include "LedBlinkerTester.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Construction and destruction +// ---------------------------------------------------------------------- + +LedBlinkerTester ::LedBlinkerTester() + : LedBlinkerGTestBase("LedBlinkerTester", LedBlinkerTester::MAX_HISTORY_SIZE), component("LedBlinker") { + this->initComponents(); + this->connectPorts(); +} + +LedBlinkerTester ::~LedBlinkerTester() {} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void LedBlinkerTester ::testBlinking() { + // This test will make use of parameters. So need to load them. + this->component.loadParameters(); + + // Ensure LED stays off when blinking is disabled + // The Led component defaults to blinking off + this->invoke_to_run(0, 0); // invoke the 'run' port to simulate running one cycle + this->component.doDispatch(); // Trigger execution of async port + + ASSERT_EVENTS_SetBlinkingState_SIZE(0); // ensure no LedState change events we emitted + + ASSERT_from_neoPixelSet_SIZE(0); // ensure gpio LED wasn't set + + ASSERT_TLM_LedBlinks_SIZE(0); // ensure no LedTransitions were recorded +} + +// ---------------------------------------------------------------------- +// Handlers for typed from ports +// ---------------------------------------------------------------------- + +void LedBlinkerTester ::from_neoPixelSet_handler(NATIVE_INT_TYPE portNum, + const Fw::On& on_off, + U8 red, + U8 green, + U8 blue) { + // TODO +} + +} // namespace Components diff --git a/Components/LedBlinker/test/ut/LedBlinkerTester.hpp b/Components/LedBlinker/test/ut/LedBlinkerTester.hpp new file mode 100644 index 0000000..ec40ab1 --- /dev/null +++ b/Components/LedBlinker/test/ut/LedBlinkerTester.hpp @@ -0,0 +1,83 @@ +// ====================================================================== +// \title LedBlinkerTester.hpp +// \author nate +// \brief hpp file for LedBlinker component test harness implementation class +// ====================================================================== + +#ifndef Components_LedBlinkerTester_HPP +#define Components_LedBlinkerTester_HPP + +#include "Components/LedBlinker/LedBlinker.hpp" +#include "Components/LedBlinker/LedBlinkerGTestBase.hpp" + +namespace Components { + +class LedBlinkerTester : public LedBlinkerGTestBase { + public: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + // Maximum size of histories storing events, telemetry, and port outputs + static const NATIVE_INT_TYPE MAX_HISTORY_SIZE = 10; + + // Instance ID supplied to the component instance under test + static const NATIVE_INT_TYPE TEST_INSTANCE_ID = 0; + + // Queue depth supplied to the component instance under test + static const NATIVE_INT_TYPE TEST_INSTANCE_QUEUE_DEPTH = 10; + + public: + // ---------------------------------------------------------------------- + // Construction and destruction + // ---------------------------------------------------------------------- + + //! Construct object LedBlinkerTester + LedBlinkerTester(); + + //! Destroy object LedBlinkerTester + ~LedBlinkerTester(); + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! To do + void testBlinking(); + + private: + // ---------------------------------------------------------------------- + // Handlers for typed from ports + // ---------------------------------------------------------------------- + + //! Handler implementation for neoPixelSet + void from_neoPixelSet_handler(NATIVE_INT_TYPE portNum, //!< The port number + const Fw::On& on_off, + U8 red, + U8 green, + U8 blue); + + private: + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + //! Connect ports + void connectPorts(); + + //! Initialize components + void initComponents(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The component under test + LedBlinker component; +}; + +} // namespace Components + +#endif diff --git a/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp b/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp new file mode 100644 index 0000000..c3e3a1a --- /dev/null +++ b/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp @@ -0,0 +1,52 @@ +// ====================================================================== +// \title LedBlinkerTesterHelpers.cpp +// \author Generated by fpp-to-cpp +// \brief cpp file for LedBlinker component test harness helper functions +// ====================================================================== + +#include "LedBlinkerTester.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Helper functions +// ---------------------------------------------------------------------- + +void LedBlinkerTester ::connectPorts() { + // Connect special input ports + + this->connect_to_cmdIn(0, this->component.get_cmdIn_InputPort(0)); + + // Connect special output ports + + this->component.set_cmdRegOut_OutputPort(0, this->get_from_cmdRegOut(0)); + + this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); + + this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); + + this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); + + this->component.set_prmGetOut_OutputPort(0, this->get_from_prmGetOut(0)); + + this->component.set_prmSetOut_OutputPort(0, this->get_from_prmSetOut(0)); + + this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); + + this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); + + // Connect typed input ports + + this->connect_to_run(0, this->component.get_run_InputPort(0)); + + // Connect typed output ports + + this->component.set_neoPixelSet_OutputPort(0, this->get_from_neoPixelSet(0)); +} + +void LedBlinkerTester ::initComponents() { + this->init(); + this->component.init(LedBlinkerTester::TEST_INSTANCE_QUEUE_DEPTH, LedBlinkerTester::TEST_INSTANCE_ID); +} + +} // namespace Components From daeb0ff3ac9bad31dc30b98d1e64449e752be724 Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Thu, 7 Nov 2024 13:33:27 -0600 Subject: [PATCH 2/4] Removing docs dir --- Components/LedBlinker/docs/sdd.md | 66 ------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 Components/LedBlinker/docs/sdd.md diff --git a/Components/LedBlinker/docs/sdd.md b/Components/LedBlinker/docs/sdd.md deleted file mode 100644 index fc8f77f..0000000 --- a/Components/LedBlinker/docs/sdd.md +++ /dev/null @@ -1,66 +0,0 @@ -# Components::LedBlinker - -Component to blink an LED driven by a rate group - -## Usage Examples -Add usage examples here - -### Diagrams -Add diagrams here - -### Typical Usage -And the typical usage of the component here - -## Class Diagram -Add a class diagram here - -## Port Descriptions -| Name | Description | -|---|---| -|---|---| - -## Component States -Add component states in the chart below -| Name | Description | -|---|---| -|---|---| - -## Sequence Diagrams -Add sequence diagrams here - -## Parameters -| Name | Description | -|---|---| -|---|---| - -## Commands -| Name | Description | -|---|---| -|---|---| - -## Events -| Name | Description | -|---|---| -|---|---| - -## Telemetry -| Name | Description | -|---|---| -|---|---| - -## Unit Tests -Add unit test descriptions in the chart below -| Name | Description | Output | Coverage | -|---|---|---|---| -|---|---|---|---| - -## Requirements -Add requirements in the chart below -| Name | Description | Validation | -|---|---|---| -|---|---|---| - -## Change Log -| Date | Description | -|---|---| -|---| Initial Draft | From 6f0baf6ab1e391d9a5246be9e87713f589e68a42 Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Thu, 7 Nov 2024 13:34:42 -0600 Subject: [PATCH 3/4] Remove unimplemented test files --- Components/LedBlinker/CMakeLists.txt | 15 ---- .../test/int/led_integration_tests.py | 6 -- .../LedBlinker/test/ut/LedBlinkerTestMain.cpp | 17 ---- .../LedBlinker/test/ut/LedBlinkerTester.cpp | 55 ------------ .../LedBlinker/test/ut/LedBlinkerTester.hpp | 83 ------------------- .../test/ut/LedBlinkerTesterHelpers.cpp | 52 ------------ 6 files changed, 228 deletions(-) delete mode 100644 Components/LedBlinker/test/int/led_integration_tests.py delete mode 100644 Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp delete mode 100644 Components/LedBlinker/test/ut/LedBlinkerTester.cpp delete mode 100644 Components/LedBlinker/test/ut/LedBlinkerTester.hpp delete mode 100644 Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp diff --git a/Components/LedBlinker/CMakeLists.txt b/Components/LedBlinker/CMakeLists.txt index 56c1d7c..e9bc80f 100644 --- a/Components/LedBlinker/CMakeLists.txt +++ b/Components/LedBlinker/CMakeLists.txt @@ -11,19 +11,4 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.cpp" ) -# Uncomment and add any modules that this component depends on, else -# they might not be available when cmake tries to build this component. - -# set(MOD_DEPS -# Adafruit_NeoPixel -# ) - register_fprime_module() - -set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.fpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/LedBlinkerTestMain.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/LedBlinkerTester.cpp" -) -set(UT_AUTO_HELPERS ON) # Additional Unit-Test autocoding -register_fprime_ut() diff --git a/Components/LedBlinker/test/int/led_integration_tests.py b/Components/LedBlinker/test/int/led_integration_tests.py deleted file mode 100644 index 35528a2..0000000 --- a/Components/LedBlinker/test/int/led_integration_tests.py +++ /dev/null @@ -1,6 +0,0 @@ -def test_cmd_no_op(fprime_test_api): - """Test command CMD_NO_OP - - Test that CMD_NO_OP can be sent and return without and errors - """ - fprime_test_api.send_and_assert_command("cmdDisp.CMD_NO_OP") diff --git a/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp b/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp deleted file mode 100644 index a7feb55..0000000 --- a/Components/LedBlinker/test/ut/LedBlinkerTestMain.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// ====================================================================== -// \title LedBlinkerTestMain.cpp -// \author nate -// \brief cpp file for LedBlinker component test main function -// ====================================================================== - -#include "LedBlinkerTester.hpp" - -TEST(Nominal, TestBlinking) { - Components::LedBlinkerTester tester; - tester.testBlinking(); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/Components/LedBlinker/test/ut/LedBlinkerTester.cpp b/Components/LedBlinker/test/ut/LedBlinkerTester.cpp deleted file mode 100644 index a961b5f..0000000 --- a/Components/LedBlinker/test/ut/LedBlinkerTester.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// ====================================================================== -// \title LedBlinkerTester.cpp -// \author nate -// \brief cpp file for LedBlinker component test harness implementation class -// ====================================================================== - -#include "LedBlinkerTester.hpp" - -namespace Components { - -// ---------------------------------------------------------------------- -// Construction and destruction -// ---------------------------------------------------------------------- - -LedBlinkerTester ::LedBlinkerTester() - : LedBlinkerGTestBase("LedBlinkerTester", LedBlinkerTester::MAX_HISTORY_SIZE), component("LedBlinker") { - this->initComponents(); - this->connectPorts(); -} - -LedBlinkerTester ::~LedBlinkerTester() {} - -// ---------------------------------------------------------------------- -// Tests -// ---------------------------------------------------------------------- - -void LedBlinkerTester ::testBlinking() { - // This test will make use of parameters. So need to load them. - this->component.loadParameters(); - - // Ensure LED stays off when blinking is disabled - // The Led component defaults to blinking off - this->invoke_to_run(0, 0); // invoke the 'run' port to simulate running one cycle - this->component.doDispatch(); // Trigger execution of async port - - ASSERT_EVENTS_SetBlinkingState_SIZE(0); // ensure no LedState change events we emitted - - ASSERT_from_neoPixelSet_SIZE(0); // ensure gpio LED wasn't set - - ASSERT_TLM_LedBlinks_SIZE(0); // ensure no LedTransitions were recorded -} - -// ---------------------------------------------------------------------- -// Handlers for typed from ports -// ---------------------------------------------------------------------- - -void LedBlinkerTester ::from_neoPixelSet_handler(NATIVE_INT_TYPE portNum, - const Fw::On& on_off, - U8 red, - U8 green, - U8 blue) { - // TODO -} - -} // namespace Components diff --git a/Components/LedBlinker/test/ut/LedBlinkerTester.hpp b/Components/LedBlinker/test/ut/LedBlinkerTester.hpp deleted file mode 100644 index ec40ab1..0000000 --- a/Components/LedBlinker/test/ut/LedBlinkerTester.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// ====================================================================== -// \title LedBlinkerTester.hpp -// \author nate -// \brief hpp file for LedBlinker component test harness implementation class -// ====================================================================== - -#ifndef Components_LedBlinkerTester_HPP -#define Components_LedBlinkerTester_HPP - -#include "Components/LedBlinker/LedBlinker.hpp" -#include "Components/LedBlinker/LedBlinkerGTestBase.hpp" - -namespace Components { - -class LedBlinkerTester : public LedBlinkerGTestBase { - public: - // ---------------------------------------------------------------------- - // Constants - // ---------------------------------------------------------------------- - - // Maximum size of histories storing events, telemetry, and port outputs - static const NATIVE_INT_TYPE MAX_HISTORY_SIZE = 10; - - // Instance ID supplied to the component instance under test - static const NATIVE_INT_TYPE TEST_INSTANCE_ID = 0; - - // Queue depth supplied to the component instance under test - static const NATIVE_INT_TYPE TEST_INSTANCE_QUEUE_DEPTH = 10; - - public: - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - //! Construct object LedBlinkerTester - LedBlinkerTester(); - - //! Destroy object LedBlinkerTester - ~LedBlinkerTester(); - - public: - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - - //! To do - void testBlinking(); - - private: - // ---------------------------------------------------------------------- - // Handlers for typed from ports - // ---------------------------------------------------------------------- - - //! Handler implementation for neoPixelSet - void from_neoPixelSet_handler(NATIVE_INT_TYPE portNum, //!< The port number - const Fw::On& on_off, - U8 red, - U8 green, - U8 blue); - - private: - // ---------------------------------------------------------------------- - // Helper functions - // ---------------------------------------------------------------------- - - //! Connect ports - void connectPorts(); - - //! Initialize components - void initComponents(); - - private: - // ---------------------------------------------------------------------- - // Member variables - // ---------------------------------------------------------------------- - - //! The component under test - LedBlinker component; -}; - -} // namespace Components - -#endif diff --git a/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp b/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp deleted file mode 100644 index c3e3a1a..0000000 --- a/Components/LedBlinker/test/ut/LedBlinkerTesterHelpers.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// ====================================================================== -// \title LedBlinkerTesterHelpers.cpp -// \author Generated by fpp-to-cpp -// \brief cpp file for LedBlinker component test harness helper functions -// ====================================================================== - -#include "LedBlinkerTester.hpp" - -namespace Components { - -// ---------------------------------------------------------------------- -// Helper functions -// ---------------------------------------------------------------------- - -void LedBlinkerTester ::connectPorts() { - // Connect special input ports - - this->connect_to_cmdIn(0, this->component.get_cmdIn_InputPort(0)); - - // Connect special output ports - - this->component.set_cmdRegOut_OutputPort(0, this->get_from_cmdRegOut(0)); - - this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); - - this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); - - this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); - - this->component.set_prmGetOut_OutputPort(0, this->get_from_prmGetOut(0)); - - this->component.set_prmSetOut_OutputPort(0, this->get_from_prmSetOut(0)); - - this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); - - this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); - - // Connect typed input ports - - this->connect_to_run(0, this->component.get_run_InputPort(0)); - - // Connect typed output ports - - this->component.set_neoPixelSet_OutputPort(0, this->get_from_neoPixelSet(0)); -} - -void LedBlinkerTester ::initComponents() { - this->init(); - this->component.init(LedBlinkerTester::TEST_INSTANCE_QUEUE_DEPTH, LedBlinkerTester::TEST_INSTANCE_ID); -} - -} // namespace Components From 43bb292885da84cb879130f7944d9074b6fe096c Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Mon, 24 Feb 2025 18:36:31 -0600 Subject: [PATCH 4/4] empty