From 2a5dba39de076ec7af3739aba42d321bf67ab5c5 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 27 Mar 2024 18:37:58 -0700 Subject: [PATCH 01/36] 2604: SDD in Progress --- Svc/CMakeLists.txt | 1 + Svc/Version/CMakeLists.txt | 22 ++++++++++++ Svc/Version/Version.cpp | 29 ++++++++++++++++ Svc/Version/Version.fpp | 55 ++++++++++++++++++++++++++++++ Svc/Version/Version.hpp | 36 ++++++++++++++++++++ Svc/Version/docs/sdd.md | 70 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 213 insertions(+) create mode 100644 Svc/Version/CMakeLists.txt create mode 100644 Svc/Version/Version.cpp create mode 100644 Svc/Version/Version.fpp create mode 100644 Svc/Version/Version.hpp create mode 100644 Svc/Version/docs/sdd.md diff --git a/Svc/CMakeLists.txt b/Svc/CMakeLists.txt index 175654cccc..0783471c41 100644 --- a/Svc/CMakeLists.txt +++ b/Svc/CMakeLists.txt @@ -56,3 +56,4 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwi add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/") endif() +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Version/") diff --git a/Svc/Version/CMakeLists.txt b/Svc/Version/CMakeLists.txt new file mode 100644 index 0000000000..3a52208a05 --- /dev/null +++ b/Svc/Version/CMakeLists.txt @@ -0,0 +1,22 @@ +#### +# 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}/Version.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Version.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 + Os + version +) + +register_fprime_module() diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp new file mode 100644 index 0000000000..8077fc3061 --- /dev/null +++ b/Svc/Version/Version.cpp @@ -0,0 +1,29 @@ +// ====================================================================== +// \title Version.cpp +// \author sreddy +// \brief cpp file for Version component implementation class +// ====================================================================== + +#include "FpConfig.hpp" +#include "Svc/Version/Version.hpp" + +namespace Svc { + + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + Version :: + Version(const char* const compName) : + VersionComponentBase(compName) + { + + } + + Version :: + ~Version() + { + + } + +} diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp new file mode 100644 index 0000000000..12a9d622ec --- /dev/null +++ b/Svc/Version/Version.fpp @@ -0,0 +1,55 @@ +module Svc { + @ Tracks veramework, user defined versions etc + passive component Version { + + ############################################################################## + #### Uncomment the following examples to start customizing your component #### + ############################################################################## + + # @ Example async command + # async command COMMAND_NAME(param_name: U32) + + # @ Example telemetry counter + # telemetry ExampleCounter: U64 + + # @ Example event + # event ExampleStateEvent(example_state: Fw.On) severity activity high id 0 format "State set to {}" + + # @ Example port: receiving calls from the rate group + # sync input port run: Svc.Sched + + # @ Example parameter + # param PARAMETER_NAME: U32 + + ############################################################################### + # 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 + + } +} \ No newline at end of file diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp new file mode 100644 index 0000000000..191c1099fd --- /dev/null +++ b/Svc/Version/Version.hpp @@ -0,0 +1,36 @@ +// ====================================================================== +// \title Version.hpp +// \author sreddy +// \brief hpp file for Version component implementation class +// ====================================================================== + +#ifndef Svc_Version_HPP +#define Svc_Version_HPP + +#include "Svc/Version/VersionComponentAc.hpp" + +namespace Svc { + + class Version : + public VersionComponentBase + { + + public: + + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Version object + Version( + const char* const compName //!< The component name + ); + + //! Destroy Version object + ~Version(); + + }; + +} + +#endif diff --git a/Svc/Version/docs/sdd.md b/Svc/Version/docs/sdd.md new file mode 100644 index 0000000000..e0b5c84b29 --- /dev/null +++ b/Svc/Version/docs/sdd.md @@ -0,0 +1,70 @@ +# Svc::Version + +Tracks versions for framework,project, libraries and user defined project specific versions. + +## 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 + +| Name | Description | Validation | +|---|---|---| +|SVC-VERSION-001|`Svc::Version` shall create an EVR indicating versions of framework, project and libary at start-up and on command| This is to provide transparency to users on versions being used| +|SVC-VERSION-002|`Svc::Version` shall provide a telemetry channel on framework version| Accessiblity to versions being used| +|SVC-VERSION-003|`Svc::Version` shall provide a telemetry channel on project version| Accessiblity to versions being used| +|SVC-VERSION-004|`Svc::Version` shall provide a telemetry channel on library version| Accessiblity to versions being used| +|SVC-VERSION-005|`Svc::Version` shall provide an interface for users to set custom versions.| Enables projects to set hardware and FPGA versions as needed| + +## Change Log +| Date | Description | +|---|---| +|---| Initial Draft | \ No newline at end of file From 2e6715497faeac669501e403658ca7b057d33d59 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 9 Apr 2024 18:28:57 -0700 Subject: [PATCH 02/36] 2604: Fixed bug in version --- .../Python/src/fprime_ac/utils/version.py | 8 ++- Svc/Version/Version.cpp | 53 ++++++++++++++++- Svc/Version/Version.fpp | 59 ++++++++++++++----- Svc/Version/Version.hpp | 37 ++++++++++++ cmake/target/version.cmake | 2 +- .../target/version/generate_version_header.py | 3 +- 6 files changed, 141 insertions(+), 21 deletions(-) diff --git a/Autocoders/Python/src/fprime_ac/utils/version.py b/Autocoders/Python/src/fprime_ac/utils/version.py index 6fe5104d30..bad88ae5f5 100644 --- a/Autocoders/Python/src/fprime_ac/utils/version.py +++ b/Autocoders/Python/src/fprime_ac/utils/version.py @@ -20,6 +20,8 @@ def get_version_str(working_dir, fallback=FALLBACK_VERSION): output = subprocess.check_output( ["git", "describe", "--tags", "--always"], cwd=working_dir ) + #print ("Msg3: output string : ",output) + #print ("Msg4: output string reformatted: ",output.strip().decode("ascii")) return output.strip().decode("ascii") except Exception: return fallback @@ -35,8 +37,9 @@ def get_fprime_version(): Version of fprime framework """ fprime_directory = os.environ.get( - "FPRIME_FRAMEWORK_PATH", os.path.dirname(__file__) - ) + "FPRIME_FRAMEWORK_PATH", os.path.dirname(__file__)) + #print("Msg1: fprime_directory for version: ", fprime_directory) + return get_version_str(working_dir=fprime_directory, fallback=FALLBACK_VERSION) @@ -53,4 +56,5 @@ def get_project_version(fallback=FALLBACK_VERSION): Version of fprime framework """ fprime_directory = os.environ.get("FPRIME_PROJECT_ROOT", os.path.dirname(__file__)) + #print("Msg1: fprime_directory for project : ", fprime_directory, "and _file_ : ",__file__) return get_version_str(working_dir=fprime_directory, fallback=fallback) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 8077fc3061..05aca609b0 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -6,6 +6,7 @@ #include "FpConfig.hpp" #include "Svc/Version/Version.hpp" +#include //autogenerated file containing hardcoded project and framework versions namespace Svc { @@ -15,7 +16,7 @@ namespace Svc { Version :: Version(const char* const compName) : - VersionComponentBase(compName) + VersionComponentBase(compName), m_enable(true) { } @@ -26,4 +27,54 @@ namespace Svc { } +// ---------------------------------------------------------------------- +// Handler implementations for user-defined typed input ports +// ---------------------------------------------------------------------- + +void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { + if(m_enable) { + Version_tlm(); + } +} + + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + void Version :: + ENABLE_cmdHandler( + FwOpcodeType opCode, + U32 cmdSeq, + Svc::VersionEnabled enable + ) + { + m_enable = (enable == VersionEnabled::ENABLED); + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); + } + + //Command handler to EVR versions + void Version :: + VERSION_cmdHandler( + FwOpcodeType opCode, + U32 cmdSeq + ) + { + Fw::LogStringArg version_string(FRAMEWORK_VERSION); + this->log_ACTIVITY_LO_FRAMEWORK_VERSION(version_string); + + version_string = PROJECT_VERSION; + this->log_ACTIVITY_LO_PROJECT_VERSION(version_string); + + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); + } + + //function to log tlm on versions + void Version :: Version_tlm() { + Fw::TlmString version_string(FRAMEWORK_VERSION); + this->tlmWrite_FRAMEWORK_VERSION(version_string); + + version_string = PROJECT_VERSION; + this->tlmWrite_PROJECT_VERSION(version_string); + } + } diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 12a9d622ec..1f92073f85 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -1,25 +1,52 @@ module Svc { - @ Tracks veramework, user defined versions etc + + @ Tracks versions for project, framework and user defined versions etc + + enum VersionEnabled { + DISABLED = 0 + ENABLED = 1 + } + passive component Version { ############################################################################## #### Uncomment the following examples to start customizing your component #### ############################################################################## - - # @ Example async command - # async command COMMAND_NAME(param_name: U32) - - # @ Example telemetry counter - # telemetry ExampleCounter: U64 - - # @ Example event - # event ExampleStateEvent(example_state: Fw.On) severity activity high id 0 format "State set to {}" - - # @ Example port: receiving calls from the rate group - # sync input port run: Svc.Sched - - # @ Example parameter - # param PARAMETER_NAME: U32 + + @ Run port + guarded input port run: [1] Svc.Sched + + @ A command to enable or disable Version telemetry + guarded command ENABLE( + enable: VersionEnabled @< whether or not Version telemetry is enabled + ) \ + opcode 0 + + @ Report version as EVR + guarded command VERSION \ + opcode 1 + + @ Version of the git repository. + event FRAMEWORK_VERSION( + version: string size 40 @< version string + ) \ + severity activity low \ + id 0 \ + format "Framework Version: [{}]" + + @ Version of the git repository. + event PROJECT_VERSION( + version: string size 40 @< version string + ) \ + severity activity low \ + id 1 \ + format "Project Version: [{}]" + + @ Software framework version + telemetry FRAMEWORK_VERSION: string size 40 id 0 + + @ Software project version + telemetry PROJECT_VERSION: string size 40 id 1 ############################################################################### # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 191c1099fd..52a74feba2 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -29,6 +29,43 @@ namespace Svc { //! Destroy Version object ~Version(); + PRIVATE: + // ---------------------------------------------------------------------- + // Handler implementations for user-defined typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for run + //! + void + run_handler(const NATIVE_INT_TYPE portNum, /*!< The port number*/ + U32 context /*!< The call order*/ + ) override; + + private: + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + //! Handler implementation for command ENABLE + //! + //! A command to enable or disable Version telemetry + void ENABLE_cmdHandler( + FwOpcodeType opCode, //!< The opcode + U32 cmdSeq, //!< The command sequence number + Svc::VersionEnabled enable //!< whether or not Version telemetry is enabled + ) override; + + //! Handler implementation for command VERSION + //! + //! Report version as EVR + void VERSION_cmdHandler( + FwOpcodeType opCode, //!< The opcode + U32 cmdSeq //!< The command sequence number + ) override; + + private: + void Version_tlm(); + bool m_enable; /*!*/ }; } diff --git a/cmake/target/version.cmake b/cmake/target/version.cmake index 6d21cfd325..edbfec06b1 100644 --- a/cmake/target/version.cmake +++ b/cmake/target/version.cmake @@ -14,7 +14,7 @@ function(version_add_global_target TARGET) endif() add_custom_target("${TARGET}" ALL BYPRODUCTS "${OUTPUT_FILE}" COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${PYTHONPATH}:${FPRIME_FRAMEWORK_PATH}/Autocoders/Python/src" - "${FPRIME_VERSION_SCRIPT}" "${OUTPUT_FILE}.tmp" "${OPTIONAL_CHECK_ARG}" + "FPRIME_PROJECT_ROOT=${FPRIME_PROJECT_ROOT}" "FPRIME_FRAMEWORK_PATH=${FPRIME_FRAMEWORK_PATH}" "${FPRIME_VERSION_SCRIPT}" "${OUTPUT_FILE}.tmp" "${OPTIONAL_CHECK_ARG}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OUTPUT_FILE}.tmp" "${OUTPUT_FILE}" WORKING_DIRECTORY "${FPRIME_PROJECT_ROOT}" ) diff --git a/cmake/target/version/generate_version_header.py b/cmake/target/version/generate_version_header.py index 9ed5bafe1c..5428040c85 100755 --- a/cmake/target/version/generate_version_header.py +++ b/cmake/target/version/generate_version_header.py @@ -47,7 +47,7 @@ def create_version_file(fid, framework_version, project_version): fid.write( 'static const char* FRAMEWORK_VERSION = "{}";\n'.format(framework_version) ) - fid.write('static const char* PROJECT_VERSION = "{}";\n'.format(framework_version)) + fid.write('static const char* PROJECT_VERSION = "{}";\n'.format(project_version)) fid.write("\n") fid.write("#endif\n") fid.write("\n") @@ -76,6 +76,7 @@ def main(): # Build the version output fprime_version = get_fprime_version() project_version = get_project_version() + #print("Project Version: ",project_version) create_version_file(args.output, fprime_version, project_version) # Check version if asked to do so From 25ede54f21c03c46eac0af78d27661ee11663146 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 23 Apr 2024 17:25:24 -0700 Subject: [PATCH 03/36] 2604: Updates to user defined versions --- Svc/Version/Version.cpp | 32 +++++++++++++++++++++++++++++++- Svc/Version/Version.fpp | 19 +++++++++++++++++++ Svc/Version/Version.hpp | 35 ++++++++++++++++++++++++++++++++++- config/CMakeLists.txt | 1 + config/VersionCfg.fpp | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 config/VersionCfg.fpp diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 05aca609b0..94582c8ece 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -18,7 +18,10 @@ namespace Svc { Version(const char* const compName) : VersionComponentBase(compName), m_enable(true) { - + // initialize all entries to stale + for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { + this->verId_db[id].status = VersionStatus::FAILURE; + } } Version :: @@ -37,6 +40,33 @@ void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { } } +void Version :: + getVersion_handler( + FwIndexType portNum, + const Svc::VersionCfg::VersionEnum& version_id, + Svc::VersPortStrings::StringSize80& version_string, + Svc::VersionStatus& status + ) + { + FW_ASSERT(version_id.isValid(),version_id.e); + version_string = this->verId_db[version_id.e].val; + status = this->verId_db[version_id.e].status ; + + } + + void Version :: + setVersion_handler( + FwIndexType portNum, + const Svc::VersionCfg::VersionEnum& version_id, + Svc::VersPortStrings::StringSize80& version_string, + Svc::VersionStatus& status + ) + { + FW_ASSERT(version_id.isValid(),version_id.e); + this->verId_db[version_id.e].val = version_string; + this->verId_db[version_id.e].status = status; + + } // ---------------------------------------------------------------------- // Handler implementations for commands // ---------------------------------------------------------------------- diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 1f92073f85..7f51c0235d 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -6,7 +6,20 @@ module Svc { DISABLED = 0 ENABLED = 1 } + + @ An enumeration for version status + enum VersionStatus { + OK = 0 @< Version was good + FAILURE = 1 @< Failure to get version + } + @ Port for setting and getting Versions + port Vers( + version_id: VersionCfg.VersionEnum @< The entry to access + ref version_string: string @< The value to be passed + ref status: VersionStatus @< The command response argument + ) + passive component Version { ############################################################################## @@ -15,6 +28,12 @@ module Svc { @ Run port guarded input port run: [1] Svc.Sched + + @ Mutexed Port to get values + guarded input port getVersion: Svc.Vers + + @ Mutexed Port to set values + guarded input port setVersion: Svc.Vers @ A command to enable or disable Version telemetry guarded command ENABLE( diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 52a74feba2..3e10ca971e 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -22,7 +22,7 @@ namespace Svc { // ---------------------------------------------------------------------- //! Construct Version object - Version( + explicit Version( const char* const compName //!< The component name ); @@ -40,7 +40,40 @@ namespace Svc { run_handler(const NATIVE_INT_TYPE portNum, /*!< The port number*/ U32 context /*!< The call order*/ ) override; + + //! Handler implementation for getVersion + //! + //! Mutexed Port to get values + void getVersion_handler( + FwIndexType portNum, //!< The port number + const Svc::VersionCfg::VersionEnum& version_id, //!< The entry to access + Svc::VersPortStrings::StringSize80& version_string, //!< The value to be passed + Svc::VersionStatus& status //!< The command response argument + ) override; + + //! Handler implementation for setVersion + //! + //! Mutexed Port to set values + void setVersion_handler( + FwIndexType portNum, //!< The port number + const Svc::VersionCfg::VersionEnum& version_id, //!< The entry to access + Svc::VersPortStrings::StringSize80& version_string, //!< The value to be passed + Svc::VersionStatus& status //!< The command response argument + ) override; + + //! \struct t_dbStruct + //! \brief PolyDb database structure + //! + //! This structure stores the latest values of the measurements. + //! The statuses are all initialized to MeasurementStatus::STALE by the constructor. + //! + + struct verArr { + VersionStatus status; //!< last status of measurement + VersPortStrings::StringSize80 val; //!< the last value of the measurement + } verId_db[Svc::VersionCfg::VersionEnum::NUM_CONSTANTS]; + private: // ---------------------------------------------------------------------- // Handler implementations for commands diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index e45152b631..a63d68471d 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -8,5 +8,6 @@ set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/DpCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/FpConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/PolyDbCfg.fpp" + "${CMAKE_CURRENT_LIST_DIR}/VersionCfg.fpp" ) register_fprime_module(config) diff --git a/config/VersionCfg.fpp b/config/VersionCfg.fpp new file mode 100644 index 0000000000..b990d8f699 --- /dev/null +++ b/config/VersionCfg.fpp @@ -0,0 +1,34 @@ +# ====================================================================== +# FPP file for Version configuration +# ====================================================================== + +module Svc { + + module VersionCfg { + + @ Define a set of PolyDb entries on a project-specific + @ basis. + enum VersionEnum: U32 { + @ Entry 0 + PROJECT_VERSION_00 + @ Entry 1 + PROJECT_VERSION_01 + @ Entry 2 + PROJECT_VERSION_03 + @ Entry 4 + PROJECT_VERSION_04 + @ Entry 5 + PROJECT_VERSION_05 + @ Entry 6 + PROJECT_VERSION_06 + @ Entry 7 + PROJECT_VERSION_07 + @ Entry 8 + PROJECT_VERSION_08 + @ Entry 9 + PROJECT_VERSION_09 + } + + } + +} \ No newline at end of file From 8d30c55ae2f103d952ef4b8a1dd81f0db3851f07 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Thu, 9 May 2024 17:31:50 -0700 Subject: [PATCH 04/36] FP-2604: Updates to Version module and UTs --- Svc/Version/CMakeLists.txt | 8 + Svc/Version/Version.cpp | 8 + Svc/Version/Version.fpp | 9 + Svc/Version/Version.hpp | 1 + Svc/Version/test/ut/VersionTestMain.cpp | 27 +++ Svc/Version/test/ut/VersionTester.cpp | 168 +++++++++++++++++++ Svc/Version/test/ut/VersionTester.hpp | 91 ++++++++++ Svc/Version/test/ut/VersionTesterHelpers.cpp | 82 +++++++++ config/VersionCfg.fpp | 2 + 9 files changed, 396 insertions(+) create mode 100644 Svc/Version/test/ut/VersionTestMain.cpp create mode 100644 Svc/Version/test/ut/VersionTester.cpp create mode 100644 Svc/Version/test/ut/VersionTester.hpp create mode 100644 Svc/Version/test/ut/VersionTesterHelpers.cpp diff --git a/Svc/Version/CMakeLists.txt b/Svc/Version/CMakeLists.txt index 3a52208a05..49072b3df7 100644 --- a/Svc/Version/CMakeLists.txt +++ b/Svc/Version/CMakeLists.txt @@ -20,3 +20,11 @@ set(MOD_DEPS ) register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Version.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/VersionTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/VersionTestMain.cpp" +) +set (UT_AUTO_HELPERS ON) +register_fprime_ut() diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 94582c8ece..c8f956e55c 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -18,8 +18,11 @@ namespace Svc { Version(const char* const compName) : VersionComponentBase(compName), m_enable(true) { + startup_done = false; + Svc::VersPortStrings::StringSize80 ver_str = "no_ver"; // initialize all entries to stale for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { + this->verId_db[id].val = ver_str; this->verId_db[id].status = VersionStatus::FAILURE; } } @@ -37,6 +40,11 @@ namespace Svc { void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { if(m_enable) { Version_tlm(); + //TODO: Need to add libraries and user defined versions here as well + if (startup_done == false) { //Send EVR once at startup + this->log_ACTIVITY_LO_STARTUP_EVR((PROJECT_VERSION),(FRAMEWORK_VERSION)); + startup_done = true; + } } } diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 7f51c0235d..5b4677a59b 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -45,6 +45,15 @@ module Svc { guarded command VERSION \ opcode 1 + @ Version of the git repository. + event STARTUP_EVR( + proj_version: string size 40 @< project version + frm_version: string size 40 @< framework version + ) \ + severity activity low \ + id 2 \ + format "Project Version: [{}] Framework Version: [{}]" + @ Version of the git repository. event FRAMEWORK_VERSION( version: string size 40 @< version string diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 3e10ca971e..5ebd5b12ac 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -99,6 +99,7 @@ namespace Svc { private: void Version_tlm(); bool m_enable; /*!*/ + bool startup_done; }; } diff --git a/Svc/Version/test/ut/VersionTestMain.cpp b/Svc/Version/test/ut/VersionTestMain.cpp new file mode 100644 index 0000000000..b90ab2bdfe --- /dev/null +++ b/Svc/Version/test/ut/VersionTestMain.cpp @@ -0,0 +1,27 @@ +// ====================================================================== +// \title VersionTestMain.cpp +// \author sreddy +// \brief cpp file for Version component test main function +// ====================================================================== + +#include "VersionTester.hpp" + +TEST(Nominal, test_startup) { + Svc::VersionTester tester; + tester.test_startup(); +} + +TEST(Nominal, test_ports) { + Svc::VersionTester tester; + tester.test_ports(); +} + +TEST(Nominal, test_cmds) { + Svc::VersionTester tester; + tester.test_commands(); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp new file mode 100644 index 0000000000..0b321fa599 --- /dev/null +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -0,0 +1,168 @@ +// ====================================================================== +// \title VersionTester.cpp +// \author sreddy +// \brief cpp file for Version component test harness implementation class +// ====================================================================== + +#include "VersionTester.hpp" +#include + +namespace Svc { + + // ---------------------------------------------------------------------- + // Construction and destruction + // ---------------------------------------------------------------------- + + VersionTester :: + VersionTester() : + VersionGTestBase("VersionTester", VersionTester::MAX_HISTORY_SIZE), + component("Version") + { + this->initComponents(); + this->connectPorts(); + } + + VersionTester :: + ~VersionTester() + { + + } + + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + // ---------------------------------------------------------------------- + // Test STARTUP + // ---------------------------------------------------------------------- + void VersionTester :: test_startup() { + this->invoke_to_run(0,0); + ASSERT_EVENTS_STARTUP_EVR_SIZE(1); + ASSERT_EVENTS_STARTUP_EVR(0,FRAMEWORK_VERSION,PROJECT_VERSION); + } + + // ---------------------------------------------------------------------- + // Test Commands + // ---------------------------------------------------------------------- + void VersionTester :: + test_enable() + { + U32 cmd_seq = 9; + this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::DISABLED); + this->invoke_to_run(0,0); + ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + + cmd_seq = 9; + this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::ENABLED); + this->invoke_to_run(0,0); + ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + ASSERT_TLM_FRAMEWORK_VERSION(0, FRAMEWORK_VERSION); + ASSERT_TLM_PROJECT_VERSION(0, PROJECT_VERSION); + } + + void VersionTester :: + test_versions() + { + U32 cmd_seq = 9; + this->sendCmd_VERSION(0,cmd_seq); + this->invoke_to_run(0,0); + ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); + ASSERT_EVENTS_FRAMEWORK_VERSION(0, FRAMEWORK_VERSION); + } + + void VersionTester :: test_commands() { + this->test_enable(); + this->test_versions(); + } + + // ---------------------------------------------------------------------- + // Test User Ports + // ---------------------------------------------------------------------- + + void VersionTester :: test_setVer() { + + Svc::VersionStatus status = Svc::VersionStatus::OK; + Svc::VersPortStrings::StringSize80 set_ver_0 = "ver_0"; + Svc::VersPortStrings::StringSize80 set_ver_6 = "ver_6"; + Svc::VersPortStrings::StringSize80 set_ver_3 = "ver_3"; + Svc::VersPortStrings::StringSize80 set_ver_9 = "ver_9"; + + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver_0, status); + status = Svc::VersionStatus::FAILURE; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver_3, status); + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver_6, status); + status = Svc::VersionStatus::OK; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver_9, status); + } + + void VersionTester :: test_getVer() { + + Svc::VersionStatus status; + Svc::VersPortStrings::StringSize80 get_ver; + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, get_ver, status); + ASSERT_EQ(get_ver,"ver_0"); + ASSERT_EQ(status,Svc::VersionStatus::OK); + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, get_ver, status); + ASSERT_EQ(get_ver,"ver_3"); + ASSERT_EQ(status,Svc::VersionStatus::FAILURE); + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, get_ver, status); + ASSERT_EQ(get_ver,"ver_6"); + ASSERT_EQ(status,Svc::VersionStatus::FAILURE); + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, get_ver, status); + ASSERT_EQ(get_ver,"ver_9"); + ASSERT_EQ(status,Svc::VersionStatus::OK); + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, get_ver, status); + ASSERT_EQ(get_ver,"no_ver"); + ASSERT_EQ(status,Svc::VersionStatus::FAILURE); + } + + void VersionTester::test_ports() { + this->test_setVer(); + this->test_getVer(); + } + + +// ---------------------------------------------------------------------- +// Helper methods +// ---------------------------------------------------------------------- + /* + void VersionTester::connectPorts() { + // Connect custom ports + this->connect_to_run(0, this->component.get_run_InputPort(0)); + this->connect_to_getVersion (0, this->component.get_getVersion_InputPort(0)); + this->connect_to_setVersion (0, this->component.get_setVersion_InputPort(0)); + + // CmdIn + this->connect_to_cmdIn (0, this->component.get_cmdIn_InputPort(0)); + + // CmdReg + this->component.set_cmdRegOut_OutputPort(0,this->get_from_cmdRegOut(0)); + + // CmdStatus + this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); + + // Tlm + this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); + + // Time + this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); + + // Log + this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); + + // LogText + this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); + } + + void VersionTester::initComponents() { + this->init(); + this->component.init(0); + } + */ +} \ No newline at end of file diff --git a/Svc/Version/test/ut/VersionTester.hpp b/Svc/Version/test/ut/VersionTester.hpp new file mode 100644 index 0000000000..e96aaeb8c3 --- /dev/null +++ b/Svc/Version/test/ut/VersionTester.hpp @@ -0,0 +1,91 @@ +// ====================================================================== +// \title VersionTester.hpp +// \author sreddy +// \brief hpp file for Version component test harness implementation class +// ====================================================================== + +#ifndef Svc_VersionTester_HPP +#define Svc_VersionTester_HPP + +#include "Svc/Version/VersionGTestBase.hpp" +#include "Svc/Version/Version.hpp" + +namespace Svc { + + class VersionTester : + public VersionGTestBase + { + + public: + + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + // Maximum size of histories storing events, telemetry, and port outputs + static const FwSizeType MAX_HISTORY_SIZE = 10; + + // Instance ID supplied to the component instance under test + static const FwEnumStoreType TEST_INSTANCE_ID = 0; + + public: + + // ---------------------------------------------------------------------- + // Construction and destruction + // ---------------------------------------------------------------------- + + //! Construct object VersionTester + VersionTester(); + + //! Destroy object VersionTester + ~VersionTester(); + + public: + + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! test startup EVR + void test_startup(); + + //! test enable command + void test_enable(); + //! test version command + void test_versions(); + //! test all commands + void test_commands(); + + //! test get version + void test_getVer(); + //! test set version + void test_setVer(); + //!test all ports + void test_ports(); + + private: + + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + //! Connect ports + void connectPorts(); + + //! Initialize components + void initComponents(); + + private: + + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The component under test + Version component; + + }; + +} + +#endif diff --git a/Svc/Version/test/ut/VersionTesterHelpers.cpp b/Svc/Version/test/ut/VersionTesterHelpers.cpp new file mode 100644 index 0000000000..dcced4dbde --- /dev/null +++ b/Svc/Version/test/ut/VersionTesterHelpers.cpp @@ -0,0 +1,82 @@ +// ====================================================================== +// \title VersionTesterHelpers.cpp +// \author Generated by fpp-to-cpp +// \brief cpp file for Version component test harness helper functions +// ====================================================================== + +#include "VersionTester.hpp" + +namespace Svc { + + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + void VersionTester :: + 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_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_getVersion( + 0, + this->component.get_getVersion_InputPort(0) + ); + + this->connect_to_run( + 0, + this->component.get_run_InputPort(0) + ); + + this->connect_to_setVersion( + 0, + this->component.get_setVersion_InputPort(0) + ); + } + + void VersionTester :: + initComponents() + { + this->init(); + this->component.init(VersionTester::TEST_INSTANCE_ID); + } + +} diff --git a/config/VersionCfg.fpp b/config/VersionCfg.fpp index b990d8f699..09795464ff 100644 --- a/config/VersionCfg.fpp +++ b/config/VersionCfg.fpp @@ -14,6 +14,8 @@ module Svc { @ Entry 1 PROJECT_VERSION_01 @ Entry 2 + PROJECT_VERSION_02 + @ Entry 3 PROJECT_VERSION_03 @ Entry 4 PROJECT_VERSION_04 From d1c48ca3227258b7232ba1637859d7482420a769 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Thu, 9 May 2024 19:25:53 -0700 Subject: [PATCH 05/36] FP-2604 : Updates based on changes made by Thomas to version.hpp --- Svc/Version/Version.cpp | 12 ++++++------ Svc/Version/test/ut/VersionTester.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index c8f956e55c..628f10889c 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -6,7 +6,7 @@ #include "FpConfig.hpp" #include "Svc/Version/Version.hpp" -#include //autogenerated file containing hardcoded project and framework versions +#include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions namespace Svc { @@ -42,7 +42,7 @@ void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { Version_tlm(); //TODO: Need to add libraries and user defined versions here as well if (startup_done == false) { //Send EVR once at startup - this->log_ACTIVITY_LO_STARTUP_EVR((PROJECT_VERSION),(FRAMEWORK_VERSION)); + this->log_ACTIVITY_LO_STARTUP_EVR(Fw::LogStringArg(Project::Version::PROJECT_VERSION),Fw::LogStringArg(Project::Version::FRAMEWORK_VERSION)); startup_done = true; } } @@ -97,10 +97,10 @@ void Version :: U32 cmdSeq ) { - Fw::LogStringArg version_string(FRAMEWORK_VERSION); + Fw::LogStringArg version_string(Project::Version::FRAMEWORK_VERSION); this->log_ACTIVITY_LO_FRAMEWORK_VERSION(version_string); - version_string = PROJECT_VERSION; + version_string = Project::Version::PROJECT_VERSION; this->log_ACTIVITY_LO_PROJECT_VERSION(version_string); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); @@ -108,10 +108,10 @@ void Version :: //function to log tlm on versions void Version :: Version_tlm() { - Fw::TlmString version_string(FRAMEWORK_VERSION); + Fw::TlmString version_string(Project::Version::FRAMEWORK_VERSION); this->tlmWrite_FRAMEWORK_VERSION(version_string); - version_string = PROJECT_VERSION; + version_string = Project::Version::PROJECT_VERSION; this->tlmWrite_PROJECT_VERSION(version_string); } diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 0b321fa599..5d1f9edad1 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -5,7 +5,7 @@ // ====================================================================== #include "VersionTester.hpp" -#include +#include "versions/version.hpp" namespace Svc { @@ -38,7 +38,7 @@ namespace Svc { void VersionTester :: test_startup() { this->invoke_to_run(0,0); ASSERT_EVENTS_STARTUP_EVR_SIZE(1); - ASSERT_EVENTS_STARTUP_EVR(0,FRAMEWORK_VERSION,PROJECT_VERSION); + ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); } // ---------------------------------------------------------------------- @@ -56,8 +56,8 @@ namespace Svc { this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::ENABLED); this->invoke_to_run(0,0); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); - ASSERT_TLM_FRAMEWORK_VERSION(0, FRAMEWORK_VERSION); - ASSERT_TLM_PROJECT_VERSION(0, PROJECT_VERSION); + ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); } void VersionTester :: @@ -68,7 +68,7 @@ namespace Svc { this->invoke_to_run(0,0); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); - ASSERT_EVENTS_FRAMEWORK_VERSION(0, FRAMEWORK_VERSION); + ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); } void VersionTester :: test_commands() { From 5d50140f585c819e4933e7792ee431873a713086 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 21 May 2024 14:04:03 -0700 Subject: [PATCH 06/36] FP-2604: Updates to Version based on conversations with Tim and Michael --- Ref/Top/RefTopology.cpp | 2 + Svc/Version/Version.cpp | 212 +++++++++++++++++++++++++++++++++++----- Svc/Version/Version.fpp | 85 +++++++++++++--- Svc/Version/Version.hpp | 54 +++++++--- 4 files changed, 306 insertions(+), 47 deletions(-) diff --git a/Ref/Top/RefTopology.cpp b/Ref/Top/RefTopology.cpp index 3627ca9b15..8b3025d1cd 100644 --- a/Ref/Top/RefTopology.cpp +++ b/Ref/Top/RefTopology.cpp @@ -156,6 +156,8 @@ void setupTopology(const TopologyState& state) { loadParameters(); // Autocoded task kick-off (active components). Function provided by autocoder. startTasks(state); + // Startup TLM and Config verbosity for Versions + Version.Config(true); // Initialize socket client communication if and only if there is a valid specification if (state.hostname != nullptr && state.port != 0) { Os::TaskString name("ReceiveTask"); diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 628f10889c..35fb6e2b76 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -16,14 +16,17 @@ namespace Svc { Version :: Version(const char* const compName) : - VersionComponentBase(compName), m_enable(true) + VersionComponentBase(compName) { startup_done = false; + num_lib_elem = 0; + num_cus_elem = 0; Svc::VersPortStrings::StringSize80 ver_str = "no_ver"; - // initialize all entries to stale + // initialize all entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { - this->verId_db[id].val = ver_str; - this->verId_db[id].status = VersionStatus::FAILURE; + //setver_enum is by default set to the first enum value, so not setting it here + verId_db[id].setver_val(ver_str); + verId_db[id].setver_status(VersionStatus::FAILURE); } } @@ -32,11 +35,22 @@ namespace Svc { { } + + void Version::Config(bool enable) { + //Set Verbosity for custom versions + m_enable = enable; + + //Setup and send startup TLM + this->proc_libver(); + this->FwVer_tlm(); + this->ProjVer_tlm(); + this->LibVer_tlm(); + } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- - +/* void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { if(m_enable) { Version_tlm(); @@ -47,6 +61,7 @@ void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { } } } +*/ void Version :: getVersion_handler( @@ -57,9 +72,9 @@ void Version :: ) { FW_ASSERT(version_id.isValid(),version_id.e); - version_string = this->verId_db[version_id.e].val; - status = this->verId_db[version_id.e].status ; - + version_string = this->verId_db[version_id.e].getver_val(); + status = this->verId_db[version_id.e].getver_status() ; + this->CusVer_tlm(); } void Version :: @@ -71,9 +86,11 @@ void Version :: ) { FW_ASSERT(version_id.isValid(),version_id.e); - this->verId_db[version_id.e].val = version_string; - this->verId_db[version_id.e].status = status; - + this->verId_db[version_id.e].setver_enum(version_id); + this->verId_db[version_id.e].setver_val(version_string); + this->verId_db[version_id.e].setver_status(status); + this->proc_cusver(); + this->CusVer_tlm(); } // ---------------------------------------------------------------------- // Handler implementations for commands @@ -94,25 +111,174 @@ void Version :: void Version :: VERSION_cmdHandler( FwOpcodeType opCode, - U32 cmdSeq + U32 cmdSeq, + Svc::VersionType version_type ) { - Fw::LogStringArg version_string(Project::Version::FRAMEWORK_VERSION); - this->log_ACTIVITY_LO_FRAMEWORK_VERSION(version_string); - - version_string = Project::Version::PROJECT_VERSION; - this->log_ACTIVITY_LO_PROJECT_VERSION(version_string); + //FW_ASSERT(version_type <= Svc::VersionType::ALL); + switch(version_type) { + case (Svc::VersionType::PROJECT): + this->ProjVer_tlm(); + break; + + case (Svc::VersionType::FRAMEWORK): + this->FwVer_tlm(); + break; + + case (Svc::VersionType::LIBRARY): + this->LibVer_tlm(); + break; + + case (Svc::VersionType::CUSTOM): + this->CusVer_tlm(); + break; + + case (Svc::VersionType::ALL): + this->ProjVer_tlm(); + this->FwVer_tlm(); + this->LibVer_tlm(); + this->CusVer_tlm(); + break; + default: + FW_ASSERT(0,version_type); + break; + } this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); } + // ---------------------------------------------------------------------- + // implementations for internal functions + // ---------------------------------------------------------------------- + //Process libs + void Version :: proc_libver() { + num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); + /* + //Store lib array locally + for(U8 i = 0; i < num_lib_elem ; i++) { + lib_ver_arr[i] = Project::Version::LIBRARY_VERSIONS[i]; + } + */ + } + + //Process Custom Versions + void Version :: proc_cusver() { + num_cus_elem = sizeof(this->verId_db)/sizeof(this->verId_db[0]); + } - //function to log tlm on versions - void Version :: Version_tlm() { - Fw::TlmString version_string(Project::Version::FRAMEWORK_VERSION); - this->tlmWrite_FRAMEWORK_VERSION(version_string); + //functions to log tlm on versions + void Version :: FwVer_tlm() { + Fw::LogStringArg fw_evr = (Project::Version::FRAMEWORK_VERSION); + this->log_ACTIVITY_LO_FRAMEWORK_VERSION(fw_evr); + Fw::TlmString fw_eha = (Project::Version::FRAMEWORK_VERSION); + this->tlmWrite_FRAMEWORK_VERSION(fw_eha); + } - version_string = Project::Version::PROJECT_VERSION; - this->tlmWrite_PROJECT_VERSION(version_string); + void Version :: ProjVer_tlm() { + Fw::LogStringArg proj_evr = Project::Version::PROJECT_VERSION; + this->log_ACTIVITY_LO_PROJECT_VERSION(proj_evr); + Fw::TlmString proj_eha= Project::Version::PROJECT_VERSION; + this->tlmWrite_PROJECT_VERSION(proj_eha); + } + + void Version :: LibVer_tlm() { + + for (U8 i = 0; i < num_lib_elem; i++) { + //Emit EVR TLM on library versions + this->log_ACTIVITY_LO_LIBRARY_VERSIONS(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); + + //Write to EHAs + switch(i) { + case VER_SLOT_00: + this->tlmWrite_LIBRARY_VERSION_01(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_01: + this->tlmWrite_LIBRARY_VERSION_02(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_02: + this->tlmWrite_LIBRARY_VERSION_03(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_03: + this->tlmWrite_LIBRARY_VERSION_04(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_04: + this->tlmWrite_LIBRARY_VERSION_05(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_05: + this->tlmWrite_LIBRARY_VERSION_06(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_06: + this->tlmWrite_LIBRARY_VERSION_07(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_07: + this->tlmWrite_LIBRARY_VERSION_08(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_08: + this->tlmWrite_LIBRARY_VERSION_09(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + case VER_SLOT_09: + this->tlmWrite_LIBRARY_VERSION_10(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + break; + default: + //It is possible to have more than 10 library versions; however design agreed to only + // provide 10 TLM channels for it + break; + } + } + + } + + void Version :: CusVer_tlm() { + + //Process custom version TLM only if verbosity is enabled and there are any valid writes to it; + // it doesn't necessarily have to be consecutive + for ( U8 i = 0; + (m_enable == true) && (num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); + i++) { + + if(this->verId_db[i].getver_val() != "no_ver") { //Write TLM for valid writes + + //Emit EVR TLM on library versions + this->log_ACTIVITY_LO_CUSTOM_VERSIONS(this->verId_db[i].getver_enum(), this->verId_db[i].getver_val()); + + //Write to EHAs + switch(i) { + case VER_SLOT_00: + this->tlmWrite_CUSTOM_VERSION_01(verId_db[i]); + break; + case VER_SLOT_01: + this->tlmWrite_CUSTOM_VERSION_02(verId_db[i]); + break; + case VER_SLOT_02: + this->tlmWrite_CUSTOM_VERSION_03(verId_db[i]); + break; + case VER_SLOT_03: + this->tlmWrite_CUSTOM_VERSION_04(verId_db[i]); + break; + case VER_SLOT_04: + this->tlmWrite_CUSTOM_VERSION_05(verId_db[i]); + break; + case VER_SLOT_05: + this->tlmWrite_CUSTOM_VERSION_06(verId_db[i]); + break; + case VER_SLOT_06: + this->tlmWrite_CUSTOM_VERSION_07(verId_db[i]); + break; + case VER_SLOT_07: + this->tlmWrite_CUSTOM_VERSION_08(verId_db[i]); + break; + case VER_SLOT_08: + this->tlmWrite_CUSTOM_VERSION_09(verId_db[i]); + break; + case VER_SLOT_09: + this->tlmWrite_CUSTOM_VERSION_10(verId_db[i]); + break; + default: + //There are only 10 enum slots available, so can assert here + FW_ASSERT(0,i); + break; + } + } + } } } diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 5b4677a59b..7d50c68d2f 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -13,13 +13,30 @@ module Svc { FAILURE = 1 @< Failure to get version } + @ An enumeration for Version Type + enum VersionType { + PROJECT = 0 @< project version + FRAMEWORK = 1 + LIBRARY = 2 + CUSTOM = 3 + ALL = 4 + } + + @ Port for setting and getting Versions port Vers( version_id: VersionCfg.VersionEnum @< The entry to access ref version_string: string @< The value to be passed ref status: VersionStatus @< The command response argument - ) + ) + @Data Structure for custom version Tlm + struct CusVerDb { + ver_enum: VersionCfg.VersionEnum + ver_val: string size 80 + ver_status : VersionStatus + } + passive component Version { ############################################################################## @@ -27,7 +44,7 @@ module Svc { ############################################################################## @ Run port - guarded input port run: [1] Svc.Sched + #guarded input port run: [1] Svc.Sched @ Mutexed Port to get values guarded input port getVersion: Svc.Vers @@ -35,24 +52,26 @@ module Svc { @ Mutexed Port to set values guarded input port setVersion: Svc.Vers - @ A command to enable or disable Version telemetry + @ A command to enable or disable EVR verbosity and Telemetry guarded command ENABLE( enable: VersionEnabled @< whether or not Version telemetry is enabled ) \ opcode 0 @ Report version as EVR - guarded command VERSION \ - opcode 1 + guarded command VERSION( + version_type: VersionType @*/ bool startup_done; + U32 num_lib_elem; //number of library versions + U32 num_cus_elem; //number of custom versions + //const char* lib_ver_arr[]; // Store library versions internally + + // An enumeration for TLM slot access + enum VerSlot { + VER_SLOT_00 = 0, + VER_SLOT_01, + VER_SLOT_02, + VER_SLOT_03, + VER_SLOT_04, + VER_SLOT_05, + VER_SLOT_06, + VER_SLOT_07, + VER_SLOT_08, + VER_SLOT_09 + }; + }; } From 9b1cd590bb4f24f593e15b157833809a6b1b03ae Mon Sep 17 00:00:00 2001 From: Shivaly Date: Fri, 24 May 2024 15:39:04 -0700 Subject: [PATCH 07/36] FP-2604: Updates to UTs and respective code changes --- Svc/Version/Version.cpp | 110 ++++--- Svc/Version/Version.hpp | 31 +- Svc/Version/docs/sdd.md | 21 +- Svc/Version/test/ut/VersionTestMain.cpp | 8 +- Svc/Version/test/ut/VersionTester.cpp | 289 +++++++++++++++++-- Svc/Version/test/ut/VersionTester.hpp | 10 +- Svc/Version/test/ut/VersionTesterHelpers.cpp | 4 +- Svc/Version/test/ut/versions/version.hpp | 30 ++ config/VersionCfg.fpp | 2 +- 9 files changed, 403 insertions(+), 102 deletions(-) create mode 100644 Svc/Version/test/ut/versions/version.hpp diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 35fb6e2b76..bd1f430d51 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -6,7 +6,12 @@ #include "FpConfig.hpp" #include "Svc/Version/Version.hpp" -#include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions + +#ifdef BUILD_UT + #include "test/ut/versions/version.hpp" //autogenerated file containing hardcoded project and framework versions +#else + #include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions +#endif namespace Svc { @@ -37,12 +42,11 @@ namespace Svc { } void Version::Config(bool enable) { - //Set Verbosity for custom versions m_enable = enable; + //Setup and send startup TLM - this->proc_libver(); this->FwVer_tlm(); this->ProjVer_tlm(); this->LibVer_tlm(); @@ -72,9 +76,9 @@ void Version :: ) { FW_ASSERT(version_id.isValid(),version_id.e); - version_string = this->verId_db[version_id.e].getver_val(); - status = this->verId_db[version_id.e].getver_status() ; - this->CusVer_tlm(); + U8 ver_slot = VerSlot(version_id.e); + version_string = this->verId_db[ver_slot].getver_val(); + status = this->verId_db[ver_slot].getver_status() ; } void Version :: @@ -86,12 +90,14 @@ void Version :: ) { FW_ASSERT(version_id.isValid(),version_id.e); - this->verId_db[version_id.e].setver_enum(version_id); - this->verId_db[version_id.e].setver_val(version_string); - this->verId_db[version_id.e].setver_status(status); - this->proc_cusver(); - this->CusVer_tlm(); + VerSlot ver_slot = VerSlot(version_id.e); + this->verId_db[ver_slot].setver_enum(version_id); + this->verId_db[ver_slot].setver_val(version_string); + this->verId_db[ver_slot].setver_status(status); + this->num_cus_elem++; + this->CusVer_tlm(ver_slot); } + // ---------------------------------------------------------------------- // Handler implementations for commands // ---------------------------------------------------------------------- @@ -104,6 +110,8 @@ void Version :: ) { m_enable = (enable == VersionEnabled::ENABLED); + //printf("Test m_enable when disabled: %d\n\n", m_enable); + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); } @@ -130,14 +138,14 @@ void Version :: break; case (Svc::VersionType::CUSTOM): - this->CusVer_tlm(); + this->CusVer_tlm_all(); break; case (Svc::VersionType::ALL): this->ProjVer_tlm(); this->FwVer_tlm(); this->LibVer_tlm(); - this->CusVer_tlm(); + this->CusVer_tlm_all(); break; default: FW_ASSERT(0,version_type); @@ -151,20 +159,20 @@ void Version :: // ---------------------------------------------------------------------- //Process libs void Version :: proc_libver() { - num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); - /* - //Store lib array locally - for(U8 i = 0; i < num_lib_elem ; i++) { - lib_ver_arr[i] = Project::Version::LIBRARY_VERSIONS[i]; - } - */ + num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); + //printf( "num of lib elements before : %d\n\n",num_lib_elem); + if(Project::Version::LIBRARY_VERSIONS[0] == nullptr) { + num_lib_elem = 0; + } + //printf( "num of lib elements : %d\n\n",num_lib_elem); + /* + //Store lib array locally + for(U8 i = 0; i < num_lib_elem ; i++) { + lib_ver_arr[i] = Project::Version::LIBRARY_VERSIONS[i]; + } + */ } - //Process Custom Versions - void Version :: proc_cusver() { - num_cus_elem = sizeof(this->verId_db)/sizeof(this->verId_db[0]); - } - //functions to log tlm on versions void Version :: FwVer_tlm() { Fw::LogStringArg fw_evr = (Project::Version::FRAMEWORK_VERSION); @@ -181,11 +189,13 @@ void Version :: } void Version :: LibVer_tlm() { + //Process libraries array + this->proc_libver(); for (U8 i = 0; i < num_lib_elem; i++) { //Emit EVR TLM on library versions + //printf("lib versions are: %s",Project::Version::LIBRARY_VERSIONS[i]); this->log_ACTIVITY_LO_LIBRARY_VERSIONS(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); - //Write to EHAs switch(i) { case VER_SLOT_00: @@ -227,58 +237,64 @@ void Version :: } - void Version :: CusVer_tlm() { - - //Process custom version TLM only if verbosity is enabled and there are any valid writes to it; - // it doesn't necessarily have to be consecutive + void Version :: CusVer_tlm_all() { + //printf("m_enable : %d , num_cus_elem : %d\n\n",m_enable,num_cus_elem); for ( U8 i = 0; (m_enable == true) && (num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); i++) { - - if(this->verId_db[i].getver_val() != "no_ver") { //Write TLM for valid writes + Version::CusVer_tlm(VerSlot(i)); + } + } + + void Version :: CusVer_tlm(VerSlot cus_slot) { + + //Process custom version TLM only if verbosity is enabled and there are any valid writes to it; + // it doesn't necessarily have to be consecutive + if( (this->verId_db[cus_slot].getver_val() != "no_ver") + && m_enable == true + && (num_cus_elem > 0)) { //Write TLM for valid writes //Emit EVR TLM on library versions - this->log_ACTIVITY_LO_CUSTOM_VERSIONS(this->verId_db[i].getver_enum(), this->verId_db[i].getver_val()); + this->log_ACTIVITY_LO_CUSTOM_VERSIONS(this->verId_db[cus_slot].getver_enum(), this->verId_db[cus_slot].getver_val()); //Write to EHAs - switch(i) { + switch(cus_slot) { case VER_SLOT_00: - this->tlmWrite_CUSTOM_VERSION_01(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_01(verId_db[cus_slot]); break; case VER_SLOT_01: - this->tlmWrite_CUSTOM_VERSION_02(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_02(verId_db[cus_slot]); break; case VER_SLOT_02: - this->tlmWrite_CUSTOM_VERSION_03(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_03(verId_db[cus_slot]); break; case VER_SLOT_03: - this->tlmWrite_CUSTOM_VERSION_04(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_04(verId_db[cus_slot]); break; case VER_SLOT_04: - this->tlmWrite_CUSTOM_VERSION_05(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_05(verId_db[cus_slot]); break; case VER_SLOT_05: - this->tlmWrite_CUSTOM_VERSION_06(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_06(verId_db[cus_slot]); break; case VER_SLOT_06: - this->tlmWrite_CUSTOM_VERSION_07(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_07(verId_db[cus_slot]); break; case VER_SLOT_07: - this->tlmWrite_CUSTOM_VERSION_08(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_08(verId_db[cus_slot]); break; case VER_SLOT_08: - this->tlmWrite_CUSTOM_VERSION_09(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_09(verId_db[cus_slot]); break; case VER_SLOT_09: - this->tlmWrite_CUSTOM_VERSION_10(verId_db[i]); + this->tlmWrite_CUSTOM_VERSION_10(verId_db[cus_slot]); break; default: - //There are only 10 enum slots available, so can assert here - FW_ASSERT(0,i); + //There are only 10 custom slots available + FW_ASSERT(0,cus_slot); break; } } } - } } diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 1ad879f637..8c03392e18 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -103,20 +103,9 @@ namespace Svc { Svc::VersionType version_type //!< which version type EVR is requested ) override; - private: - void proc_libver(); - void proc_cusver(); - void FwVer_tlm(); - void ProjVer_tlm(); - void LibVer_tlm(); - void CusVer_tlm(); - bool m_enable; /*!*/ - bool startup_done; - U32 num_lib_elem; //number of library versions - U32 num_cus_elem; //number of custom versions - //const char* lib_ver_arr[]; // Store library versions internally - - // An enumeration for TLM slot access + PRIVATE: + + // An enumeration for TLM slot access enum VerSlot { VER_SLOT_00 = 0, VER_SLOT_01, @@ -130,6 +119,20 @@ namespace Svc { VER_SLOT_09 }; + void proc_libver(); + void proc_cusver(); + void FwVer_tlm(); + void ProjVer_tlm(); + void LibVer_tlm(); + void CusVer_tlm(VerSlot cus_slot); + void CusVer_tlm_all(); + bool m_enable; /*!*/ + bool startup_done; + U32 num_lib_elem; //number of library versions + U32 num_cus_elem; //number of custom versions + //const char* lib_ver_arr[]; // Store library versions internally + + }; } diff --git a/Svc/Version/docs/sdd.md b/Svc/Version/docs/sdd.md index e0b5c84b29..f4b948ad99 100644 --- a/Svc/Version/docs/sdd.md +++ b/Svc/Version/docs/sdd.md @@ -58,11 +58,22 @@ Add unit test descriptions in the chart below | Name | Description | Validation | |---|---|---| -|SVC-VERSION-001|`Svc::Version` shall create an EVR indicating versions of framework, project and libary at start-up and on command| This is to provide transparency to users on versions being used| -|SVC-VERSION-002|`Svc::Version` shall provide a telemetry channel on framework version| Accessiblity to versions being used| -|SVC-VERSION-003|`Svc::Version` shall provide a telemetry channel on project version| Accessiblity to versions being used| -|SVC-VERSION-004|`Svc::Version` shall provide a telemetry channel on library version| Accessiblity to versions being used| -|SVC-VERSION-005|`Svc::Version` shall provide an interface for users to set custom versions.| Enables projects to set hardware and FPGA versions as needed| +|SVC-VERSION-001|`Svc::Version` upon startup shall generate an event and a telemetry channel with version for framework.| This is to provide transparency on framework version being used| +|SVC-VERSION-002|`Svc::Version` upon startup shall generate an event and a telemetry channel with version for project | This is to provide transparency on project version being used| +|SVC-VERSION-003|`Svc::Version` upon startup shall generate events and telemetry channels (upto 10) with versions for libary.| Transparency on different library versions| +|SVC-VERSION-004|`Svc::Version` upon startup shall make verbosity on custom versions configurable.| Transparency on different library versions| +|SVC-VERSION-005|`Svc::Version` shall provide a ground command to request events and telemetry on framework version| Accessiblity on demand| +|SVC-VERSION-006|`Svc::Version` shall provide a ground command to request events and telemetry on project version| Accessiblity on demand| +|SVC-VERSION-007|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on library versions| Accessiblity on demand| +|SVC-VERSION-008|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on custom versions| Accessiblity on demand| +|SVC-VERSION-009|`Svc::Version` shall provide a ground command to enable/disable verbosity on custom versions| Accessiblity on demand| +|SVC-VERSION-010|`Svc::Version` shall provide a telemetry channel on framework version| Accessiblity to versions being used| +|SVC-VERSION-011|`Svc::Version` shall provide a telemetry channel on project version| Accessiblity to versions being used| +|SVC-VERSION-012|`Svc::Version` shall provide upto 10 telemetry channels on library versions| Accessiblity to versions being used| +|SVC-VERSION-013|`Svc::Version` shall provide upto 10 telemetry channels on custom versions| Accessiblity to versions being used| +|SVC-VERSION-014|`Svc::Version` shall provide an interface for other components to set custom versions.| Enables projects to set hardware and FPGA versions, say, as needed. Also generates EVRs/EHAs| +|SVC-VERSION-015|`Svc::Version` shall provide an interface for other components to get custom versions.| Also generates EVRs/EHAs| + ## Change Log | Date | Description | diff --git a/Svc/Version/test/ut/VersionTestMain.cpp b/Svc/Version/test/ut/VersionTestMain.cpp index b90ab2bdfe..1da68afea0 100644 --- a/Svc/Version/test/ut/VersionTestMain.cpp +++ b/Svc/Version/test/ut/VersionTestMain.cpp @@ -11,14 +11,14 @@ TEST(Nominal, test_startup) { tester.test_startup(); } -TEST(Nominal, test_ports) { +TEST(Nominal, test_cmds) { Svc::VersionTester tester; - tester.test_ports(); + tester.test_commands(); } -TEST(Nominal, test_cmds) { +TEST(Nominal, test_ports) { Svc::VersionTester tester; - tester.test_commands(); + tester.test_ports(); } int main(int argc, char** argv) { diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 5d1f9edad1..99966df825 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -31,44 +31,190 @@ namespace Svc { // ---------------------------------------------------------------------- // Tests // ---------------------------------------------------------------------- + //Clear/init test + void VersionTester :: clear_all() { + this->clearHistory(); + ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(0); + ASSERT_EVENTS_PROJECT_VERSION_SIZE(0); + ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(0); + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(0); + ASSERT_TLM_FRAMEWORK_VERSION_SIZE(0); + ASSERT_TLM_PROJECT_VERSION_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_01_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_02_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_03_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_04_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_05_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_06_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_07_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_08_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_09_SIZE(0); + ASSERT_TLM_LIBRARY_VERSION_10_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_01_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_02_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_03_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_04_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_05_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_06_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_07_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_08_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_09_SIZE(0); + ASSERT_TLM_CUSTOM_VERSION_10_SIZE(0); + } // ---------------------------------------------------------------------- // Test STARTUP // ---------------------------------------------------------------------- void VersionTester :: test_startup() { - this->invoke_to_run(0,0); - ASSERT_EVENTS_STARTUP_EVR_SIZE(1); - ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); + //this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after starttask() in RefTopology.cpp + //ASSERT_EVENTS_STARTUP_EVR_SIZE(1); + //ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); + this->component.Config(true); + ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); + ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); + ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); + ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + //Library versions currently set to a null pointer + //TODO: Need to figure out how to put in artifical sets to test them + ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); + ASSERT_EVENTS_LIBRARY_VERSIONS(0, "blah0 @ blah0"); } // ---------------------------------------------------------------------- // Test Commands // ---------------------------------------------------------------------- + void VersionTester :: test_enable() { U32 cmd_seq = 9; this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::DISABLED); - this->invoke_to_run(0,0); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + VersionTester::test_setVer(false); + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(0); + cmd_seq = 9; this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::ENABLED); - this->invoke_to_run(0,0); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); - ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); + VersionTester::test_setVer(true); + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + } void VersionTester :: test_versions() { U32 cmd_seq = 9; - this->sendCmd_VERSION(0,cmd_seq); - this->invoke_to_run(0,0); - ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + this->clear_all(); + this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::FRAMEWORK); + ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + ASSERT_TLM_FRAMEWORK_VERSION_SIZE(1); + ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + + this->clear_all(); + this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::PROJECT); + ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + ASSERT_TLM_PROJECT_VERSION_SIZE(1); + ASSERT_TLM_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); + ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + + this->clear_all(); + this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::LIBRARY); + ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + //printf ("\nfirst lib element : %s\n\n", Project::Version::LIBRARY_VERSIONS[0]); + ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); + + ASSERT_TLM_LIBRARY_VERSION_01_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_01(0, "blah0 @ blah0"); + ASSERT_EVENTS_LIBRARY_VERSIONS(0, "blah0 @ blah0"); + + ASSERT_TLM_LIBRARY_VERSION_02_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_02(0, "blah1 @ blah1"); + ASSERT_EVENTS_LIBRARY_VERSIONS(1, "blah1 @ blah1"); + + ASSERT_TLM_LIBRARY_VERSION_03_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_03(0, "blah2 @ blah2"); + ASSERT_EVENTS_LIBRARY_VERSIONS(2, "blah2 @ blah2"); + + ASSERT_TLM_LIBRARY_VERSION_04_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_04(0, "blah3 @ blah3"); + ASSERT_EVENTS_LIBRARY_VERSIONS(3, "blah3 @ blah3"); + + ASSERT_TLM_LIBRARY_VERSION_05_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_05(0, "blah4 @ blah4"); + ASSERT_EVENTS_LIBRARY_VERSIONS(4, "blah4 @ blah4"); + + ASSERT_TLM_LIBRARY_VERSION_06_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_06(0, "blah5 @ blah5"); + ASSERT_EVENTS_LIBRARY_VERSIONS(5, "blah5 @ blah5"); + + ASSERT_TLM_LIBRARY_VERSION_07_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_07(0, "blah6 @ blah6"); + ASSERT_EVENTS_LIBRARY_VERSIONS(6, "blah6 @ blah6"); + + ASSERT_TLM_LIBRARY_VERSION_08_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_08(0, "blah7 @ blah7"); + ASSERT_EVENTS_LIBRARY_VERSIONS(7, "blah7 @ blah7"); + + ASSERT_TLM_LIBRARY_VERSION_09_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_09(0, "blah8 @ blah8"); + ASSERT_EVENTS_LIBRARY_VERSIONS(8, "blah8 @ blah8"); + + ASSERT_TLM_LIBRARY_VERSION_10_SIZE(1); + ASSERT_TLM_LIBRARY_VERSION_10(0, "blah9 @ blah9"); + ASSERT_EVENTS_LIBRARY_VERSIONS(9, "blah9 @ blah9"); + + ASSERT_EVENTS_LIBRARY_VERSIONS(10, "blah10 @ blah10"); + + ASSERT_EVENTS_LIBRARY_VERSIONS(11, "blah11 @ blah11"); + + + this->clear_all(); + Svc::CusVerDb cus_data_struct; + this->test_setVer(false); + this->clear_all(); + this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::CUSTOM); + ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + + ASSERT_EVENTS_CUSTOM_VERSIONS(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_03(0, cus_data_struct); + ASSERT_TLM_CUSTOM_VERSION_03_SIZE(1); + + ASSERT_EVENTS_CUSTOM_VERSIONS(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_04(0, cus_data_struct); + ASSERT_TLM_CUSTOM_VERSION_04_SIZE(1); + + ASSERT_EVENTS_CUSTOM_VERSIONS(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_07(0, cus_data_struct); + ASSERT_TLM_CUSTOM_VERSION_07_SIZE(1); + + ASSERT_EVENTS_CUSTOM_VERSIONS(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_10(0, cus_data_struct); + ASSERT_TLM_CUSTOM_VERSION_10_SIZE(1); + + this->clear_all(); + this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::ALL); + ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); + ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); + ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); + ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); } void VersionTester :: test_commands() { @@ -80,29 +226,122 @@ namespace Svc { // Test User Ports // ---------------------------------------------------------------------- - void VersionTester :: test_setVer() { + void VersionTester :: test_setVer(bool is_enabled) { Svc::VersionStatus status = Svc::VersionStatus::OK; - Svc::VersPortStrings::StringSize80 set_ver_0 = "ver_0"; - Svc::VersPortStrings::StringSize80 set_ver_6 = "ver_6"; - Svc::VersPortStrings::StringSize80 set_ver_3 = "ver_3"; - Svc::VersPortStrings::StringSize80 set_ver_9 = "ver_9"; + Svc::VersPortStrings::StringSize80 set_ver = "ver_2"; + + //Create a db to compare against set values + Svc::CusVerDb cus_data_struct; + //printf("\nTesting the very first port invocation\n"); + + //Start Clean + this->clear_all(); + + //this->sendCmd_ENABLE(0,9,VersionEnabled::ENABLED); + set_ver = "ver_0"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(1); + ASSERT_EVENTS_CUSTOM_VERSIONS(0,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00,"ver_0"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_01(0, cus_data_struct); + } - this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver_0, status); + set_ver = "ver_1"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(2); + ASSERT_EVENTS_CUSTOM_VERSIONS(1,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01,"ver_1"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_02(0, cus_data_struct); + } + + set_ver = "ver_2"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(3); + ASSERT_EVENTS_CUSTOM_VERSIONS(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_03(0, cus_data_struct); + } + status = Svc::VersionStatus::FAILURE; - this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver_3, status); - this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver_6, status); + + set_ver = "ver_3"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(4); + ASSERT_EVENTS_CUSTOM_VERSIONS(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_04(0, cus_data_struct); + } + + set_ver = "ver_4"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(5); + ASSERT_EVENTS_CUSTOM_VERSIONS(4,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04,"ver_4"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_05(0, cus_data_struct); + } + + set_ver = "ver_5"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(6); + ASSERT_EVENTS_CUSTOM_VERSIONS(5,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05,"ver_5"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_06(0, cus_data_struct); + } + + set_ver = "ver_6"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(7); + ASSERT_EVENTS_CUSTOM_VERSIONS(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CUSTOM_VERSION_07(0, cus_data_struct); + } + status = Svc::VersionStatus::OK; - this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver_9, status); + + set_ver = "ver_7"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(8); + ASSERT_EVENTS_CUSTOM_VERSIONS(7,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07,"ver_7"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_08(0, cus_data_struct); + } + + set_ver = "ver_8"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(9); + ASSERT_EVENTS_CUSTOM_VERSIONS(8,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08,"ver_8"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_09(0, cus_data_struct); + } + + set_ver = "ver_9"; + this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, status); + if(is_enabled == true) { + ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + ASSERT_EVENTS_CUSTOM_VERSIONS(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CUSTOM_VERSION_10(0, cus_data_struct); + } + } void VersionTester :: test_getVer() { Svc::VersionStatus status; Svc::VersPortStrings::StringSize80 get_ver; - - this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, get_ver, status); - ASSERT_EQ(get_ver,"ver_0"); + + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, get_ver, status); + ASSERT_EQ(get_ver,"ver_2"); ASSERT_EQ(status,Svc::VersionStatus::OK); this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, get_ver, status); @@ -118,16 +357,16 @@ namespace Svc { ASSERT_EQ(status,Svc::VersionStatus::OK); this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, get_ver, status); - ASSERT_EQ(get_ver,"no_ver"); + ASSERT_EQ(get_ver,"ver_5"); ASSERT_EQ(status,Svc::VersionStatus::FAILURE); } void VersionTester::test_ports() { - this->test_setVer(); + this->sendCmd_ENABLE(0,9,VersionEnabled::ENABLED); + this->test_setVer(true); this->test_getVer(); } - // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- diff --git a/Svc/Version/test/ut/VersionTester.hpp b/Svc/Version/test/ut/VersionTester.hpp index e96aaeb8c3..b36b3dd07e 100644 --- a/Svc/Version/test/ut/VersionTester.hpp +++ b/Svc/Version/test/ut/VersionTester.hpp @@ -23,7 +23,7 @@ namespace Svc { // ---------------------------------------------------------------------- // Maximum size of histories storing events, telemetry, and port outputs - static const FwSizeType MAX_HISTORY_SIZE = 10; + static const FwSizeType MAX_HISTORY_SIZE = 100; // Instance ID supplied to the component instance under test static const FwEnumStoreType TEST_INSTANCE_ID = 0; @@ -48,9 +48,10 @@ namespace Svc { //! test startup EVR void test_startup(); - + //! test enable command void test_enable(); + //! test version command void test_versions(); //! test all commands @@ -59,10 +60,11 @@ namespace Svc { //! test get version void test_getVer(); //! test set version - void test_setVer(); + void test_setVer(bool is_enabled); //!test all ports void test_ports(); - + //clear history + void clear_all(); private: // ---------------------------------------------------------------------- diff --git a/Svc/Version/test/ut/VersionTesterHelpers.cpp b/Svc/Version/test/ut/VersionTesterHelpers.cpp index dcced4dbde..8bf832ae08 100644 --- a/Svc/Version/test/ut/VersionTesterHelpers.cpp +++ b/Svc/Version/test/ut/VersionTesterHelpers.cpp @@ -60,12 +60,12 @@ namespace Svc { 0, this->component.get_getVersion_InputPort(0) ); - +/* this->connect_to_run( 0, this->component.get_run_InputPort(0) ); - +*/ this->connect_to_setVersion( 0, this->component.get_setVersion_InputPort(0) diff --git a/Svc/Version/test/ut/versions/version.hpp b/Svc/Version/test/ut/versions/version.hpp new file mode 100644 index 0000000000..ca483df727 --- /dev/null +++ b/Svc/Version/test/ut/versions/version.hpp @@ -0,0 +1,30 @@ +/* + This file is a replica of version.hpp generated using [generate_version_info.py]. + Replicated to have a fixed size and values for +*/ +#ifndef _VERSION_TESTER_HPP_ +#define _VERSION_TESTER_HPP_ + +namespace Project { + +struct Version { + static constexpr const char* const FRAMEWORK_VERSION = "v3.4.3-66-g5d50140f5"; + static constexpr const char* const PROJECT_VERSION = "v3.4.3-66-g5d50140f5"; + static constexpr const char* const LIBRARY_VERSIONS[] = { + "blah0 @ blah0" , + "blah1 @ blah1" , + "blah2 @ blah2" , + "blah3 @ blah3" , + "blah4 @ blah4" , + "blah5 @ blah5" , + "blah6 @ blah6" , + "blah7 @ blah7" , + "blah8 @ blah8" , + "blah9 @ blah9" , + "blah10 @ blah10" , + "blah11 @ blah11" , + }; +}; + +} // namespace Project +#endif diff --git a/config/VersionCfg.fpp b/config/VersionCfg.fpp index 09795464ff..6a7806c47a 100644 --- a/config/VersionCfg.fpp +++ b/config/VersionCfg.fpp @@ -6,7 +6,7 @@ module Svc { module VersionCfg { - @ Define a set of PolyDb entries on a project-specific + @ Define a set of Version entries on a project-specific @ basis. enum VersionEnum: U32 { @ Entry 0 From 68860c9379ca95a4a32fb241ad2b4c7724cfcec9 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 28 May 2024 12:05:39 -0700 Subject: [PATCH 08/36] FP-2604: Updates based on review comments --- Svc/Version/Version.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 8c03392e18..7bee4ed24e 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -128,8 +128,8 @@ namespace Svc { void CusVer_tlm_all(); bool m_enable; /*!*/ bool startup_done; - U32 num_lib_elem; //number of library versions - U32 num_cus_elem; //number of custom versions + U8 num_lib_elem; //number of library versions + U8 num_cus_elem; //number of custom versions //const char* lib_ver_arr[]; // Store library versions internally From 77c7b4903bfc81d50042a688078155a1fcf0af73 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 28 May 2024 14:35:06 -0700 Subject: [PATCH 09/36] FP-2604: Minor updates based on pull request auto comments --- Svc/Version/Version.cpp | 5 +++-- Svc/Version/test/ut/VersionTester.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index bd1f430d51..fc5ae721c2 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -26,8 +26,9 @@ namespace Svc { startup_done = false; num_lib_elem = 0; num_cus_elem = 0; + m_enable = false; Svc::VersPortStrings::StringSize80 ver_str = "no_ver"; - // initialize all entries + // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { //setver_enum is by default set to the first enum value, so not setting it here verId_db[id].setver_val(ver_str); @@ -78,7 +79,7 @@ void Version :: FW_ASSERT(version_id.isValid(),version_id.e); U8 ver_slot = VerSlot(version_id.e); version_string = this->verId_db[ver_slot].getver_val(); - status = this->verId_db[ver_slot].getver_status() ; + status = this->verId_db[ver_slot].getver_status(); } void Version :: diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 99966df825..f554ab7ffa 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -404,4 +404,4 @@ namespace Svc { this->component.init(0); } */ -} \ No newline at end of file +} From 3b177afebfd321824325f32b24182c8acbd44c19 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 29 May 2024 14:09:06 -0700 Subject: [PATCH 10/36] FP-2604: Updates to Ref to integrate versions config and include channel packets --- .github/actions/spelling/expect.txt | 1 + Ref/Top/RefPackets.xml | 58 +++++++++++++++++++++++++++++ Ref/Top/RefTopology.cpp | 2 +- Ref/Top/instances.fpp | 4 ++ Ref/Top/topology.fpp | 1 + Svc/Version/Version.cpp | 2 +- Svc/Version/Version.hpp | 2 +- 7 files changed, 67 insertions(+), 3 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index ba1456bcca..937b4de805 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -976,6 +976,7 @@ spidev srandom srange SRCS +sreddy sss Ssymbols STAMEM diff --git a/Ref/Top/RefPackets.xml b/Ref/Top/RefPackets.xml index c29f3ac906..a68b99f193 100644 --- a/Ref/Top/RefPackets.xml +++ b/Ref/Top/RefPackets.xml @@ -187,6 +187,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ref/Top/RefTopology.cpp b/Ref/Top/RefTopology.cpp index 8b3025d1cd..e4cfeac086 100644 --- a/Ref/Top/RefTopology.cpp +++ b/Ref/Top/RefTopology.cpp @@ -157,7 +157,7 @@ void setupTopology(const TopologyState& state) { // Autocoded task kick-off (active components). Function provided by autocoder. startTasks(state); // Startup TLM and Config verbosity for Versions - Version.Config(true); + version.config(true); // Initialize socket client communication if and only if there is a valid specification if (state.hostname != nullptr && state.port != 0) { Os::TaskString name("ReceiveTask"); diff --git a/Ref/Top/instances.fpp b/Ref/Top/instances.fpp index 2e51b98eaa..2dc3032762 100644 --- a/Ref/Top/instances.fpp +++ b/Ref/Top/instances.fpp @@ -129,6 +129,8 @@ module Ref { instance sendBuffComp: Ref.SendBuff base id 0x2600 \ queue size Default.QUEUE_SIZE + + # ---------------------------------------------------------------------- # Passive component instances @@ -161,5 +163,7 @@ module Ref { instance systemResources: Svc.SystemResources base id 0x4B00 instance dpBufferManager: Svc.BufferManager base id 0x4C00 + + instance version: Svc.Version base id 0x4D00 } diff --git a/Ref/Top/topology.fpp b/Ref/Top/topology.fpp index f2feb1e8ab..d890604f4a 100644 --- a/Ref/Top/topology.fpp +++ b/Ref/Top/topology.fpp @@ -58,6 +58,7 @@ module Ref { instance dpMgr instance dpWriter instance dpBufferManager + instance version # ---------------------------------------------------------------------- # Pattern graph specifiers diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index fc5ae721c2..9417d2c9fa 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -42,7 +42,7 @@ namespace Svc { } - void Version::Config(bool enable) { + void Version::config(bool enable) { //Set Verbosity for custom versions m_enable = enable; diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 7bee4ed24e..1baf1a1bdf 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -30,7 +30,7 @@ namespace Svc { ~Version(); //! configure version's verbosity and startup - void Config (bool enable); + void config (bool enable); PRIVATE: // ---------------------------------------------------------------------- From 06df65d6298009031c3ed02988fab49cee1bc4c2 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 29 May 2024 14:21:27 -0700 Subject: [PATCH 11/36] FP-2604 : Update function call in UTs for config to match standards --- Svc/Version/test/ut/VersionTester.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index f554ab7ffa..0b016e9378 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -69,7 +69,7 @@ namespace Svc { //this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after starttask() in RefTopology.cpp //ASSERT_EVENTS_STARTUP_EVR_SIZE(1); //ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); - this->component.Config(true); + this->component.config(true); ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); From 2e4b8e79014ce0ecb1b9ce019984030b0961a0d7 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 29 May 2024 16:19:10 -0700 Subject: [PATCH 12/36] FP-2604: Remove commented out lines so the python formatter passes in the PR --- Autocoders/Python/src/fprime_ac/utils/version.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Autocoders/Python/src/fprime_ac/utils/version.py b/Autocoders/Python/src/fprime_ac/utils/version.py index 2c662646a8..97826f9b91 100644 --- a/Autocoders/Python/src/fprime_ac/utils/version.py +++ b/Autocoders/Python/src/fprime_ac/utils/version.py @@ -21,8 +21,6 @@ def get_version_str(working_dir, fallback=FALLBACK_VERSION): output = subprocess.check_output( ["git", "describe", "--tags", "--always"], cwd=working_dir ) - #print ("Msg3: output string : ",output) - #print ("Msg4: output string reformatted: ",output.strip().decode("ascii")) return output.strip().decode("ascii") except Exception: return fallback @@ -39,7 +37,6 @@ def get_fprime_version(): """ fprime_directory = os.environ.get( "FPRIME_FRAMEWORK_PATH", os.path.dirname(__file__)) - #print("Msg1: fprime_directory for version: ", fprime_directory) return get_version_str(working_dir=fprime_directory, fallback=FALLBACK_VERSION) @@ -57,7 +54,6 @@ def get_project_version(fallback=FALLBACK_VERSION): Version of fprime framework """ fprime_directory = os.environ.get("FPRIME_PROJECT_ROOT", os.path.dirname(__file__)) - #print("Msg1: fprime_directory for project : ", fprime_directory, "and _file_ : ",__file__) return get_version_str(working_dir=fprime_directory, fallback=fallback) From 62294116a9891a217f617966e51b46fc5e8f0bb0 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 29 May 2024 16:35:26 -0700 Subject: [PATCH 13/36] FP-2604: Fixing python formatting issues --- Autocoders/Python/src/fprime_ac/utils/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Autocoders/Python/src/fprime_ac/utils/version.py b/Autocoders/Python/src/fprime_ac/utils/version.py index 97826f9b91..b332790b4c 100644 --- a/Autocoders/Python/src/fprime_ac/utils/version.py +++ b/Autocoders/Python/src/fprime_ac/utils/version.py @@ -36,8 +36,8 @@ def get_fprime_version(): Version of fprime framework """ fprime_directory = os.environ.get( - "FPRIME_FRAMEWORK_PATH", os.path.dirname(__file__)) - + "FPRIME_FRAMEWORK_PATH", os.path.dirname(__file__) + ) return get_version_str(working_dir=fprime_directory, fallback=FALLBACK_VERSION) From 7fcff5f67b0a6e749764b7a4e3b64b33736b95af Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 15:45:23 -0700 Subject: [PATCH 14/36] FP-2604: Updates to code based on peer review comments --- Svc/Version/Version.cpp | 184 ++++++++---------- Svc/Version/Version.fpp | 101 +++++----- Svc/Version/Version.hpp | 59 +++--- Svc/Version/docs/sdd.md | 24 +-- Svc/Version/test/ut/VersionTester.cpp | 268 +++++++++++++------------- 5 files changed, 296 insertions(+), 340 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 9417d2c9fa..8b198ff598 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -23,16 +23,16 @@ namespace Svc { Version(const char* const compName) : VersionComponentBase(compName) { - startup_done = false; - num_lib_elem = 0; - num_cus_elem = 0; + m_startup_done = false; + m_num_lib_elem = 0; + m_num_cus_elem = 0; m_enable = false; - Svc::VersPortStrings::StringSize80 ver_str = "no_ver"; + Svc::VersionPortStrings::StringSize80 ver_str = "no_ver"; // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { //setver_enum is by default set to the first enum value, so not setting it here - verId_db[id].setver_val(ver_str); - verId_db[id].setver_status(VersionStatus::FAILURE); + verId_db[id].setversion_value(ver_str); + verId_db[id].setversion_status(VersionStatus::FAILURE); } } @@ -48,55 +48,43 @@ namespace Svc { //Setup and send startup TLM - this->FwVer_tlm(); - this->ProjVer_tlm(); - this->LibVer_tlm(); + this->fwVersion_tlm(); + this->projectVersion_tlm(); + this->libraryVersion_tlm(); } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- -/* -void Version ::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { - if(m_enable) { - Version_tlm(); - //TODO: Need to add libraries and user defined versions here as well - if (startup_done == false) { //Send EVR once at startup - this->log_ACTIVITY_LO_STARTUP_EVR(Fw::LogStringArg(Project::Version::PROJECT_VERSION),Fw::LogStringArg(Project::Version::FRAMEWORK_VERSION)); - startup_done = true; - } - } -} -*/ void Version :: getVersion_handler( FwIndexType portNum, const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersPortStrings::StringSize80& version_string, + Svc::VersionPortStrings::StringSize80& version_string, Svc::VersionStatus& status ) { FW_ASSERT(version_id.isValid(),version_id.e); - U8 ver_slot = VerSlot(version_id.e); - version_string = this->verId_db[ver_slot].getver_val(); - status = this->verId_db[ver_slot].getver_status(); + U8 version_slot = VersionSlot(version_id.e); + version_string = this->verId_db[version_slot].getversion_value(); + status = this->verId_db[version_slot].getversion_status(); } void Version :: setVersion_handler( FwIndexType portNum, const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersPortStrings::StringSize80& version_string, + Svc::VersionPortStrings::StringSize80& version_string, Svc::VersionStatus& status ) { FW_ASSERT(version_id.isValid(),version_id.e); - VerSlot ver_slot = VerSlot(version_id.e); - this->verId_db[ver_slot].setver_enum(version_id); - this->verId_db[ver_slot].setver_val(version_string); - this->verId_db[ver_slot].setver_status(status); - this->num_cus_elem++; - this->CusVer_tlm(ver_slot); + VersionSlot ver_slot = VersionSlot(version_id.e); + this->verId_db[ver_slot].setversion_enum(version_id); + this->verId_db[ver_slot].setversion_value(version_string); + this->verId_db[ver_slot].setversion_status(status); + this->m_num_cus_elem++; + this->customVersion_tlm(ver_slot); } // ---------------------------------------------------------------------- @@ -111,12 +99,11 @@ void Version :: ) { m_enable = (enable == VersionEnabled::ENABLED); - //printf("Test m_enable when disabled: %d\n\n", m_enable); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); } - //Command handler to EVR versions + //Command handler to event versions void Version :: VERSION_cmdHandler( FwOpcodeType opCode, @@ -127,26 +114,26 @@ void Version :: //FW_ASSERT(version_type <= Svc::VersionType::ALL); switch(version_type) { case (Svc::VersionType::PROJECT): - this->ProjVer_tlm(); + this->projectVersion_tlm(); break; case (Svc::VersionType::FRAMEWORK): - this->FwVer_tlm(); + this->fwVersion_tlm(); break; case (Svc::VersionType::LIBRARY): - this->LibVer_tlm(); + this->libraryVersion_tlm(); break; case (Svc::VersionType::CUSTOM): - this->CusVer_tlm_all(); + this->customVersion_tlm_all(); break; case (Svc::VersionType::ALL): - this->ProjVer_tlm(); - this->FwVer_tlm(); - this->LibVer_tlm(); - this->CusVer_tlm_all(); + this->projectVersion_tlm(); + this->fwVersion_tlm(); + this->libraryVersion_tlm(); + this->customVersion_tlm_all(); break; default: FW_ASSERT(0,version_type); @@ -158,76 +145,68 @@ void Version :: // ---------------------------------------------------------------------- // implementations for internal functions // ---------------------------------------------------------------------- - //Process libs - void Version :: proc_libver() { - num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); - //printf( "num of lib elements before : %d\n\n",num_lib_elem); + //Process libsv + void Version :: process_libraryVersion() { + m_num_lib_elem = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); + //m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); if(Project::Version::LIBRARY_VERSIONS[0] == nullptr) { - num_lib_elem = 0; + m_num_lib_elem = 0; } - //printf( "num of lib elements : %d\n\n",num_lib_elem); - /* - //Store lib array locally - for(U8 i = 0; i < num_lib_elem ; i++) { - lib_ver_arr[i] = Project::Version::LIBRARY_VERSIONS[i]; - } - */ } //functions to log tlm on versions - void Version :: FwVer_tlm() { - Fw::LogStringArg fw_evr = (Project::Version::FRAMEWORK_VERSION); - this->log_ACTIVITY_LO_FRAMEWORK_VERSION(fw_evr); - Fw::TlmString fw_eha = (Project::Version::FRAMEWORK_VERSION); - this->tlmWrite_FRAMEWORK_VERSION(fw_eha); + void Version :: fwVersion_tlm() { + Fw::LogStringArg fw_event = (Project::Version::FRAMEWORK_VERSION); + this->log_ACTIVITY_LO_FrameworkVersion(fw_event); + Fw::TlmString fw_tlm = (Project::Version::FRAMEWORK_VERSION); + this->tlmWrite_FrameworkVersion(fw_tlm); } - void Version :: ProjVer_tlm() { - Fw::LogStringArg proj_evr = Project::Version::PROJECT_VERSION; - this->log_ACTIVITY_LO_PROJECT_VERSION(proj_evr); - Fw::TlmString proj_eha= Project::Version::PROJECT_VERSION; - this->tlmWrite_PROJECT_VERSION(proj_eha); + void Version :: projectVersion_tlm() { + Fw::LogStringArg proj_event = Project::Version::PROJECT_VERSION; + this->log_ACTIVITY_LO_ProjectVersion(proj_event); + Fw::TlmString proj_tlm = Project::Version::PROJECT_VERSION; + this->tlmWrite_ProjectVersion(proj_tlm); } - void Version :: LibVer_tlm() { + void Version :: libraryVersion_tlm() { //Process libraries array - this->proc_libver(); + this->process_libraryVersion(); - for (U8 i = 0; i < num_lib_elem; i++) { - //Emit EVR TLM on library versions - //printf("lib versions are: %s",Project::Version::LIBRARY_VERSIONS[i]); - this->log_ACTIVITY_LO_LIBRARY_VERSIONS(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); - //Write to EHAs + for (U8 i = 0; i < m_num_lib_elem; i++) { + //Emit Event/TLM on library versions + this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); + //Write to Events switch(i) { case VER_SLOT_00: - this->tlmWrite_LIBRARY_VERSION_01(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion01(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_01: - this->tlmWrite_LIBRARY_VERSION_02(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion02(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_02: - this->tlmWrite_LIBRARY_VERSION_03(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion03(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_03: - this->tlmWrite_LIBRARY_VERSION_04(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion04(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_04: - this->tlmWrite_LIBRARY_VERSION_05(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion05(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_05: - this->tlmWrite_LIBRARY_VERSION_06(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion06(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_06: - this->tlmWrite_LIBRARY_VERSION_07(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion07(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_07: - this->tlmWrite_LIBRARY_VERSION_08(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion08(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_08: - this->tlmWrite_LIBRARY_VERSION_09(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion09(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; case VER_SLOT_09: - this->tlmWrite_LIBRARY_VERSION_10(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); + this->tlmWrite_LibraryVersion10(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; default: //It is possible to have more than 10 library versions; however design agreed to only @@ -238,61 +217,60 @@ void Version :: } - void Version :: CusVer_tlm_all() { - //printf("m_enable : %d , num_cus_elem : %d\n\n",m_enable,num_cus_elem); + void Version :: customVersion_tlm_all() { for ( U8 i = 0; - (m_enable == true) && (num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); + (m_enable == true) && (m_num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); i++) { - Version::CusVer_tlm(VerSlot(i)); + Version::customVersion_tlm(VersionSlot(i)); } } - void Version :: CusVer_tlm(VerSlot cus_slot) { + void Version :: customVersion_tlm(VersionSlot custom_slot) { //Process custom version TLM only if verbosity is enabled and there are any valid writes to it; // it doesn't necessarily have to be consecutive - if( (this->verId_db[cus_slot].getver_val() != "no_ver") + if( (this->verId_db[custom_slot].getversion_value() != "no_ver") && m_enable == true - && (num_cus_elem > 0)) { //Write TLM for valid writes + && (m_num_cus_elem > 0)) { //Write TLM for valid writes - //Emit EVR TLM on library versions - this->log_ACTIVITY_LO_CUSTOM_VERSIONS(this->verId_db[cus_slot].getver_enum(), this->verId_db[cus_slot].getver_val()); + //Emit Events/TLM on library versions + this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].getversion_enum(), this->verId_db[custom_slot].getversion_value()); - //Write to EHAs - switch(cus_slot) { + //Write to TLM + switch(custom_slot) { case VER_SLOT_00: - this->tlmWrite_CUSTOM_VERSION_01(verId_db[cus_slot]); + this->tlmWrite_CustomVersion01(verId_db[custom_slot]); break; case VER_SLOT_01: - this->tlmWrite_CUSTOM_VERSION_02(verId_db[cus_slot]); + this->tlmWrite_CustomVersion02(verId_db[custom_slot]); break; case VER_SLOT_02: - this->tlmWrite_CUSTOM_VERSION_03(verId_db[cus_slot]); + this->tlmWrite_CustomVersion03(verId_db[custom_slot]); break; case VER_SLOT_03: - this->tlmWrite_CUSTOM_VERSION_04(verId_db[cus_slot]); + this->tlmWrite_CustomVersion04(verId_db[custom_slot]); break; case VER_SLOT_04: - this->tlmWrite_CUSTOM_VERSION_05(verId_db[cus_slot]); + this->tlmWrite_CustomVersion05(verId_db[custom_slot]); break; case VER_SLOT_05: - this->tlmWrite_CUSTOM_VERSION_06(verId_db[cus_slot]); + this->tlmWrite_CustomVersion06(verId_db[custom_slot]); break; case VER_SLOT_06: - this->tlmWrite_CUSTOM_VERSION_07(verId_db[cus_slot]); + this->tlmWrite_CustomVersion07(verId_db[custom_slot]); break; case VER_SLOT_07: - this->tlmWrite_CUSTOM_VERSION_08(verId_db[cus_slot]); + this->tlmWrite_CustomVersion08(verId_db[custom_slot]); break; case VER_SLOT_08: - this->tlmWrite_CUSTOM_VERSION_09(verId_db[cus_slot]); + this->tlmWrite_CustomVersion09(verId_db[custom_slot]); break; case VER_SLOT_09: - this->tlmWrite_CUSTOM_VERSION_10(verId_db[cus_slot]); + this->tlmWrite_CustomVersion10(verId_db[custom_slot]); break; default: //There are only 10 custom slots available - FW_ASSERT(0,cus_slot); + FW_ASSERT(0,custom_slot); break; } } diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 7d50c68d2f..4629859f96 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -3,8 +3,8 @@ module Svc { @ Tracks versions for project, framework and user defined versions etc enum VersionEnabled { - DISABLED = 0 - ENABLED = 1 + DISABLED = 0 @< verbosity disabled + ENABLED = 1 @< verbosity enabled } @ An enumeration for version status @@ -16,65 +16,53 @@ module Svc { @ An enumeration for Version Type enum VersionType { PROJECT = 0 @< project version - FRAMEWORK = 1 - LIBRARY = 2 - CUSTOM = 3 - ALL = 4 + FRAMEWORK = 1 @< framework version + LIBRARY = 2 @< library version + CUSTOM = 3 @< custom version + ALL = 4 @< all above versions } @ Port for setting and getting Versions - port Vers( + port Version( version_id: VersionCfg.VersionEnum @< The entry to access ref version_string: string @< The value to be passed ref status: VersionStatus @< The command response argument ) @Data Structure for custom version Tlm - struct CusVerDb { - ver_enum: VersionCfg.VersionEnum - ver_val: string size 80 - ver_status : VersionStatus + struct CustomVersionDb { + version_enum: VersionCfg.VersionEnum @*/ - bool startup_done; - U8 num_lib_elem; //number of library versions - U8 num_cus_elem; //number of custom versions - //const char* lib_ver_arr[]; // Store library versions internally - - + bool m_startup_done; + U8 m_num_lib_elem; //number of library versions + U8 m_num_cus_elem; //number of custom versions }; } diff --git a/Svc/Version/docs/sdd.md b/Svc/Version/docs/sdd.md index f4b948ad99..a3f74cde31 100644 --- a/Svc/Version/docs/sdd.md +++ b/Svc/Version/docs/sdd.md @@ -60,19 +60,19 @@ Add unit test descriptions in the chart below |---|---|---| |SVC-VERSION-001|`Svc::Version` upon startup shall generate an event and a telemetry channel with version for framework.| This is to provide transparency on framework version being used| |SVC-VERSION-002|`Svc::Version` upon startup shall generate an event and a telemetry channel with version for project | This is to provide transparency on project version being used| -|SVC-VERSION-003|`Svc::Version` upon startup shall generate events and telemetry channels (upto 10) with versions for libary.| Transparency on different library versions| +|SVC-VERSION-003|`Svc::Version` upon startup shall generate events and telemetry channels (upto 10) with versions for library.| Transparency on different library versions| |SVC-VERSION-004|`Svc::Version` upon startup shall make verbosity on custom versions configurable.| Transparency on different library versions| -|SVC-VERSION-005|`Svc::Version` shall provide a ground command to request events and telemetry on framework version| Accessiblity on demand| -|SVC-VERSION-006|`Svc::Version` shall provide a ground command to request events and telemetry on project version| Accessiblity on demand| -|SVC-VERSION-007|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on library versions| Accessiblity on demand| -|SVC-VERSION-008|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on custom versions| Accessiblity on demand| -|SVC-VERSION-009|`Svc::Version` shall provide a ground command to enable/disable verbosity on custom versions| Accessiblity on demand| -|SVC-VERSION-010|`Svc::Version` shall provide a telemetry channel on framework version| Accessiblity to versions being used| -|SVC-VERSION-011|`Svc::Version` shall provide a telemetry channel on project version| Accessiblity to versions being used| -|SVC-VERSION-012|`Svc::Version` shall provide upto 10 telemetry channels on library versions| Accessiblity to versions being used| -|SVC-VERSION-013|`Svc::Version` shall provide upto 10 telemetry channels on custom versions| Accessiblity to versions being used| -|SVC-VERSION-014|`Svc::Version` shall provide an interface for other components to set custom versions.| Enables projects to set hardware and FPGA versions, say, as needed. Also generates EVRs/EHAs| -|SVC-VERSION-015|`Svc::Version` shall provide an interface for other components to get custom versions.| Also generates EVRs/EHAs| +|SVC-VERSION-005|`Svc::Version` shall provide a ground command to request events and telemetry on framework version| Accessibility on demand| +|SVC-VERSION-006|`Svc::Version` shall provide a ground command to request events and telemetry on project version| Accessibility on demand| +|SVC-VERSION-007|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on library versions| Accessibility on demand| +|SVC-VERSION-008|`Svc::Version` shall provide a ground command to request events and telemetry channels (upto 10) on custom versions| Accessibility on demand| +|SVC-VERSION-009|`Svc::Version` shall provide a ground command to enable/disable verbosity on custom versions| Accessibility on demand| +|SVC-VERSION-010|`Svc::Version` shall provide a telemetry channel on framework version| Accessibility to versions being used| +|SVC-VERSION-011|`Svc::Version` shall provide a telemetry channel on project version| Accessibility to versions being used| +|SVC-VERSION-012|`Svc::Version` shall provide upto 10 telemetry channels on library versions| Accessibility to versions being used| +|SVC-VERSION-013|`Svc::Version` shall provide upto 10 telemetry channels on custom versions| Accessibility to versions being used| +|SVC-VERSION-014|`Svc::Version` shall provide an interface for other components to set custom versions.| Enables projects to set hardware and FPGA versions, say, as needed. Also generates Events/TLM| +|SVC-VERSION-015|`Svc::Version` shall provide an interface for other components to get custom versions.| Also generates Events/TLM| ## Change Log diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 0b016e9378..059707bb66 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -35,51 +35,51 @@ namespace Svc { void VersionTester :: clear_all() { this->clearHistory(); - ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(0); - ASSERT_EVENTS_PROJECT_VERSION_SIZE(0); - ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(0); - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(0); - ASSERT_TLM_FRAMEWORK_VERSION_SIZE(0); - ASSERT_TLM_PROJECT_VERSION_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_01_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_02_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_03_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_04_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_05_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_06_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_07_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_08_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_09_SIZE(0); - ASSERT_TLM_LIBRARY_VERSION_10_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_01_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_02_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_03_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_04_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_05_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_06_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_07_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_08_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_09_SIZE(0); - ASSERT_TLM_CUSTOM_VERSION_10_SIZE(0); + ASSERT_EVENTS_FrameworkVersion_SIZE(0); + ASSERT_EVENTS_ProjectVersion_SIZE(0); + ASSERT_EVENTS_LibraryVersions_SIZE(0); + ASSERT_EVENTS_CustomVersions_SIZE(0); + ASSERT_TLM_FrameworkVersion_SIZE(0); + ASSERT_TLM_ProjectVersion_SIZE(0); + ASSERT_TLM_LibraryVersion01_SIZE(0); + ASSERT_TLM_LibraryVersion02_SIZE(0); + ASSERT_TLM_LibraryVersion03_SIZE(0); + ASSERT_TLM_LibraryVersion04_SIZE(0); + ASSERT_TLM_LibraryVersion05_SIZE(0); + ASSERT_TLM_LibraryVersion06_SIZE(0); + ASSERT_TLM_LibraryVersion07_SIZE(0); + ASSERT_TLM_LibraryVersion08_SIZE(0); + ASSERT_TLM_LibraryVersion09_SIZE(0); + ASSERT_TLM_LibraryVersion10_SIZE(0); + ASSERT_TLM_CustomVersion01_SIZE(0); + ASSERT_TLM_CustomVersion02_SIZE(0); + ASSERT_TLM_CustomVersion03_SIZE(0); + ASSERT_TLM_CustomVersion04_SIZE(0); + ASSERT_TLM_CustomVersion05_SIZE(0); + ASSERT_TLM_CustomVersion06_SIZE(0); + ASSERT_TLM_CustomVersion07_SIZE(0); + ASSERT_TLM_CustomVersion08_SIZE(0); + ASSERT_TLM_CustomVersion09_SIZE(0); + ASSERT_TLM_CustomVersion10_SIZE(0); } // ---------------------------------------------------------------------- // Test STARTUP // ---------------------------------------------------------------------- void VersionTester :: test_startup() { - //this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after starttask() in RefTopology.cpp + //this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after startTasks() in RefTopology.cpp //ASSERT_EVENTS_STARTUP_EVR_SIZE(1); //ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); this->component.config(true); - ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); - ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); - ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); - ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); + ASSERT_EVENTS_FrameworkVersion_SIZE(1); + ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_ProjectVersion_SIZE(1); + ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); //Library versions currently set to a null pointer - //TODO: Need to figure out how to put in artifical sets to test them - ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); - ASSERT_EVENTS_LIBRARY_VERSIONS(0, "blah0 @ blah0"); + //TODO: Need to figure out how to put in artificial sets to test them + ASSERT_EVENTS_LibraryVersions_SIZE(12); + ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); } // ---------------------------------------------------------------------- @@ -93,14 +93,14 @@ namespace Svc { this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::DISABLED); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); VersionTester::test_setVer(false); - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(0); + ASSERT_EVENTS_CustomVersions_SIZE(0); cmd_seq = 9; this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::ENABLED); ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); VersionTester::test_setVer(true); - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + ASSERT_EVENTS_CustomVersions_SIZE(10); } @@ -111,110 +111,110 @@ namespace Svc { this->clear_all(); this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::FRAMEWORK); ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - ASSERT_TLM_FRAMEWORK_VERSION_SIZE(1); - ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); - ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_FrameworkVersion_SIZE(1); + ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_FrameworkVersion_SIZE(1); + ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); this->clear_all(); this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::PROJECT); ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - ASSERT_TLM_PROJECT_VERSION_SIZE(1); - ASSERT_TLM_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); - ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_ProjectVersion_SIZE(1); + ASSERT_TLM_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_ProjectVersion_SIZE(1); + ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); this->clear_all(); this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::LIBRARY); ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); //printf ("\nfirst lib element : %s\n\n", Project::Version::LIBRARY_VERSIONS[0]); - ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); + ASSERT_EVENTS_LibraryVersions_SIZE(12); - ASSERT_TLM_LIBRARY_VERSION_01_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_01(0, "blah0 @ blah0"); - ASSERT_EVENTS_LIBRARY_VERSIONS(0, "blah0 @ blah0"); + ASSERT_TLM_LibraryVersion01_SIZE(1); + ASSERT_TLM_LibraryVersion01(0, "blah0 @ blah0"); + ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); - ASSERT_TLM_LIBRARY_VERSION_02_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_02(0, "blah1 @ blah1"); - ASSERT_EVENTS_LIBRARY_VERSIONS(1, "blah1 @ blah1"); + ASSERT_TLM_LibraryVersion02_SIZE(1); + ASSERT_TLM_LibraryVersion02(0, "blah1 @ blah1"); + ASSERT_EVENTS_LibraryVersions(1, "blah1 @ blah1"); - ASSERT_TLM_LIBRARY_VERSION_03_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_03(0, "blah2 @ blah2"); - ASSERT_EVENTS_LIBRARY_VERSIONS(2, "blah2 @ blah2"); + ASSERT_TLM_LibraryVersion03_SIZE(1); + ASSERT_TLM_LibraryVersion03(0, "blah2 @ blah2"); + ASSERT_EVENTS_LibraryVersions(2, "blah2 @ blah2"); - ASSERT_TLM_LIBRARY_VERSION_04_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_04(0, "blah3 @ blah3"); - ASSERT_EVENTS_LIBRARY_VERSIONS(3, "blah3 @ blah3"); + ASSERT_TLM_LibraryVersion04_SIZE(1); + ASSERT_TLM_LibraryVersion04(0, "blah3 @ blah3"); + ASSERT_EVENTS_LibraryVersions(3, "blah3 @ blah3"); - ASSERT_TLM_LIBRARY_VERSION_05_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_05(0, "blah4 @ blah4"); - ASSERT_EVENTS_LIBRARY_VERSIONS(4, "blah4 @ blah4"); + ASSERT_TLM_LibraryVersion05_SIZE(1); + ASSERT_TLM_LibraryVersion05(0, "blah4 @ blah4"); + ASSERT_EVENTS_LibraryVersions(4, "blah4 @ blah4"); - ASSERT_TLM_LIBRARY_VERSION_06_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_06(0, "blah5 @ blah5"); - ASSERT_EVENTS_LIBRARY_VERSIONS(5, "blah5 @ blah5"); + ASSERT_TLM_LibraryVersion06_SIZE(1); + ASSERT_TLM_LibraryVersion06(0, "blah5 @ blah5"); + ASSERT_EVENTS_LibraryVersions(5, "blah5 @ blah5"); - ASSERT_TLM_LIBRARY_VERSION_07_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_07(0, "blah6 @ blah6"); - ASSERT_EVENTS_LIBRARY_VERSIONS(6, "blah6 @ blah6"); + ASSERT_TLM_LibraryVersion07_SIZE(1); + ASSERT_TLM_LibraryVersion07(0, "blah6 @ blah6"); + ASSERT_EVENTS_LibraryVersions(6, "blah6 @ blah6"); - ASSERT_TLM_LIBRARY_VERSION_08_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_08(0, "blah7 @ blah7"); - ASSERT_EVENTS_LIBRARY_VERSIONS(7, "blah7 @ blah7"); + ASSERT_TLM_LibraryVersion08_SIZE(1); + ASSERT_TLM_LibraryVersion08(0, "blah7 @ blah7"); + ASSERT_EVENTS_LibraryVersions(7, "blah7 @ blah7"); - ASSERT_TLM_LIBRARY_VERSION_09_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_09(0, "blah8 @ blah8"); - ASSERT_EVENTS_LIBRARY_VERSIONS(8, "blah8 @ blah8"); + ASSERT_TLM_LibraryVersion09_SIZE(1); + ASSERT_TLM_LibraryVersion09(0, "blah8 @ blah8"); + ASSERT_EVENTS_LibraryVersions(8, "blah8 @ blah8"); - ASSERT_TLM_LIBRARY_VERSION_10_SIZE(1); - ASSERT_TLM_LIBRARY_VERSION_10(0, "blah9 @ blah9"); - ASSERT_EVENTS_LIBRARY_VERSIONS(9, "blah9 @ blah9"); + ASSERT_TLM_LibraryVersion10_SIZE(1); + ASSERT_TLM_LibraryVersion10(0, "blah9 @ blah9"); + ASSERT_EVENTS_LibraryVersions(9, "blah9 @ blah9"); - ASSERT_EVENTS_LIBRARY_VERSIONS(10, "blah10 @ blah10"); + ASSERT_EVENTS_LibraryVersions(10, "blah10 @ blah10"); - ASSERT_EVENTS_LIBRARY_VERSIONS(11, "blah11 @ blah11"); + ASSERT_EVENTS_LibraryVersions(11, "blah11 @ blah11"); this->clear_all(); - Svc::CusVerDb cus_data_struct; + Svc::CustomVersionDb cus_data_struct; this->test_setVer(false); this->clear_all(); this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::CUSTOM); ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); + ASSERT_EVENTS_CustomVersions_SIZE(10); - ASSERT_EVENTS_CUSTOM_VERSIONS(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + ASSERT_EVENTS_CustomVersions(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_03(0, cus_data_struct); - ASSERT_TLM_CUSTOM_VERSION_03_SIZE(1); + ASSERT_TLM_CustomVersion03(0, cus_data_struct); + ASSERT_TLM_CustomVersion03_SIZE(1); - ASSERT_EVENTS_CUSTOM_VERSIONS(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + ASSERT_EVENTS_CustomVersions(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_04(0, cus_data_struct); - ASSERT_TLM_CUSTOM_VERSION_04_SIZE(1); + ASSERT_TLM_CustomVersion04(0, cus_data_struct); + ASSERT_TLM_CustomVersion04_SIZE(1); - ASSERT_EVENTS_CUSTOM_VERSIONS(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + ASSERT_EVENTS_CustomVersions(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_07(0, cus_data_struct); - ASSERT_TLM_CUSTOM_VERSION_07_SIZE(1); + ASSERT_TLM_CustomVersion07(0, cus_data_struct); + ASSERT_TLM_CustomVersion07_SIZE(1); - ASSERT_EVENTS_CUSTOM_VERSIONS(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + ASSERT_EVENTS_CustomVersions(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_10(0, cus_data_struct); - ASSERT_TLM_CUSTOM_VERSION_10_SIZE(1); + ASSERT_TLM_CustomVersion10(0, cus_data_struct); + ASSERT_TLM_CustomVersion10_SIZE(1); this->clear_all(); this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::ALL); ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - ASSERT_TLM_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_TLM_PROJECT_VERSION(0, Project::Version::PROJECT_VERSION); - ASSERT_EVENTS_FRAMEWORK_VERSION_SIZE(1); - ASSERT_EVENTS_FRAMEWORK_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_PROJECT_VERSION_SIZE(1); - ASSERT_EVENTS_PROJECT_VERSION(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); - ASSERT_EVENTS_LIBRARY_VERSIONS_SIZE(12); + ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); + ASSERT_EVENTS_FrameworkVersion_SIZE(1); + ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_ProjectVersion_SIZE(1); + ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_CustomVersions_SIZE(10); + ASSERT_EVENTS_LibraryVersions_SIZE(12); } void VersionTester :: test_commands() { @@ -229,10 +229,10 @@ namespace Svc { void VersionTester :: test_setVer(bool is_enabled) { Svc::VersionStatus status = Svc::VersionStatus::OK; - Svc::VersPortStrings::StringSize80 set_ver = "ver_2"; + Svc::VersionPortStrings::StringSize80 set_ver = "ver_2"; //Create a db to compare against set values - Svc::CusVerDb cus_data_struct; + Svc::CustomVersionDb cus_data_struct; //printf("\nTesting the very first port invocation\n"); //Start Clean @@ -242,28 +242,28 @@ namespace Svc { set_ver = "ver_0"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(1); - ASSERT_EVENTS_CUSTOM_VERSIONS(0,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00,"ver_0"); + ASSERT_EVENTS_CustomVersions_SIZE(1); + ASSERT_EVENTS_CustomVersions(0,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00,"ver_0"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_01(0, cus_data_struct); + ASSERT_TLM_CustomVersion01(0, cus_data_struct); } set_ver = "ver_1"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(2); - ASSERT_EVENTS_CUSTOM_VERSIONS(1,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01,"ver_1"); + ASSERT_EVENTS_CustomVersions_SIZE(2); + ASSERT_EVENTS_CustomVersions(1,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01,"ver_1"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_02(0, cus_data_struct); + ASSERT_TLM_CustomVersion02(0, cus_data_struct); } set_ver = "ver_2"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(3); - ASSERT_EVENTS_CUSTOM_VERSIONS(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + ASSERT_EVENTS_CustomVersions_SIZE(3); + ASSERT_EVENTS_CustomVersions(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_03(0, cus_data_struct); + ASSERT_TLM_CustomVersion03(0, cus_data_struct); } status = Svc::VersionStatus::FAILURE; @@ -271,37 +271,37 @@ namespace Svc { set_ver = "ver_3"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(4); - ASSERT_EVENTS_CUSTOM_VERSIONS(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + ASSERT_EVENTS_CustomVersions_SIZE(4); + ASSERT_EVENTS_CustomVersions(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_04(0, cus_data_struct); + ASSERT_TLM_CustomVersion04(0, cus_data_struct); } set_ver = "ver_4"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(5); - ASSERT_EVENTS_CUSTOM_VERSIONS(4,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04,"ver_4"); + ASSERT_EVENTS_CustomVersions_SIZE(5); + ASSERT_EVENTS_CustomVersions(4,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04,"ver_4"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_05(0, cus_data_struct); + ASSERT_TLM_CustomVersion05(0, cus_data_struct); } set_ver = "ver_5"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(6); - ASSERT_EVENTS_CUSTOM_VERSIONS(5,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05,"ver_5"); + ASSERT_EVENTS_CustomVersions_SIZE(6); + ASSERT_EVENTS_CustomVersions(5,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05,"ver_5"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_06(0, cus_data_struct); + ASSERT_TLM_CustomVersion06(0, cus_data_struct); } set_ver = "ver_6"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(7); - ASSERT_EVENTS_CUSTOM_VERSIONS(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + ASSERT_EVENTS_CustomVersions_SIZE(7); + ASSERT_EVENTS_CustomVersions(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CUSTOM_VERSION_07(0, cus_data_struct); + ASSERT_TLM_CustomVersion07(0, cus_data_struct); } status = Svc::VersionStatus::OK; @@ -309,28 +309,28 @@ namespace Svc { set_ver = "ver_7"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(8); - ASSERT_EVENTS_CUSTOM_VERSIONS(7,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07,"ver_7"); + ASSERT_EVENTS_CustomVersions_SIZE(8); + ASSERT_EVENTS_CustomVersions(7,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07,"ver_7"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_08(0, cus_data_struct); + ASSERT_TLM_CustomVersion08(0, cus_data_struct); } set_ver = "ver_8"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(9); - ASSERT_EVENTS_CUSTOM_VERSIONS(8,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08,"ver_8"); + ASSERT_EVENTS_CustomVersions_SIZE(9); + ASSERT_EVENTS_CustomVersions(8,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08,"ver_8"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_09(0, cus_data_struct); + ASSERT_TLM_CustomVersion09(0, cus_data_struct); } set_ver = "ver_9"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, status); if(is_enabled == true) { - ASSERT_EVENTS_CUSTOM_VERSIONS_SIZE(10); - ASSERT_EVENTS_CUSTOM_VERSIONS(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + ASSERT_EVENTS_CustomVersions_SIZE(10); + ASSERT_EVENTS_CustomVersions(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CUSTOM_VERSION_10(0, cus_data_struct); + ASSERT_TLM_CustomVersion10(0, cus_data_struct); } } @@ -338,7 +338,7 @@ namespace Svc { void VersionTester :: test_getVer() { Svc::VersionStatus status; - Svc::VersPortStrings::StringSize80 get_ver; + Svc::VersionPortStrings::StringSize80 get_ver; this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, get_ver, status); ASSERT_EQ(get_ver,"ver_2"); From b2eac8f7bf62c473a7232eb8934a7890d292f986 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 17:02:17 -0700 Subject: [PATCH 15/36] FP-2604: Format *.cpp files, create new Ports dir in Svc --- Svc/CMakeLists.txt | 1 + Svc/Ports/VersionPorts/CMakeLists.txt | 9 + Svc/Ports/VersionPorts/VersionPorts.fpp | 21 + Svc/Version/Version.cpp | 304 +++++++------- Svc/Version/Version.fpp | 17 +- Svc/Version/Version.hpp | 177 ++++----- Svc/Version/test/ut/VersionTestMain.cpp | 16 +- Svc/Version/test/ut/VersionTester.cpp | 398 +++++++++---------- Svc/Version/test/ut/VersionTester.hpp | 116 +++--- Svc/Version/test/ut/VersionTesterHelpers.cpp | 79 ++-- Svc/Version/test/ut/versions/version.hpp | 16 +- 11 files changed, 530 insertions(+), 624 deletions(-) create mode 100644 Svc/Ports/VersionPorts/CMakeLists.txt create mode 100644 Svc/Ports/VersionPorts/VersionPorts.fpp diff --git a/Svc/CMakeLists.txt b/Svc/CMakeLists.txt index 662388806c..1b4c7c6b4a 100644 --- a/Svc/CMakeLists.txt +++ b/Svc/CMakeLists.txt @@ -46,6 +46,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StaticMemory/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmChan/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmPacketizer/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SystemResources/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ports/VersionPorts/") # Text logger components included by default, # but can be disabled if FW_ENABLE_TEXT_LOGGING=0 is desired. diff --git a/Svc/Ports/VersionPorts/CMakeLists.txt b/Svc/Ports/VersionPorts/CMakeLists.txt new file mode 100644 index 0000000000..2d33657ab3 --- /dev/null +++ b/Svc/Ports/VersionPorts/CMakeLists.txt @@ -0,0 +1,9 @@ +#### +# CMakeLists.txt: +# +# Sets up the fprime module build within CMake. +#### +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/VersionPorts.fpp" +) +register_fprime_module() \ No newline at end of file diff --git a/Svc/Ports/VersionPorts/VersionPorts.fpp b/Svc/Ports/VersionPorts/VersionPorts.fpp new file mode 100644 index 0000000000..5f77cf15c3 --- /dev/null +++ b/Svc/Ports/VersionPorts/VersionPorts.fpp @@ -0,0 +1,21 @@ +##### +# Version Ports: +# +# A port setting/getting custom versions per project. +##### + +module Svc{ + + @ An enumeration for version status + enum VersionStatus { + OK = 0 @< Version was good + FAILURE = 1 @< Failure to get version + } + + @ Port for setting and getting Versions + port Version( + version_id: VersionCfg.VersionEnum @< The entry to access + ref version_string: string @< The value to be passed + ref status: VersionStatus @< The command response argument + ) +} diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 8b198ff598..cd17f66ad7 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -4,131 +4,100 @@ // \brief cpp file for Version component implementation class // ====================================================================== -#include "FpConfig.hpp" #include "Svc/Version/Version.hpp" +#include "FpConfig.hpp" #ifdef BUILD_UT - #include "test/ut/versions/version.hpp" //autogenerated file containing hardcoded project and framework versions +#include "test/ut/versions/version.hpp" //autogenerated file containing hardcoded project and framework versions #else - #include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions +#include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions #endif namespace Svc { - // ---------------------------------------------------------------------- - // Component construction and destruction - // ---------------------------------------------------------------------- +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- - Version :: - Version(const char* const compName) : - VersionComponentBase(compName) - { - m_startup_done = false; - m_num_lib_elem = 0; - m_num_cus_elem = 0; - m_enable = false; - Svc::VersionPortStrings::StringSize80 ver_str = "no_ver"; - // initialize all custom entries - for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { - //setver_enum is by default set to the first enum value, so not setting it here - verId_db[id].setversion_value(ver_str); - verId_db[id].setversion_status(VersionStatus::FAILURE); - } - } +Version ::Version(const char* const compName) + : VersionComponentBase(compName), m_enable(false), m_startup_done(false), m_num_lib_elem(0), m_num_cus_elem(0) { + Svc::VersionPortStrings::StringSize80 ver_str = "no_ver"; + // initialize all custom entries + for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { + // setver_enum is by default set to the first enum value, so not setting it here + verId_db[id].setversion_value(ver_str); + verId_db[id].setversion_status(VersionStatus::FAILURE); + } +} - Version :: - ~Version() - { +Version ::~Version() {} - } - - void Version::config(bool enable) { - //Set Verbosity for custom versions +void Version::config(bool enable) { + // Set Verbosity for custom versions m_enable = enable; - - //Setup and send startup TLM + // Setup and send startup TLM this->fwVersion_tlm(); this->projectVersion_tlm(); this->libraryVersion_tlm(); - } +} // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- -void Version :: - getVersion_handler( - FwIndexType portNum, - const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersionPortStrings::StringSize80& version_string, - Svc::VersionStatus& status - ) - { - FW_ASSERT(version_id.isValid(),version_id.e); - U8 version_slot = VersionSlot(version_id.e); - version_string = this->verId_db[version_slot].getversion_value(); - status = this->verId_db[version_slot].getversion_status(); - } +void Version ::getVersion_handler(FwIndexType portNum, + const Svc::VersionCfg::VersionEnum& version_id, + Svc::VersionPortStrings::StringSize80& version_string, + Svc::VersionStatus& status) { + FW_ASSERT(version_id.isValid(), version_id.e); + U8 version_slot = VersionSlot(version_id.e); + version_string = this->verId_db[version_slot].getversion_value(); + status = this->verId_db[version_slot].getversion_status(); +} - void Version :: - setVersion_handler( - FwIndexType portNum, - const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersionPortStrings::StringSize80& version_string, - Svc::VersionStatus& status - ) - { - FW_ASSERT(version_id.isValid(),version_id.e); - VersionSlot ver_slot = VersionSlot(version_id.e); - this->verId_db[ver_slot].setversion_enum(version_id); - this->verId_db[ver_slot].setversion_value(version_string); - this->verId_db[ver_slot].setversion_status(status); - this->m_num_cus_elem++; - this->customVersion_tlm(ver_slot); - } +void Version ::setVersion_handler(FwIndexType portNum, + const Svc::VersionCfg::VersionEnum& version_id, + Svc::VersionPortStrings::StringSize80& version_string, + Svc::VersionStatus& status) { + FW_ASSERT(version_id.isValid(), version_id.e); + VersionSlot ver_slot = VersionSlot(version_id.e); + this->verId_db[ver_slot].setversion_enum(version_id); + this->verId_db[ver_slot].setversion_value(version_string); + this->verId_db[ver_slot].setversion_status(status); + this->m_num_cus_elem++; + this->customVersion_tlm(ver_slot); +} - // ---------------------------------------------------------------------- - // Handler implementations for commands - // ---------------------------------------------------------------------- +// ---------------------------------------------------------------------- +// Handler implementations for commands +// ---------------------------------------------------------------------- - void Version :: - ENABLE_cmdHandler( - FwOpcodeType opCode, - U32 cmdSeq, - Svc::VersionEnabled enable - ) - { +void Version ::ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionEnabled enable) { m_enable = (enable == VersionEnabled::ENABLED); - + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); - } +} - //Command handler to event versions - void Version :: - VERSION_cmdHandler( - FwOpcodeType opCode, - U32 cmdSeq, - Svc::VersionType version_type - ) - { - //FW_ASSERT(version_type <= Svc::VersionType::ALL); - switch(version_type) { +// Command handler to event versions +void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionType version_type) { + // FW_ASSERT(version_type <= Svc::VersionType::ALL); + switch (version_type) { case (Svc::VersionType::PROJECT): this->projectVersion_tlm(); break; - + case (Svc::VersionType::FRAMEWORK): this->fwVersion_tlm(); break; - + case (Svc::VersionType::LIBRARY): this->libraryVersion_tlm(); break; - + case (Svc::VersionType::CUSTOM): this->customVersion_tlm_all(); break; - + case (Svc::VersionType::ALL): this->projectVersion_tlm(); this->fwVersion_tlm(); @@ -136,48 +105,48 @@ void Version :: this->customVersion_tlm_all(); break; default: - FW_ASSERT(0,version_type); - break; + FW_ASSERT(0, version_type); + break; } this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); - } - // ---------------------------------------------------------------------- - // implementations for internal functions - // ---------------------------------------------------------------------- - //Process libsv - void Version :: process_libraryVersion() { - m_num_lib_elem = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); - //m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); - if(Project::Version::LIBRARY_VERSIONS[0] == nullptr) { +} +// ---------------------------------------------------------------------- +// implementations for internal functions +// ---------------------------------------------------------------------- +// Process libsv +void Version ::process_libraryVersion() { + m_num_lib_elem = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); + // m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); + if (Project::Version::LIBRARY_VERSIONS[0] == nullptr) { m_num_lib_elem = 0; - } - } - - //functions to log tlm on versions - void Version :: fwVersion_tlm() { + } +} + +// functions to log tlm on versions +void Version ::fwVersion_tlm() { Fw::LogStringArg fw_event = (Project::Version::FRAMEWORK_VERSION); this->log_ACTIVITY_LO_FrameworkVersion(fw_event); Fw::TlmString fw_tlm = (Project::Version::FRAMEWORK_VERSION); this->tlmWrite_FrameworkVersion(fw_tlm); - } +} - void Version :: projectVersion_tlm() { +void Version ::projectVersion_tlm() { Fw::LogStringArg proj_event = Project::Version::PROJECT_VERSION; this->log_ACTIVITY_LO_ProjectVersion(proj_event); Fw::TlmString proj_tlm = Project::Version::PROJECT_VERSION; this->tlmWrite_ProjectVersion(proj_tlm); - } +} - void Version :: libraryVersion_tlm() { - //Process libraries array +void Version ::libraryVersion_tlm() { + // Process libraries array this->process_libraryVersion(); for (U8 i = 0; i < m_num_lib_elem; i++) { - //Emit Event/TLM on library versions + // Emit Event/TLM on library versions this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); - //Write to Events - switch(i) { + // Write to Events + switch (i) { case VER_SLOT_00: this->tlmWrite_LibraryVersion01(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; @@ -209,71 +178,68 @@ void Version :: this->tlmWrite_LibraryVersion10(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i])); break; default: - //It is possible to have more than 10 library versions; however design agreed to only - // provide 10 TLM channels for it + // It is possible to have more than 10 library versions; however design agreed to only + // provide 10 TLM channels for it break; } } +} - } - - void Version :: customVersion_tlm_all() { - for ( U8 i = 0; - (m_enable == true) && (m_num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); - i++) { - Version::customVersion_tlm(VersionSlot(i)); +void Version ::customVersion_tlm_all() { + for (U8 i = 0; (m_enable == true) && (m_num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); + i++) { + Version::customVersion_tlm(VersionSlot(i)); } - } +} + +void Version ::customVersion_tlm(VersionSlot custom_slot) { + // Process custom version TLM only if verbosity is enabled and there are any valid writes to it; + // it doesn't necessarily have to be consecutive + if ((this->verId_db[custom_slot].getversion_value() != "no_ver") && m_enable == true && + (m_num_cus_elem > 0)) { // Write TLM for valid writes - void Version :: customVersion_tlm(VersionSlot custom_slot) { - - //Process custom version TLM only if verbosity is enabled and there are any valid writes to it; - // it doesn't necessarily have to be consecutive - if( (this->verId_db[custom_slot].getversion_value() != "no_ver") - && m_enable == true - && (m_num_cus_elem > 0)) { //Write TLM for valid writes - - //Emit Events/TLM on library versions - this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].getversion_enum(), this->verId_db[custom_slot].getversion_value()); + // Emit Events/TLM on library versions + this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].getversion_enum(), + this->verId_db[custom_slot].getversion_value()); - //Write to TLM - switch(custom_slot) { - case VER_SLOT_00: - this->tlmWrite_CustomVersion01(verId_db[custom_slot]); - break; - case VER_SLOT_01: - this->tlmWrite_CustomVersion02(verId_db[custom_slot]); - break; - case VER_SLOT_02: - this->tlmWrite_CustomVersion03(verId_db[custom_slot]); - break; - case VER_SLOT_03: - this->tlmWrite_CustomVersion04(verId_db[custom_slot]); - break; - case VER_SLOT_04: - this->tlmWrite_CustomVersion05(verId_db[custom_slot]); - break; - case VER_SLOT_05: - this->tlmWrite_CustomVersion06(verId_db[custom_slot]); - break; - case VER_SLOT_06: - this->tlmWrite_CustomVersion07(verId_db[custom_slot]); - break; - case VER_SLOT_07: - this->tlmWrite_CustomVersion08(verId_db[custom_slot]); - break; - case VER_SLOT_08: - this->tlmWrite_CustomVersion09(verId_db[custom_slot]); - break; - case VER_SLOT_09: - this->tlmWrite_CustomVersion10(verId_db[custom_slot]); - break; - default: - //There are only 10 custom slots available - FW_ASSERT(0,custom_slot); - break; - } + // Write to TLM + switch (custom_slot) { + case VER_SLOT_00: + this->tlmWrite_CustomVersion01(verId_db[custom_slot]); + break; + case VER_SLOT_01: + this->tlmWrite_CustomVersion02(verId_db[custom_slot]); + break; + case VER_SLOT_02: + this->tlmWrite_CustomVersion03(verId_db[custom_slot]); + break; + case VER_SLOT_03: + this->tlmWrite_CustomVersion04(verId_db[custom_slot]); + break; + case VER_SLOT_04: + this->tlmWrite_CustomVersion05(verId_db[custom_slot]); + break; + case VER_SLOT_05: + this->tlmWrite_CustomVersion06(verId_db[custom_slot]); + break; + case VER_SLOT_06: + this->tlmWrite_CustomVersion07(verId_db[custom_slot]); + break; + case VER_SLOT_07: + this->tlmWrite_CustomVersion08(verId_db[custom_slot]); + break; + case VER_SLOT_08: + this->tlmWrite_CustomVersion09(verId_db[custom_slot]); + break; + case VER_SLOT_09: + this->tlmWrite_CustomVersion10(verId_db[custom_slot]); + break; + default: + // There are only 10 custom slots available + FW_ASSERT(0, custom_slot); + break; } } - } + +} // namespace Svc diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 4629859f96..e762745fba 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -7,12 +7,7 @@ module Svc { ENABLED = 1 @< verbosity enabled } - @ An enumeration for version status - enum VersionStatus { - OK = 0 @< Version was good - FAILURE = 1 @< Failure to get version - } - + @ An enumeration for Version Type enum VersionType { PROJECT = 0 @< project version @@ -22,19 +17,11 @@ module Svc { ALL = 4 @< all above versions } - - @ Port for setting and getting Versions - port Version( - version_id: VersionCfg.VersionEnum @< The entry to access - ref version_string: string @< The value to be passed - ref status: VersionStatus @< The command response argument - ) - @Data Structure for custom version Tlm struct CustomVersionDb { version_enum: VersionCfg.VersionEnum @*/ + bool m_enable; /*!*/ bool m_startup_done; - U8 m_num_lib_elem; //number of library versions - U8 m_num_cus_elem; //number of custom versions - }; + U8 m_num_lib_elem; // number of library versions + U8 m_num_cus_elem; // number of custom versions +}; -} +} // namespace Svc #endif diff --git a/Svc/Version/test/ut/VersionTestMain.cpp b/Svc/Version/test/ut/VersionTestMain.cpp index 1da68afea0..25845bb7ae 100644 --- a/Svc/Version/test/ut/VersionTestMain.cpp +++ b/Svc/Version/test/ut/VersionTestMain.cpp @@ -7,21 +7,21 @@ #include "VersionTester.hpp" TEST(Nominal, test_startup) { - Svc::VersionTester tester; - tester.test_startup(); + Svc::VersionTester tester; + tester.test_startup(); } TEST(Nominal, test_cmds) { - Svc::VersionTester tester; - tester.test_commands(); + Svc::VersionTester tester; + tester.test_commands(); } TEST(Nominal, test_ports) { - Svc::VersionTester tester; - tester.test_ports(); + Svc::VersionTester tester; + tester.test_ports(); } int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 059707bb66..c5ea8ef497 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -9,127 +9,113 @@ namespace Svc { - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- - - VersionTester :: - VersionTester() : - VersionGTestBase("VersionTester", VersionTester::MAX_HISTORY_SIZE), - component("Version") - { +// ---------------------------------------------------------------------- +// Construction and destruction +// ---------------------------------------------------------------------- + +VersionTester ::VersionTester() + : VersionGTestBase("VersionTester", VersionTester::MAX_HISTORY_SIZE), component("Version") { this->initComponents(); this->connectPorts(); - } - - VersionTester :: - ~VersionTester() - { - - } - - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- - //Clear/init test - void VersionTester :: clear_all() { - - this->clearHistory(); - ASSERT_EVENTS_FrameworkVersion_SIZE(0); - ASSERT_EVENTS_ProjectVersion_SIZE(0); - ASSERT_EVENTS_LibraryVersions_SIZE(0); - ASSERT_EVENTS_CustomVersions_SIZE(0); - ASSERT_TLM_FrameworkVersion_SIZE(0); - ASSERT_TLM_ProjectVersion_SIZE(0); - ASSERT_TLM_LibraryVersion01_SIZE(0); - ASSERT_TLM_LibraryVersion02_SIZE(0); - ASSERT_TLM_LibraryVersion03_SIZE(0); - ASSERT_TLM_LibraryVersion04_SIZE(0); - ASSERT_TLM_LibraryVersion05_SIZE(0); - ASSERT_TLM_LibraryVersion06_SIZE(0); - ASSERT_TLM_LibraryVersion07_SIZE(0); - ASSERT_TLM_LibraryVersion08_SIZE(0); - ASSERT_TLM_LibraryVersion09_SIZE(0); - ASSERT_TLM_LibraryVersion10_SIZE(0); - ASSERT_TLM_CustomVersion01_SIZE(0); - ASSERT_TLM_CustomVersion02_SIZE(0); - ASSERT_TLM_CustomVersion03_SIZE(0); - ASSERT_TLM_CustomVersion04_SIZE(0); - ASSERT_TLM_CustomVersion05_SIZE(0); - ASSERT_TLM_CustomVersion06_SIZE(0); - ASSERT_TLM_CustomVersion07_SIZE(0); - ASSERT_TLM_CustomVersion08_SIZE(0); - ASSERT_TLM_CustomVersion09_SIZE(0); - ASSERT_TLM_CustomVersion10_SIZE(0); - } - // ---------------------------------------------------------------------- - // Test STARTUP - // ---------------------------------------------------------------------- - void VersionTester :: test_startup() { - //this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after startTasks() in RefTopology.cpp - //ASSERT_EVENTS_STARTUP_EVR_SIZE(1); - //ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); - this->component.config(true); - ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); - ASSERT_EVENTS_FrameworkVersion_SIZE(1); - ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); - ASSERT_EVENTS_ProjectVersion_SIZE(1); - ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); - //Library versions currently set to a null pointer - //TODO: Need to figure out how to put in artificial sets to test them - ASSERT_EVENTS_LibraryVersions_SIZE(12); - ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); - } +} + +VersionTester ::~VersionTester() {} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- +// Clear/init test +void VersionTester ::clear_all() { + this->clearHistory(); + ASSERT_EVENTS_FrameworkVersion_SIZE(0); + ASSERT_EVENTS_ProjectVersion_SIZE(0); + ASSERT_EVENTS_LibraryVersions_SIZE(0); + ASSERT_EVENTS_CustomVersions_SIZE(0); + ASSERT_TLM_FrameworkVersion_SIZE(0); + ASSERT_TLM_ProjectVersion_SIZE(0); + ASSERT_TLM_LibraryVersion01_SIZE(0); + ASSERT_TLM_LibraryVersion02_SIZE(0); + ASSERT_TLM_LibraryVersion03_SIZE(0); + ASSERT_TLM_LibraryVersion04_SIZE(0); + ASSERT_TLM_LibraryVersion05_SIZE(0); + ASSERT_TLM_LibraryVersion06_SIZE(0); + ASSERT_TLM_LibraryVersion07_SIZE(0); + ASSERT_TLM_LibraryVersion08_SIZE(0); + ASSERT_TLM_LibraryVersion09_SIZE(0); + ASSERT_TLM_LibraryVersion10_SIZE(0); + ASSERT_TLM_CustomVersion01_SIZE(0); + ASSERT_TLM_CustomVersion02_SIZE(0); + ASSERT_TLM_CustomVersion03_SIZE(0); + ASSERT_TLM_CustomVersion04_SIZE(0); + ASSERT_TLM_CustomVersion05_SIZE(0); + ASSERT_TLM_CustomVersion06_SIZE(0); + ASSERT_TLM_CustomVersion07_SIZE(0); + ASSERT_TLM_CustomVersion08_SIZE(0); + ASSERT_TLM_CustomVersion09_SIZE(0); + ASSERT_TLM_CustomVersion10_SIZE(0); +} +// ---------------------------------------------------------------------- +// Test STARTUP +// ---------------------------------------------------------------------- +void VersionTester ::test_startup() { + // this->invoke_to_run(0,0); //No longer running version on a scheduler but invoked after startTasks() in + // RefTopology.cpp ASSERT_EVENTS_STARTUP_EVR_SIZE(1); + // ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); + this->component.config(true); + ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); + ASSERT_EVENTS_FrameworkVersion_SIZE(1); + ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); + ASSERT_EVENTS_ProjectVersion_SIZE(1); + ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); + // Library versions currently set to a null pointer + // TODO: Need to figure out how to put in artificial sets to test them + ASSERT_EVENTS_LibraryVersions_SIZE(12); + ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); +} + +// ---------------------------------------------------------------------- +// Test Commands +// ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- - // Test Commands - // ---------------------------------------------------------------------- - - void VersionTester :: - test_enable() - { +void VersionTester ::test_enable() { U32 cmd_seq = 9; - this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::DISABLED); - ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + this->sendCmd_ENABLE(0, cmd_seq, VersionEnabled::DISABLED); + ASSERT_CMD_RESPONSE(0, 0, 9, Fw::CmdResponse::OK); VersionTester::test_setVer(false); ASSERT_EVENTS_CustomVersions_SIZE(0); - cmd_seq = 9; - this->sendCmd_ENABLE(0,cmd_seq,VersionEnabled::ENABLED); - ASSERT_CMD_RESPONSE (0, 0, 9, Fw::CmdResponse::OK); + this->sendCmd_ENABLE(0, cmd_seq, VersionEnabled::ENABLED); + ASSERT_CMD_RESPONSE(0, 0, 9, Fw::CmdResponse::OK); VersionTester::test_setVer(true); ASSERT_EVENTS_CustomVersions_SIZE(10); +} - } - - void VersionTester :: - test_versions() - { +void VersionTester ::test_versions() { U32 cmd_seq = 9; this->clear_all(); - this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::FRAMEWORK); - ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::FRAMEWORK); + ASSERT_CMD_RESPONSE(0, 1, 9, Fw::CmdResponse::OK); ASSERT_TLM_FrameworkVersion_SIZE(1); ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); ASSERT_EVENTS_FrameworkVersion_SIZE(1); ASSERT_EVENTS_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); this->clear_all(); - this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::PROJECT); - ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::PROJECT); + ASSERT_CMD_RESPONSE(0, 1, 9, Fw::CmdResponse::OK); ASSERT_TLM_ProjectVersion_SIZE(1); ASSERT_TLM_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); ASSERT_EVENTS_ProjectVersion_SIZE(1); ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); - + this->clear_all(); - this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::LIBRARY); - ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - //printf ("\nfirst lib element : %s\n\n", Project::Version::LIBRARY_VERSIONS[0]); + this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::LIBRARY); + ASSERT_CMD_RESPONSE(0, 1, 9, Fw::CmdResponse::OK); + // printf ("\nfirst lib element : %s\n\n", Project::Version::LIBRARY_VERSIONS[0]); ASSERT_EVENTS_LibraryVersions_SIZE(12); - + ASSERT_TLM_LibraryVersion01_SIZE(1); ASSERT_TLM_LibraryVersion01(0, "blah0 @ blah0"); ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); @@ -174,39 +160,38 @@ namespace Svc { ASSERT_EVENTS_LibraryVersions(11, "blah11 @ blah11"); - this->clear_all(); Svc::CustomVersionDb cus_data_struct; this->test_setVer(false); this->clear_all(); - this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::CUSTOM); - ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); - + this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::CUSTOM); + ASSERT_CMD_RESPONSE(0, 1, 9, Fw::CmdResponse::OK); + ASSERT_EVENTS_CustomVersions_SIZE(10); - - ASSERT_EVENTS_CustomVersions(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + + ASSERT_EVENTS_CustomVersions(2, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion03(0, cus_data_struct); ASSERT_TLM_CustomVersion03_SIZE(1); - - ASSERT_EVENTS_CustomVersions(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + + ASSERT_EVENTS_CustomVersions(3, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion04(0, cus_data_struct); ASSERT_TLM_CustomVersion04_SIZE(1); - - ASSERT_EVENTS_CustomVersions(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + + ASSERT_EVENTS_CustomVersions(6, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion07(0, cus_data_struct); ASSERT_TLM_CustomVersion07_SIZE(1); - - ASSERT_EVENTS_CustomVersions(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + + ASSERT_EVENTS_CustomVersions(9, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion10(0, cus_data_struct); ASSERT_TLM_CustomVersion10_SIZE(1); - + this->clear_all(); - this->sendCmd_VERSION(0,cmd_seq,Svc::VersionType::ALL); - ASSERT_CMD_RESPONSE (0, 1, 9, Fw::CmdResponse::OK); + this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::ALL); + ASSERT_CMD_RESPONSE(0, 1, 9, Fw::CmdResponse::OK); ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); ASSERT_EVENTS_FrameworkVersion_SIZE(1); @@ -215,193 +200,190 @@ namespace Svc { ASSERT_EVENTS_ProjectVersion(0, Project::Version::FRAMEWORK_VERSION); ASSERT_EVENTS_CustomVersions_SIZE(10); ASSERT_EVENTS_LibraryVersions_SIZE(12); - } +} - void VersionTester :: test_commands() { +void VersionTester ::test_commands() { this->test_enable(); this->test_versions(); - } - - // ---------------------------------------------------------------------- - // Test User Ports - // ---------------------------------------------------------------------- - - void VersionTester :: test_setVer(bool is_enabled) { - +} + +// ---------------------------------------------------------------------- +// Test User Ports +// ---------------------------------------------------------------------- + +void VersionTester ::test_setVer(bool is_enabled) { Svc::VersionStatus status = Svc::VersionStatus::OK; Svc::VersionPortStrings::StringSize80 set_ver = "ver_2"; - //Create a db to compare against set values + // Create a db to compare against set values Svc::CustomVersionDb cus_data_struct; - //printf("\nTesting the very first port invocation\n"); + // printf("\nTesting the very first port invocation\n"); - //Start Clean + // Start Clean this->clear_all(); - //this->sendCmd_ENABLE(0,9,VersionEnabled::ENABLED); + // this->sendCmd_ENABLE(0,9,VersionEnabled::ENABLED); set_ver = "ver_0"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(1); - ASSERT_EVENTS_CustomVersions(0,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00,"ver_0"); + ASSERT_EVENTS_CustomVersions(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, "ver_0"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion01(0, cus_data_struct); } set_ver = "ver_1"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(2); - ASSERT_EVENTS_CustomVersions(1,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01,"ver_1"); + ASSERT_EVENTS_CustomVersions(1, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, "ver_1"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion02(0, cus_data_struct); } set_ver = "ver_2"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(3); - ASSERT_EVENTS_CustomVersions(2,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02,"ver_2"); + ASSERT_EVENTS_CustomVersions(2, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion03(0, cus_data_struct); } - + status = Svc::VersionStatus::FAILURE; set_ver = "ver_3"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(4); - ASSERT_EVENTS_CustomVersions(3,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03,"ver_3"); + ASSERT_EVENTS_CustomVersions(3, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion04(0, cus_data_struct); } - + set_ver = "ver_4"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(5); - ASSERT_EVENTS_CustomVersions(4,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04,"ver_4"); + ASSERT_EVENTS_CustomVersions(4, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, "ver_4"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion05(0, cus_data_struct); } - + set_ver = "ver_5"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(6); - ASSERT_EVENTS_CustomVersions(5,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05,"ver_5"); + ASSERT_EVENTS_CustomVersions(5, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, "ver_5"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion06(0, cus_data_struct); } - + set_ver = "ver_6"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(7); - ASSERT_EVENTS_CustomVersions(6,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06,"ver_6"); + ASSERT_EVENTS_CustomVersions(6, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion07(0, cus_data_struct); } - + status = Svc::VersionStatus::OK; - + set_ver = "ver_7"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(8); - ASSERT_EVENTS_CustomVersions(7,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07,"ver_7"); + ASSERT_EVENTS_CustomVersions(7, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, "ver_7"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion08(0, cus_data_struct); } set_ver = "ver_8"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(9); - ASSERT_EVENTS_CustomVersions(8,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08,"ver_8"); + ASSERT_EVENTS_CustomVersions(8, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, "ver_8"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion09(0, cus_data_struct); } set_ver = "ver_9"; this->invoke_to_setVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, status); - if(is_enabled == true) { + if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(10); - ASSERT_EVENTS_CustomVersions(9,Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09,"ver_9"); + ASSERT_EVENTS_CustomVersions(9, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9"); cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion10(0, cus_data_struct); } +} - } - - void VersionTester :: test_getVer() { - +void VersionTester ::test_getVer() { Svc::VersionStatus status; Svc::VersionPortStrings::StringSize80 get_ver; - + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, get_ver, status); - ASSERT_EQ(get_ver,"ver_2"); - ASSERT_EQ(status,Svc::VersionStatus::OK); - + ASSERT_EQ(get_ver, "ver_2"); + ASSERT_EQ(status, Svc::VersionStatus::OK); + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, get_ver, status); - ASSERT_EQ(get_ver,"ver_3"); - ASSERT_EQ(status,Svc::VersionStatus::FAILURE); - + ASSERT_EQ(get_ver, "ver_3"); + ASSERT_EQ(status, Svc::VersionStatus::FAILURE); + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, get_ver, status); - ASSERT_EQ(get_ver,"ver_6"); - ASSERT_EQ(status,Svc::VersionStatus::FAILURE); - + ASSERT_EQ(get_ver, "ver_6"); + ASSERT_EQ(status, Svc::VersionStatus::FAILURE); + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, get_ver, status); - ASSERT_EQ(get_ver,"ver_9"); - ASSERT_EQ(status,Svc::VersionStatus::OK); - + ASSERT_EQ(get_ver, "ver_9"); + ASSERT_EQ(status, Svc::VersionStatus::OK); + this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, get_ver, status); - ASSERT_EQ(get_ver,"ver_5"); - ASSERT_EQ(status,Svc::VersionStatus::FAILURE); - } + ASSERT_EQ(get_ver, "ver_5"); + ASSERT_EQ(status, Svc::VersionStatus::FAILURE); +} - void VersionTester::test_ports() { - this->sendCmd_ENABLE(0,9,VersionEnabled::ENABLED); +void VersionTester::test_ports() { + this->sendCmd_ENABLE(0, 9, VersionEnabled::ENABLED); this->test_setVer(true); this->test_getVer(); - } +} // ---------------------------------------------------------------------- // Helper methods // ---------------------------------------------------------------------- - /* - void VersionTester::connectPorts() { - // Connect custom ports - this->connect_to_run(0, this->component.get_run_InputPort(0)); - this->connect_to_getVersion (0, this->component.get_getVersion_InputPort(0)); - this->connect_to_setVersion (0, this->component.get_setVersion_InputPort(0)); - - // CmdIn - this->connect_to_cmdIn (0, this->component.get_cmdIn_InputPort(0)); - - // CmdReg - this->component.set_cmdRegOut_OutputPort(0,this->get_from_cmdRegOut(0)); - - // CmdStatus - this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); - - // Tlm - this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); - - // Time - this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); - - // Log - this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); - - // LogText - this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); - } - - void VersionTester::initComponents() { - this->init(); - this->component.init(0); - } - */ +/* +void VersionTester::connectPorts() { + // Connect custom ports + this->connect_to_run(0, this->component.get_run_InputPort(0)); + this->connect_to_getVersion (0, this->component.get_getVersion_InputPort(0)); + this->connect_to_setVersion (0, this->component.get_setVersion_InputPort(0)); + + // CmdIn + this->connect_to_cmdIn (0, this->component.get_cmdIn_InputPort(0)); + + // CmdReg + this->component.set_cmdRegOut_OutputPort(0,this->get_from_cmdRegOut(0)); + + // CmdStatus + this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); + + // Tlm + this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); + + // Time + this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); + + // Log + this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); + + // LogText + this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); +} + +void VersionTester::initComponents() { + this->init(); + this->component.init(0); } +*/ +} // namespace Svc diff --git a/Svc/Version/test/ut/VersionTester.hpp b/Svc/Version/test/ut/VersionTester.hpp index b36b3dd07e..a6dc0e1065 100644 --- a/Svc/Version/test/ut/VersionTester.hpp +++ b/Svc/Version/test/ut/VersionTester.hpp @@ -7,87 +7,79 @@ #ifndef Svc_VersionTester_HPP #define Svc_VersionTester_HPP -#include "Svc/Version/VersionGTestBase.hpp" #include "Svc/Version/Version.hpp" +#include "Svc/Version/VersionGTestBase.hpp" namespace Svc { - class VersionTester : - public VersionGTestBase - { - - public: - - // ---------------------------------------------------------------------- - // Constants - // ---------------------------------------------------------------------- - - // Maximum size of histories storing events, telemetry, and port outputs - static const FwSizeType MAX_HISTORY_SIZE = 100; - - // Instance ID supplied to the component instance under test - static const FwEnumStoreType TEST_INSTANCE_ID = 0; - - public: +class VersionTester : public VersionGTestBase { + public: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- - // Construction and destruction - // ---------------------------------------------------------------------- + // Maximum size of histories storing events, telemetry, and port outputs + static const FwSizeType MAX_HISTORY_SIZE = 100; - //! Construct object VersionTester - VersionTester(); + // Instance ID supplied to the component instance under test + static const FwEnumStoreType TEST_INSTANCE_ID = 0; - //! Destroy object VersionTester - ~VersionTester(); + public: + // ---------------------------------------------------------------------- + // Construction and destruction + // ---------------------------------------------------------------------- - public: + //! Construct object VersionTester + VersionTester(); - // ---------------------------------------------------------------------- - // Tests - // ---------------------------------------------------------------------- + //! Destroy object VersionTester + ~VersionTester(); - //! test startup EVR - void test_startup(); - - //! test enable command - void test_enable(); + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- - //! test version command - void test_versions(); - //! test all commands - void test_commands(); + //! test startup EVR + void test_startup(); - //! test get version - void test_getVer(); - //! test set version - void test_setVer(bool is_enabled); - //!test all ports - void test_ports(); - //clear history - void clear_all(); - private: + //! test enable command + void test_enable(); - // ---------------------------------------------------------------------- - // Helper functions - // ---------------------------------------------------------------------- + //! test version command + void test_versions(); + //! test all commands + void test_commands(); - //! Connect ports - void connectPorts(); + //! test get version + void test_getVer(); + //! test set version + void test_setVer(bool is_enabled); + //! test all ports + void test_ports(); + // clear history + void clear_all(); - //! Initialize components - void initComponents(); + private: + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- - private: + //! Connect ports + void connectPorts(); - // ---------------------------------------------------------------------- - // Member variables - // ---------------------------------------------------------------------- + //! Initialize components + void initComponents(); - //! The component under test - Version component; + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- - }; + //! The component under test + Version component; +}; -} +} // namespace Svc #endif diff --git a/Svc/Version/test/ut/VersionTesterHelpers.cpp b/Svc/Version/test/ut/VersionTesterHelpers.cpp index 8bf832ae08..3a6adbbcc7 100644 --- a/Svc/Version/test/ut/VersionTesterHelpers.cpp +++ b/Svc/Version/test/ut/VersionTesterHelpers.cpp @@ -8,75 +8,44 @@ namespace Svc { - // ---------------------------------------------------------------------- - // Helper functions - // ---------------------------------------------------------------------- +// ---------------------------------------------------------------------- +// Helper functions +// ---------------------------------------------------------------------- - void VersionTester :: - connectPorts() - { +void VersionTester ::connectPorts() { // Connect special input ports - this->connect_to_cmdIn( - 0, - this->component.get_cmdIn_InputPort(0) - ); + 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_cmdRegOut_OutputPort(0, this->get_from_cmdRegOut(0)); - this->component.set_cmdResponseOut_OutputPort( - 0, - this->get_from_cmdResponseOut(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_logOut_OutputPort(0, this->get_from_logOut(0)); - this->component.set_logTextOut_OutputPort( - 0, - this->get_from_logTextOut(0) - ); + this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); - this->component.set_timeCaller_OutputPort( - 0, - this->get_from_timeCaller(0) - ); + this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); - this->component.set_tlmOut_OutputPort( - 0, - this->get_from_tlmOut(0) - ); + this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); // Connect typed input ports - this->connect_to_getVersion( - 0, - this->component.get_getVersion_InputPort(0) - ); -/* - this->connect_to_run( - 0, - this->component.get_run_InputPort(0) - ); -*/ - this->connect_to_setVersion( - 0, - this->component.get_setVersion_InputPort(0) - ); - } - - void VersionTester :: - initComponents() - { + this->connect_to_getVersion(0, this->component.get_getVersion_InputPort(0)); + /* + this->connect_to_run( + 0, + this->component.get_run_InputPort(0) + ); + */ + this->connect_to_setVersion(0, this->component.get_setVersion_InputPort(0)); +} + +void VersionTester ::initComponents() { this->init(); this->component.init(VersionTester::TEST_INSTANCE_ID); - } - } + +} // namespace Svc diff --git a/Svc/Version/test/ut/versions/version.hpp b/Svc/Version/test/ut/versions/version.hpp index ca483df727..afaac3aa5f 100644 --- a/Svc/Version/test/ut/versions/version.hpp +++ b/Svc/Version/test/ut/versions/version.hpp @@ -1,6 +1,6 @@ /* This file is a replica of version.hpp generated using [generate_version_info.py]. - Replicated to have a fixed size and values for + Replicated to have a fixed size and values for */ #ifndef _VERSION_TESTER_HPP_ #define _VERSION_TESTER_HPP_ @@ -11,18 +11,8 @@ struct Version { static constexpr const char* const FRAMEWORK_VERSION = "v3.4.3-66-g5d50140f5"; static constexpr const char* const PROJECT_VERSION = "v3.4.3-66-g5d50140f5"; static constexpr const char* const LIBRARY_VERSIONS[] = { - "blah0 @ blah0" , - "blah1 @ blah1" , - "blah2 @ blah2" , - "blah3 @ blah3" , - "blah4 @ blah4" , - "blah5 @ blah5" , - "blah6 @ blah6" , - "blah7 @ blah7" , - "blah8 @ blah8" , - "blah9 @ blah9" , - "blah10 @ blah10" , - "blah11 @ blah11" , + "blah0 @ blah0", "blah1 @ blah1", "blah2 @ blah2", "blah3 @ blah3", "blah4 @ blah4", "blah5 @ blah5", + "blah6 @ blah6", "blah7 @ blah7", "blah8 @ blah8", "blah9 @ blah9", "blah10 @ blah10", "blah11 @ blah11", }; }; From 4e78ca5f4947d6accff76b0d695b61ef13d6dc47 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 17:38:16 -0700 Subject: [PATCH 16/36] FP-2604: Update spell check errors --- Svc/Version/Version.cpp | 18 +++++++++--------- Svc/Version/Version.fpp | 2 +- Svc/Version/Version.hpp | 12 ++---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index cd17f66ad7..2c7e22dc03 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -20,11 +20,11 @@ namespace Svc { // ---------------------------------------------------------------------- Version ::Version(const char* const compName) - : VersionComponentBase(compName), m_enable(false), m_startup_done(false), m_num_lib_elem(0), m_num_cus_elem(0) { + : VersionComponentBase(compName), m_enable(false), m_startup_done(false), m_num_library_elements(0), m_num_custom_elements(0) { Svc::VersionPortStrings::StringSize80 ver_str = "no_ver"; // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { - // setver_enum is by default set to the first enum value, so not setting it here + // setVersion_enum is by default set to the first enum value, so not setting it here verId_db[id].setversion_value(ver_str); verId_db[id].setversion_status(VersionStatus::FAILURE); } @@ -64,7 +64,7 @@ void Version ::setVersion_handler(FwIndexType portNum, this->verId_db[ver_slot].setversion_enum(version_id); this->verId_db[ver_slot].setversion_value(version_string); this->verId_db[ver_slot].setversion_status(status); - this->m_num_cus_elem++; + this->m_num_custom_elements++; this->customVersion_tlm(ver_slot); } @@ -114,12 +114,12 @@ void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionT // ---------------------------------------------------------------------- // implementations for internal functions // ---------------------------------------------------------------------- -// Process libsv +// Process library version void Version ::process_libraryVersion() { - m_num_lib_elem = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); + m_num_library_elements = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); // m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); if (Project::Version::LIBRARY_VERSIONS[0] == nullptr) { - m_num_lib_elem = 0; + m_num_library_elements = 0; } } @@ -142,7 +142,7 @@ void Version ::libraryVersion_tlm() { // Process libraries array this->process_libraryVersion(); - for (U8 i = 0; i < m_num_lib_elem; i++) { + for (U8 i = 0; i < m_num_library_elements; i++) { // Emit Event/TLM on library versions this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); // Write to Events @@ -186,7 +186,7 @@ void Version ::libraryVersion_tlm() { } void Version ::customVersion_tlm_all() { - for (U8 i = 0; (m_enable == true) && (m_num_cus_elem != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); + for (U8 i = 0; (m_enable == true) && (m_num_custom_elements != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); i++) { Version::customVersion_tlm(VersionSlot(i)); } @@ -196,7 +196,7 @@ void Version ::customVersion_tlm(VersionSlot custom_slot) { // Process custom version TLM only if verbosity is enabled and there are any valid writes to it; // it doesn't necessarily have to be consecutive if ((this->verId_db[custom_slot].getversion_value() != "no_ver") && m_enable == true && - (m_num_cus_elem > 0)) { // Write TLM for valid writes + (m_num_custom_elements > 0)) { // Write TLM for valid writes // Emit Events/TLM on library versions this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].getversion_enum(), diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index e762745fba..2e00d3fd72 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -70,7 +70,7 @@ module Svc { ) \ severity activity low \ id 2 \ - format "Libary Versions: [{}]" + format "Library Versions: [{}]" @ Version of the git repository. event CustomVersions( diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 9a60959a80..7ed5d9bdaf 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -32,14 +32,6 @@ class Version : public VersionComponentBase { // Handler implementations for user-defined typed input ports // ---------------------------------------------------------------------- - // No longer using a scheduler but driven by command only - //! Handler implementation for run - //! - // void - // run_handler(const NATIVE_INT_TYPE portNum, /*!< The port number*/ - // U32 context /*!< The call order*/ - //) override; - //! Handler implementation for getVersion //! //! Mutexed Port to get values @@ -111,8 +103,8 @@ class Version : public VersionComponentBase { void customVersion_tlm_all(); bool m_enable; /*!*/ bool m_startup_done; - U8 m_num_lib_elem; // number of library versions - U8 m_num_cus_elem; // number of custom versions + U8 m_num_library_elements; // number of library versions + U8 m_num_custom_elements; // number of custom versions }; } // namespace Svc From d420c185eb4e842b6f9fe20211d8b492ccf3a823 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 18:03:41 -0700 Subject: [PATCH 17/36] FP-2604: Check spell error fixes --- Svc/Version/Version.hpp | 2 +- Svc/Version/test/ut/VersionTester.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 7ed5d9bdaf..9f378c52bb 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -99,7 +99,7 @@ class Version : public VersionComponentBase { void fwVersion_tlm(); void projectVersion_tlm(); void libraryVersion_tlm(); - void customVersion_tlm(VersionSlot cus_slot); + void customVersion_tlm(VersionSlot custom_slot); void customVersion_tlm_all(); bool m_enable; /*!*/ bool m_startup_done; diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index c5ea8ef497..e53f624125 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -161,7 +161,7 @@ void VersionTester ::test_versions() { ASSERT_EVENTS_LibraryVersions(11, "blah11 @ blah11"); this->clear_all(); - Svc::CustomVersionDb cus_data_struct; + Svc::CustomVersionDb custom_data_struct; this->test_setVer(false); this->clear_all(); this->sendCmd_VERSION(0, cmd_seq, Svc::VersionType::CUSTOM); @@ -170,23 +170,23 @@ void VersionTester ::test_versions() { ASSERT_EVENTS_CustomVersions_SIZE(10); ASSERT_EVENTS_CustomVersions(2, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion03(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion03(0, custom_data_struct); ASSERT_TLM_CustomVersion03_SIZE(1); ASSERT_EVENTS_CustomVersions(3, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion04(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion04(0, custom_data_struct); ASSERT_TLM_CustomVersion04_SIZE(1); ASSERT_EVENTS_CustomVersions(6, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion07(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion07(0, custom_data_struct); ASSERT_TLM_CustomVersion07_SIZE(1); ASSERT_EVENTS_CustomVersions(9, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion10(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion10(0, custom_data_struct); ASSERT_TLM_CustomVersion10_SIZE(1); this->clear_all(); From 3d841383fdf97e58935d46872a431bf4c66fb009 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 18:40:02 -0700 Subject: [PATCH 18/36] FP-2604: Update spell check errors --- .github/actions/spelling/expect.txt | 1 + Svc/Version/test/ut/VersionTester.cpp | 42 +++++++++++++-------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 937b4de805..9493876998 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -932,6 +932,7 @@ setschedpolicy setstacksize settime settype +setversion sev sface sfregoso diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index e53f624125..343f2cd5d4 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -216,7 +216,7 @@ void VersionTester ::test_setVer(bool is_enabled) { Svc::VersionPortStrings::StringSize80 set_ver = "ver_2"; // Create a db to compare against set values - Svc::CustomVersionDb cus_data_struct; + Svc::CustomVersionDb custom_data_struct; // printf("\nTesting the very first port invocation\n"); // Start Clean @@ -228,8 +228,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(1); ASSERT_EVENTS_CustomVersions(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, "ver_0"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion01(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_00, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion01(0, custom_data_struct); } set_ver = "ver_1"; @@ -237,8 +237,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(2); ASSERT_EVENTS_CustomVersions(1, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, "ver_1"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion02(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_01, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion02(0, custom_data_struct); } set_ver = "ver_2"; @@ -246,8 +246,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(3); ASSERT_EVENTS_CustomVersions(2, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion03(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion03(0, custom_data_struct); } status = Svc::VersionStatus::FAILURE; @@ -257,8 +257,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(4); ASSERT_EVENTS_CustomVersions(3, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion04(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion04(0, custom_data_struct); } set_ver = "ver_4"; @@ -266,8 +266,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(5); ASSERT_EVENTS_CustomVersions(4, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, "ver_4"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion05(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_04, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion05(0, custom_data_struct); } set_ver = "ver_5"; @@ -275,8 +275,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(6); ASSERT_EVENTS_CustomVersions(5, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, "ver_5"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion06(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_05, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion06(0, custom_data_struct); } set_ver = "ver_6"; @@ -284,8 +284,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(7); ASSERT_EVENTS_CustomVersions(6, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, Svc::VersionStatus::FAILURE); - ASSERT_TLM_CustomVersion07(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, set_ver, Svc::VersionStatus::FAILURE); + ASSERT_TLM_CustomVersion07(0, custom_data_struct); } status = Svc::VersionStatus::OK; @@ -295,8 +295,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(8); ASSERT_EVENTS_CustomVersions(7, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, "ver_7"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion08(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_07, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion08(0, custom_data_struct); } set_ver = "ver_8"; @@ -304,8 +304,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(9); ASSERT_EVENTS_CustomVersions(8, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, "ver_8"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion09(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_08, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion09(0, custom_data_struct); } set_ver = "ver_9"; @@ -313,8 +313,8 @@ void VersionTester ::test_setVer(bool is_enabled) { if (is_enabled == true) { ASSERT_EVENTS_CustomVersions_SIZE(10); ASSERT_EVENTS_CustomVersions(9, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9"); - cus_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, Svc::VersionStatus::OK); - ASSERT_TLM_CustomVersion10(0, cus_data_struct); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, set_ver, Svc::VersionStatus::OK); + ASSERT_TLM_CustomVersion10(0, custom_data_struct); } } From 81742585208647795d513e581e3427806663ea4a Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 4 Jun 2024 19:21:26 -0700 Subject: [PATCH 19/36] FP-2604: Validated argument for version_types --- Svc/Version/Version.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 2c7e22dc03..0dd0075151 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -80,7 +80,9 @@ void Version ::ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionEn // Command handler to event versions void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionType version_type) { - // FW_ASSERT(version_type <= Svc::VersionType::ALL); + + FW_ASSERT(version_type.isValid(),version_type.e); + switch (version_type) { case (Svc::VersionType::PROJECT): this->projectVersion_tlm(); From ed36afb339b20b5ebb0bc719109952087c0ecc06 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 5 Jun 2024 10:28:11 -0700 Subject: [PATCH 20/36] FP-2604: Don't think this will make a difference with the CI errors seen in the pull request, but giving it a try --- Svc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Svc/CMakeLists.txt b/Svc/CMakeLists.txt index 1b4c7c6b4a..37de2e0110 100644 --- a/Svc/CMakeLists.txt +++ b/Svc/CMakeLists.txt @@ -46,7 +46,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StaticMemory/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmChan/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmPacketizer/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SystemResources/") -add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ports/VersionPorts/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ports/VersionPorts") # Text logger components included by default, # but can be disabled if FW_ENABLE_TEXT_LOGGING=0 is desired. From 8252982844bc8407195a2f8afa951eaf65612e97 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 5 Jun 2024 12:16:54 -0700 Subject: [PATCH 21/36] FP-2604: Updates to Version based on updates to Fw::StringBase --- Svc/Version/Version.cpp | 8 ++++---- Svc/Version/Version.hpp | 4 ++-- Svc/Version/test/ut/VersionTester.cpp | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 0dd0075151..25996880d0 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -21,11 +21,11 @@ namespace Svc { Version ::Version(const char* const compName) : VersionComponentBase(compName), m_enable(false), m_startup_done(false), m_num_library_elements(0), m_num_custom_elements(0) { - Svc::VersionPortStrings::StringSize80 ver_str = "no_ver"; + Fw::String version_string = "no_ver"; // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { // setVersion_enum is by default set to the first enum value, so not setting it here - verId_db[id].setversion_value(ver_str); + verId_db[id].setversion_value(version_string); verId_db[id].setversion_status(VersionStatus::FAILURE); } } @@ -47,7 +47,7 @@ void Version::config(bool enable) { void Version ::getVersion_handler(FwIndexType portNum, const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersionPortStrings::StringSize80& version_string, + Fw::StringBase& version_string, Svc::VersionStatus& status) { FW_ASSERT(version_id.isValid(), version_id.e); U8 version_slot = VersionSlot(version_id.e); @@ -57,7 +57,7 @@ void Version ::getVersion_handler(FwIndexType portNum, void Version ::setVersion_handler(FwIndexType portNum, const Svc::VersionCfg::VersionEnum& version_id, - Svc::VersionPortStrings::StringSize80& version_string, + Fw::StringBase& version_string, Svc::VersionStatus& status) { FW_ASSERT(version_id.isValid(), version_id.e); VersionSlot ver_slot = VersionSlot(version_id.e); diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 9f378c52bb..5520571ca5 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -37,7 +37,7 @@ class Version : public VersionComponentBase { //! Mutexed Port to get values void getVersion_handler(FwIndexType portNum, //!< The port number const Svc::VersionCfg::VersionEnum& version_id, //!< The entry to access - Svc::VersionPortStrings::StringSize80& version_string, //!< The value to be passed + Fw::StringBase& version_string, //!< The value to be passed Svc::VersionStatus& status //!< The command response argument ) override; @@ -46,7 +46,7 @@ class Version : public VersionComponentBase { //! Mutexed Port to set values void setVersion_handler(FwIndexType portNum, //!< The port number const Svc::VersionCfg::VersionEnum& version_id, //!< The entry to access - Svc::VersionPortStrings::StringSize80& version_string, //!< The value to be passed + Fw::StringBase& version_string, //!< The value to be passed Svc::VersionStatus& status //!< The command response argument ) override; diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 343f2cd5d4..0ed8d96189 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -170,22 +170,22 @@ void VersionTester ::test_versions() { ASSERT_EVENTS_CustomVersions_SIZE(10); ASSERT_EVENTS_CustomVersions(2, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2"); - custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, "ver_2", Svc::VersionStatus::OK); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, Fw::String("ver_2"), Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion03(0, custom_data_struct); ASSERT_TLM_CustomVersion03_SIZE(1); ASSERT_EVENTS_CustomVersions(3, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3"); - custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, "ver_3", Svc::VersionStatus::FAILURE); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_03, Fw::String("ver_3"), Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion04(0, custom_data_struct); ASSERT_TLM_CustomVersion04_SIZE(1); ASSERT_EVENTS_CustomVersions(6, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6"); - custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, "ver_6", Svc::VersionStatus::FAILURE); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_06, Fw::String("ver_6"), Svc::VersionStatus::FAILURE); ASSERT_TLM_CustomVersion07(0, custom_data_struct); ASSERT_TLM_CustomVersion07_SIZE(1); ASSERT_EVENTS_CustomVersions(9, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9"); - custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, "ver_9", Svc::VersionStatus::OK); + custom_data_struct.set(Svc::VersionCfg::VersionEnum::PROJECT_VERSION_09, Fw::String("ver_9"), Svc::VersionStatus::OK); ASSERT_TLM_CustomVersion10(0, custom_data_struct); ASSERT_TLM_CustomVersion10_SIZE(1); @@ -213,7 +213,7 @@ void VersionTester ::test_commands() { void VersionTester ::test_setVer(bool is_enabled) { Svc::VersionStatus status = Svc::VersionStatus::OK; - Svc::VersionPortStrings::StringSize80 set_ver = "ver_2"; + Fw::String set_ver = "ver_2"; // Create a db to compare against set values Svc::CustomVersionDb custom_data_struct; @@ -320,7 +320,7 @@ void VersionTester ::test_setVer(bool is_enabled) { void VersionTester ::test_getVer() { Svc::VersionStatus status; - Svc::VersionPortStrings::StringSize80 get_ver; + Fw::String get_ver; this->invoke_to_getVersion(0, Svc::VersionCfg::VersionEnum::PROJECT_VERSION_02, get_ver, status); ASSERT_EQ(get_ver, "ver_2"); From 364fc26de0ab09692f397068d8e0c7a30c37d9b5 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Mon, 10 Jun 2024 18:28:51 -0700 Subject: [PATCH 22/36] FP-2604: Fixing the memory allocation error for autocoded versions files --- Svc/SystemResources/CMakeLists.txt | 2 +- Svc/Version/CMakeLists.txt | 2 +- cmake/target/version.cmake | 5 ++- cmake/target/version/generate_version_info.py | 44 ++++++++++++++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Svc/SystemResources/CMakeLists.txt b/Svc/SystemResources/CMakeLists.txt index 2d2f91d49e..f1acc674b1 100644 --- a/Svc/SystemResources/CMakeLists.txt +++ b/Svc/SystemResources/CMakeLists.txt @@ -12,7 +12,7 @@ set(SOURCE_FILES ) set(MOD_DEPS Os - version + fprime_versions ) register_fprime_module() ### UTs ### diff --git a/Svc/Version/CMakeLists.txt b/Svc/Version/CMakeLists.txt index 49072b3df7..03eece1cb4 100644 --- a/Svc/Version/CMakeLists.txt +++ b/Svc/Version/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCE_FILES set(MOD_DEPS Os - version + fprime_versions ) register_fprime_module() diff --git a/cmake/target/version.cmake b/cmake/target/version.cmake index 8945e35d35..3288d17b1d 100644 --- a/cmake/target/version.cmake +++ b/cmake/target/version.cmake @@ -8,6 +8,7 @@ set(FPRIME_VERSION_INFO_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/version/generate_versi function(version_add_global_target TARGET) set(OUTPUT_DIR "${CMAKE_BINARY_DIR}/versions") set(OUTPUT_HPP "${OUTPUT_DIR}/version.hpp") + set(OUTPUT_CPP "${OUTPUT_DIR}/version.cpp") set(OUTPUT_JSON "${OUTPUT_DIR}/version.json") file(MAKE_DIRECTORY ${OUTPUT_DIR}) # Add check argument when requested @@ -16,7 +17,7 @@ function(version_add_global_target TARGET) if (FPRIME_CHECK_FRAMEWORK_VERSION) set(OPTIONAL_CHECK_ARG "--check") endif() - add_custom_target("${TARGET}" ALL BYPRODUCTS "${OUTPUT_HPP}" "${OUTPUT_JSON}" + add_custom_command(OUTPUT "${OUTPUT_HPP}" "${OUTPUT_CPP}" "${OUTPUT_JSON}" COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${PYTHONPATH}:${FPRIME_FRAMEWORK_PATH}/Autocoders/Python/src" "FPRIME_PROJECT_ROOT=${FPRIME_PROJECT_ROOT}" @@ -24,9 +25,11 @@ function(version_add_global_target TARGET) "FPRIME_LIBRARY_LOCATIONS=${FPRIME_LIBRARY_LOCATIONS_CSV}" "${FPRIME_VERSION_INFO_SCRIPT}" "${OUTPUT_DIR}" "${OPTIONAL_CHECK_ARG}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OUTPUT_HPP}.tmp" "${OUTPUT_HPP}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OUTPUT_CPP}.tmp" "${OUTPUT_CPP}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OUTPUT_JSON}.tmp" "${OUTPUT_JSON}" WORKING_DIRECTORY "${FPRIME_PROJECT_ROOT}" ) + add_library(fprime_versions "${OUTPUT_CPP}") endfunction() function(version_add_deployment_target MODULE TARGET SOURCES DEPENDENCIES FULL_DEPENDENCIES) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index b2d79033c8..98d599fee9 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -49,22 +49,55 @@ def create_version_file_hpp(output_dir, framework_version, project_version): fid.write("namespace Project {\n\n") fid.write("struct Version {\n") fid.write( - f' static constexpr const char* const FRAMEWORK_VERSION = "{framework_version}";\n' + f' static const char* const FRAMEWORK_VERSION;\n' ) fid.write( - f' static constexpr const char* const PROJECT_VERSION = "{project_version}";\n' + f' static const char* const PROJECT_VERSION;\n' + ) + lib_versions = get_library_versions() + if(len(lib_versions)) == 0: + fid.write(f" static const char* const LIBRARY_VERSIONS[1];\n") + else: + fid.write(f" static const char* const LIBRARY_VERSIONS[{len(lib_versions)}];\n") + fid.write("};\n\n") + fid.write("} // namespace Project\n") + fid.write("#endif\n") + + +def create_version_file_cpp(output_dir, framework_version, project_version): + """ + Create the version file using the provided name and path. + """ + version_cpp = Path(output_dir) / "version.cpp.tmp" + # Open file for writing + with open(version_cpp, "w") as fid: + fid.write("/*\n") + fid.write( + f" This file has been autogenerated using [{os.path.basename(__file__)}].\n" + ) + fid.write(" This file may be overwritten.\n") + fid.write("*/\n") + fid.write('#include "version.hpp"\n') + fid.write("\n") + + fid.write("namespace Project {\n\n") + fid.write( + f' constexpr const char* const Version::FRAMEWORK_VERSION = "{framework_version}";\n' + ) + fid.write( + f' constexpr const char* const Version::PROJECT_VERSION = "{project_version}";\n' ) lib_versions = get_library_versions() - fid.write(" static constexpr const char* const LIBRARY_VERSIONS[] = {\n") if len(lib_versions) == 0: + fid.write(f' constexpr const char* const Version::LIBRARY_VERSIONS[1] = {{ \n') fid.write(" nullptr\n") # nullptr when no libraries are present else: + fid.write(f' constexpr const char* const Version::LIBRARY_VERSIONS[{len(lib_versions)}] = {{ \n') for lib_name, version in lib_versions.items(): fid.write(f' "{lib_name}@{version}",\n') fid.write(" };\n") - fid.write("};\n\n") fid.write("} // namespace Project\n") - fid.write("#endif\n") + #fid.write("#endif\n") def create_version_file_json( @@ -107,6 +140,7 @@ def main(): project_version = get_project_version() lib_versions = get_library_versions() create_version_file_hpp(args.output_dir, fprime_version, project_version) + create_version_file_cpp(args.output_dir, fprime_version, project_version) create_version_file_json( args.output_dir, fprime_version, project_version, lib_versions ) From d8effeaad0e1f9602fb198fdb661cd4bab3643c2 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 11 Jun 2024 12:21:31 -0700 Subject: [PATCH 23/36] FP-2604: Fixed target name in version.cmake so ref/top/topology make rule isnt violated --- Ref/Top/RefPackets.xml | 44 +++++++++++++++--------------- Svc/SystemResources/CMakeLists.txt | 2 +- Svc/Version/CMakeLists.txt | 2 +- cmake/target/version.cmake | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Ref/Top/RefPackets.xml b/Ref/Top/RefPackets.xml index a68b99f193..a8e5204119 100644 --- a/Ref/Top/RefPackets.xml +++ b/Ref/Top/RefPackets.xml @@ -189,60 +189,60 @@ - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + diff --git a/Svc/SystemResources/CMakeLists.txt b/Svc/SystemResources/CMakeLists.txt index f1acc674b1..6fb9cfa7ea 100644 --- a/Svc/SystemResources/CMakeLists.txt +++ b/Svc/SystemResources/CMakeLists.txt @@ -12,7 +12,7 @@ set(SOURCE_FILES ) set(MOD_DEPS Os - fprime_versions + version ) register_fprime_module() ### UTs ### diff --git a/Svc/Version/CMakeLists.txt b/Svc/Version/CMakeLists.txt index 03eece1cb4..49072b3df7 100644 --- a/Svc/Version/CMakeLists.txt +++ b/Svc/Version/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCE_FILES set(MOD_DEPS Os - fprime_versions + version ) register_fprime_module() diff --git a/cmake/target/version.cmake b/cmake/target/version.cmake index 3288d17b1d..7aff3ca6a1 100644 --- a/cmake/target/version.cmake +++ b/cmake/target/version.cmake @@ -29,7 +29,7 @@ function(version_add_global_target TARGET) COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OUTPUT_JSON}.tmp" "${OUTPUT_JSON}" WORKING_DIRECTORY "${FPRIME_PROJECT_ROOT}" ) - add_library(fprime_versions "${OUTPUT_CPP}") + add_library("${TARGET}" "${OUTPUT_CPP}") endfunction() function(version_add_deployment_target MODULE TARGET SOURCES DEPENDENCIES FULL_DEPENDENCIES) From 83f6f76b5bd3ed4399fbefd10e7e96a0a84c06ff Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 11 Jun 2024 14:35:42 -0700 Subject: [PATCH 24/36] FP-2604: python file formatting error fix --- cmake/target/version/generate_version_info.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index 98d599fee9..eff71b48d0 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -100,9 +100,7 @@ def create_version_file_cpp(output_dir, framework_version, project_version): #fid.write("#endif\n") -def create_version_file_json( - output_dir: str, framework_version: str, project_version: str, lib_versions: dict -): +def create_version_file_json(output_dir: str, framework_version: str, project_version: str, lib_versions: dict): """ Create the version files using the provided name and path. """ From acc3367bcdfde5fc9a508e63189c5cc85f972caf Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 11 Jun 2024 14:55:15 -0700 Subject: [PATCH 25/36] FP-2604: version python script formatting --- cmake/target/version/generate_version_info.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index eff71b48d0..b207e6b91d 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -97,7 +97,6 @@ def create_version_file_cpp(output_dir, framework_version, project_version): fid.write(f' "{lib_name}@{version}",\n') fid.write(" };\n") fid.write("} // namespace Project\n") - #fid.write("#endif\n") def create_version_file_json(output_dir: str, framework_version: str, project_version: str, lib_versions: dict): @@ -105,11 +104,7 @@ def create_version_file_json(output_dir: str, framework_version: str, project_ve Create the version files using the provided name and path. """ json_file = Path(output_dir) / "version.json.tmp" - json_obj = { - "framework_version": framework_version, - "project_version": project_version, - "library_versions": lib_versions, - } + json_obj = { "framework_version": framework_version, "project_version": project_version, "library_versions": lib_versions} with open(json_file, "w") as file: json.dump(json_obj, file) From 0528ee45275dcc900bd60777b1f008d61c720130 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 11 Jun 2024 15:48:10 -0700 Subject: [PATCH 26/36] FP-2604: Trial/error format fixes on python script --- cmake/target/version/generate_version_info.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index b207e6b91d..23c779da9f 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -104,7 +104,10 @@ def create_version_file_json(output_dir: str, framework_version: str, project_ve Create the version files using the provided name and path. """ json_file = Path(output_dir) / "version.json.tmp" - json_obj = { "framework_version": framework_version, "project_version": project_version, "library_versions": lib_versions} + json_obj = {"framework_version": framework_version, + "project_version": project_version, + "library_versions": lib_versions + } with open(json_file, "w") as file: json.dump(json_obj, file) From f80da30ba00fe9df8dbc8a800f2b0d3e164ae1f1 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 12 Jun 2024 10:37:35 -0700 Subject: [PATCH 27/36] FP-2604: Reformatted python script --- cmake/target/version/generate_version_info.py | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index 23c779da9f..8b4059570f 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -48,17 +48,15 @@ def create_version_file_hpp(output_dir, framework_version, project_version): fid.write("namespace Project {\n\n") fid.write("struct Version {\n") - fid.write( - f' static const char* const FRAMEWORK_VERSION;\n' - ) - fid.write( - f' static const char* const PROJECT_VERSION;\n' - ) + fid.write(f" static const char* const FRAMEWORK_VERSION;\n") + fid.write(f" static const char* const PROJECT_VERSION;\n") lib_versions = get_library_versions() - if(len(lib_versions)) == 0: + if (len(lib_versions)) == 0: fid.write(f" static const char* const LIBRARY_VERSIONS[1];\n") else: - fid.write(f" static const char* const LIBRARY_VERSIONS[{len(lib_versions)}];\n") + fid.write( + f" static const char* const LIBRARY_VERSIONS[{len(lib_versions)}];\n" + ) fid.write("};\n\n") fid.write("} // namespace Project\n") fid.write("#endif\n") @@ -89,25 +87,32 @@ def create_version_file_cpp(output_dir, framework_version, project_version): ) lib_versions = get_library_versions() if len(lib_versions) == 0: - fid.write(f' constexpr const char* const Version::LIBRARY_VERSIONS[1] = {{ \n') + fid.write( + f" constexpr const char* const Version::LIBRARY_VERSIONS[1] = {{ \n" + ) fid.write(" nullptr\n") # nullptr when no libraries are present else: - fid.write(f' constexpr const char* const Version::LIBRARY_VERSIONS[{len(lib_versions)}] = {{ \n') + fid.write( + f" constexpr const char* const Version::LIBRARY_VERSIONS[{len(lib_versions)}] = {{ \n" + ) for lib_name, version in lib_versions.items(): fid.write(f' "{lib_name}@{version}",\n') fid.write(" };\n") fid.write("} // namespace Project\n") -def create_version_file_json(output_dir: str, framework_version: str, project_version: str, lib_versions: dict): +def create_version_file_json( + output_dir: str, framework_version: str, project_version: str, lib_versions: dict +): """ Create the version files using the provided name and path. """ json_file = Path(output_dir) / "version.json.tmp" - json_obj = {"framework_version": framework_version, - "project_version": project_version, - "library_versions": lib_versions - } + json_obj = { + "framework_version": framework_version, + "project_version": project_version, + "library_versions": lib_versions, + } with open(json_file, "w") as file: json.dump(json_obj, file) From a0c6bed8c32d9a5c3fd4480f175d04332961e916 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 12 Jun 2024 16:37:45 -0700 Subject: [PATCH 28/36] FP-2604: Updates to fix CI/linux errors --- Svc/Version/CMakeLists.txt | 1 + Svc/Version/Version.cpp | 11 +++----- Svc/Version/Version.hpp | 2 +- Svc/Version/test/ut/VersionTester.cpp | 2 ++ Svc/Version/test/ut/versions/version.hpp | 20 -------------- cmake/target/version/generate_version_info.py | 26 +++++++++++-------- 6 files changed, 23 insertions(+), 39 deletions(-) delete mode 100644 Svc/Version/test/ut/versions/version.hpp diff --git a/Svc/Version/CMakeLists.txt b/Svc/Version/CMakeLists.txt index 49072b3df7..7ba137288a 100644 --- a/Svc/Version/CMakeLists.txt +++ b/Svc/Version/CMakeLists.txt @@ -23,6 +23,7 @@ register_fprime_module() set(UT_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Version.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/version.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/VersionTester.cpp" "${CMAKE_CURRENT_LIST_DIR}/test/ut/VersionTestMain.cpp" ) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 25996880d0..8a3c754073 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -7,11 +7,7 @@ #include "Svc/Version/Version.hpp" #include "FpConfig.hpp" -#ifdef BUILD_UT -#include "test/ut/versions/version.hpp" //autogenerated file containing hardcoded project and framework versions -#else #include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions -#endif namespace Svc { @@ -117,6 +113,7 @@ void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionT // implementations for internal functions // ---------------------------------------------------------------------- // Process library version +/* void Version ::process_libraryVersion() { m_num_library_elements = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); // m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); @@ -124,7 +121,7 @@ void Version ::process_libraryVersion() { m_num_library_elements = 0; } } - +*/ // functions to log tlm on versions void Version ::fwVersion_tlm() { Fw::LogStringArg fw_event = (Project::Version::FRAMEWORK_VERSION); @@ -142,9 +139,9 @@ void Version ::projectVersion_tlm() { void Version ::libraryVersion_tlm() { // Process libraries array - this->process_libraryVersion(); + //this->process_libraryVersion(); - for (U8 i = 0; i < m_num_library_elements; i++) { + for (U8 i = 0; i < Project::Version::LIBRARY_VERSIONS_COUNT; i++) { // Emit Event/TLM on library versions this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); // Write to Events diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index 5520571ca5..b9b8bb6b27 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -94,7 +94,7 @@ class Version : public VersionComponentBase { VER_SLOT_09 = 9 }; - void process_libraryVersion(); + //void process_libraryVersion(); void process_CustomVersion(); void fwVersion_tlm(); void projectVersion_tlm(); diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 0ed8d96189..105bf9c66a 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -62,6 +62,7 @@ void VersionTester ::test_startup() { // RefTopology.cpp ASSERT_EVENTS_STARTUP_EVR_SIZE(1); // ASSERT_EVENTS_STARTUP_EVR(0,Project::Version::FRAMEWORK_VERSION,Project::Version::PROJECT_VERSION); this->component.config(true); + /* ASSERT_TLM_FrameworkVersion(0, Project::Version::FRAMEWORK_VERSION); ASSERT_TLM_ProjectVersion(0, Project::Version::PROJECT_VERSION); ASSERT_EVENTS_FrameworkVersion_SIZE(1); @@ -72,6 +73,7 @@ void VersionTester ::test_startup() { // TODO: Need to figure out how to put in artificial sets to test them ASSERT_EVENTS_LibraryVersions_SIZE(12); ASSERT_EVENTS_LibraryVersions(0, "blah0 @ blah0"); + */ } // ---------------------------------------------------------------------- diff --git a/Svc/Version/test/ut/versions/version.hpp b/Svc/Version/test/ut/versions/version.hpp deleted file mode 100644 index afaac3aa5f..0000000000 --- a/Svc/Version/test/ut/versions/version.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - This file is a replica of version.hpp generated using [generate_version_info.py]. - Replicated to have a fixed size and values for -*/ -#ifndef _VERSION_TESTER_HPP_ -#define _VERSION_TESTER_HPP_ - -namespace Project { - -struct Version { - static constexpr const char* const FRAMEWORK_VERSION = "v3.4.3-66-g5d50140f5"; - static constexpr const char* const PROJECT_VERSION = "v3.4.3-66-g5d50140f5"; - static constexpr const char* const LIBRARY_VERSIONS[] = { - "blah0 @ blah0", "blah1 @ blah1", "blah2 @ blah2", "blah3 @ blah3", "blah4 @ blah4", "blah5 @ blah5", - "blah6 @ blah6", "blah7 @ blah7", "blah8 @ blah8", "blah9 @ blah9", "blah10 @ blah10", "blah11 @ blah11", - }; -}; - -} // namespace Project -#endif diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index 8b4059570f..e1ee951945 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -45,18 +45,16 @@ def create_version_file_hpp(output_dir, framework_version, project_version): fid.write("#ifndef _VERSION_HPP_\n") fid.write("#define _VERSION_HPP_\n") fid.write("\n") + fid.write("#include \"FpConfig.h\"\n") fid.write("namespace Project {\n\n") fid.write("struct Version {\n") fid.write(f" static const char* const FRAMEWORK_VERSION;\n") fid.write(f" static const char* const PROJECT_VERSION;\n") - lib_versions = get_library_versions() - if (len(lib_versions)) == 0: - fid.write(f" static const char* const LIBRARY_VERSIONS[1];\n") - else: - fid.write( - f" static const char* const LIBRARY_VERSIONS[{len(lib_versions)}];\n" - ) + fid.write( + f" static const FwIndexType LIBRARY_VERSIONS_COUNT; \n" + ) + fid.write(f" static const char* const LIBRARY_VERSIONS[];\n") fid.write("};\n\n") fid.write("} // namespace Project\n") fid.write("#endif\n") @@ -80,20 +78,26 @@ def create_version_file_cpp(output_dir, framework_version, project_version): fid.write("namespace Project {\n\n") fid.write( - f' constexpr const char* const Version::FRAMEWORK_VERSION = "{framework_version}";\n' + f' const char* const Version::FRAMEWORK_VERSION = "{framework_version}";\n' ) fid.write( - f' constexpr const char* const Version::PROJECT_VERSION = "{project_version}";\n' + f' const char* const Version::PROJECT_VERSION = "{project_version}";\n' ) lib_versions = get_library_versions() if len(lib_versions) == 0: fid.write( - f" constexpr const char* const Version::LIBRARY_VERSIONS[1] = {{ \n" + f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = 0; \n" + ) + fid.write( + f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n" ) fid.write(" nullptr\n") # nullptr when no libraries are present else: fid.write( - f" constexpr const char* const Version::LIBRARY_VERSIONS[{len(lib_versions)}] = {{ \n" + f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = {len(lib_versions)}; \n" + ) + fid.write( + f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n" ) for lib_name, version in lib_versions.items(): fid.write(f' "{lib_name}@{version}",\n') From a8c506c4e63f5be8caaff1025c954184b58acc31 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 12 Jun 2024 16:42:07 -0700 Subject: [PATCH 29/36] FP-2604: Add UT version for version.cpp --- Svc/Version/test/ut/version.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Svc/Version/test/ut/version.cpp diff --git a/Svc/Version/test/ut/version.cpp b/Svc/Version/test/ut/version.cpp new file mode 100644 index 0000000000..697f99ac97 --- /dev/null +++ b/Svc/Version/test/ut/version.cpp @@ -0,0 +1,16 @@ +/* + This file has been autogenerated using [generate_version_info.py]. + This file may be overwritten. +*/ +#include "versions/version.hpp" + +namespace Project { + + const char* const Version::FRAMEWORK_VERSION = "v3.4.3-107-gf80da30ba"; + const char* const Version::PROJECT_VERSION = "v3.4.3-107-gf80da30ba"; + const FwIndexType Version::LIBRARY_VERSIONS_COUNT = 12; + const char* const Version::LIBRARY_VERSIONS[] = { + "blah0 @ blah0", "blah1 @ blah1", "blah2 @ blah2", "blah3 @ blah3", "blah4 @ blah4", "blah5 @ blah5", + "blah6 @ blah6", "blah7 @ blah7", "blah8 @ blah8", "blah9 @ blah9", "blah10 @ blah10", "blah11 @ blah11", + }; +} // namespace Project From ab83a41b887594ccf6840982030104fa5eedf2a8 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Wed, 12 Jun 2024 17:08:24 -0700 Subject: [PATCH 30/36] FP-2604: Formatting and styling updates --- Svc/Version/Version.cpp | 23 +++++-------------- cmake/target/version/generate_version_info.py | 18 ++++----------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 8a3c754073..55c8a05e39 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -21,8 +21,8 @@ Version ::Version(const char* const compName) // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { // setVersion_enum is by default set to the first enum value, so not setting it here - verId_db[id].setversion_value(version_string); - verId_db[id].setversion_status(VersionStatus::FAILURE); + this->verId_db[id].setversion_value(version_string); + this->verId_db[id].setversion_status(VersionStatus::FAILURE); } } @@ -30,7 +30,7 @@ Version ::~Version() {} void Version::config(bool enable) { // Set Verbosity for custom versions - m_enable = enable; + this->m_enable = enable; // Setup and send startup TLM this->fwVersion_tlm(); @@ -69,7 +69,7 @@ void Version ::setVersion_handler(FwIndexType portNum, // ---------------------------------------------------------------------- void Version ::ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionEnabled enable) { - m_enable = (enable == VersionEnabled::ENABLED); + this->m_enable = (enable == VersionEnabled::ENABLED); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); } @@ -112,16 +112,6 @@ void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::VersionT // ---------------------------------------------------------------------- // implementations for internal functions // ---------------------------------------------------------------------- -// Process library version -/* -void Version ::process_libraryVersion() { - m_num_library_elements = static_cast(FW_NUM_ARRAY_ELEMENTS(Project::Version::LIBRARY_VERSIONS)); - // m_num_lib_elem = sizeof(Project::Version::LIBRARY_VERSIONS)/sizeof(Project::Version::LIBRARY_VERSIONS[0]); - if (Project::Version::LIBRARY_VERSIONS[0] == nullptr) { - m_num_library_elements = 0; - } -} -*/ // functions to log tlm on versions void Version ::fwVersion_tlm() { Fw::LogStringArg fw_event = (Project::Version::FRAMEWORK_VERSION); @@ -138,9 +128,8 @@ void Version ::projectVersion_tlm() { } void Version ::libraryVersion_tlm() { - // Process libraries array - //this->process_libraryVersion(); + // Process libraries array for (U8 i = 0; i < Project::Version::LIBRARY_VERSIONS_COUNT; i++) { // Emit Event/TLM on library versions this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i])); @@ -195,7 +184,7 @@ void Version ::customVersion_tlm(VersionSlot custom_slot) { // Process custom version TLM only if verbosity is enabled and there are any valid writes to it; // it doesn't necessarily have to be consecutive if ((this->verId_db[custom_slot].getversion_value() != "no_ver") && m_enable == true && - (m_num_custom_elements > 0)) { // Write TLM for valid writes + (this->m_num_custom_elements > 0)) { // Write TLM for valid writes // Emit Events/TLM on library versions this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].getversion_enum(), diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index e1ee951945..55229c224c 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -45,15 +45,13 @@ def create_version_file_hpp(output_dir, framework_version, project_version): fid.write("#ifndef _VERSION_HPP_\n") fid.write("#define _VERSION_HPP_\n") fid.write("\n") - fid.write("#include \"FpConfig.h\"\n") + fid.write('#include "FpConfig.h"\n') fid.write("namespace Project {\n\n") fid.write("struct Version {\n") fid.write(f" static const char* const FRAMEWORK_VERSION;\n") fid.write(f" static const char* const PROJECT_VERSION;\n") - fid.write( - f" static const FwIndexType LIBRARY_VERSIONS_COUNT; \n" - ) + fid.write(f" static const FwIndexType LIBRARY_VERSIONS_COUNT; \n") fid.write(f" static const char* const LIBRARY_VERSIONS[];\n") fid.write("};\n\n") fid.write("} // namespace Project\n") @@ -85,20 +83,14 @@ def create_version_file_cpp(output_dir, framework_version, project_version): ) lib_versions = get_library_versions() if len(lib_versions) == 0: - fid.write( - f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = 0; \n" - ) - fid.write( - f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n" - ) + fid.write(f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = 0; \n") + fid.write(f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n") fid.write(" nullptr\n") # nullptr when no libraries are present else: fid.write( f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = {len(lib_versions)}; \n" ) - fid.write( - f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n" - ) + fid.write(f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n") for lib_name, version in lib_versions.items(): fid.write(f' "{lib_name}@{version}",\n') fid.write(" };\n") From 0e61c22fa2300be78fe39abc26c6cdea508f1ab4 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Jun 2024 19:09:46 -0700 Subject: [PATCH 31/36] Delete Svc/Version/test/ut/VersionTesterHelpers.cpp Deleting unneeded test helper file --- Svc/Version/test/ut/VersionTesterHelpers.cpp | 51 -------------------- 1 file changed, 51 deletions(-) delete mode 100644 Svc/Version/test/ut/VersionTesterHelpers.cpp diff --git a/Svc/Version/test/ut/VersionTesterHelpers.cpp b/Svc/Version/test/ut/VersionTesterHelpers.cpp deleted file mode 100644 index 3a6adbbcc7..0000000000 --- a/Svc/Version/test/ut/VersionTesterHelpers.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// ====================================================================== -// \title VersionTesterHelpers.cpp -// \author Generated by fpp-to-cpp -// \brief cpp file for Version component test harness helper functions -// ====================================================================== - -#include "VersionTester.hpp" - -namespace Svc { - -// ---------------------------------------------------------------------- -// Helper functions -// ---------------------------------------------------------------------- - -void VersionTester ::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_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_getVersion(0, this->component.get_getVersion_InputPort(0)); - /* - this->connect_to_run( - 0, - this->component.get_run_InputPort(0) - ); - */ - this->connect_to_setVersion(0, this->component.get_setVersion_InputPort(0)); -} - -void VersionTester ::initComponents() { - this->init(); - this->component.init(VersionTester::TEST_INSTANCE_ID); -} - -} // namespace Svc From d43dc24c109d82a78599072df341f29f7e962125 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Jun 2024 19:10:54 -0700 Subject: [PATCH 32/36] Deleting dead code in test --- Svc/Version/test/ut/VersionTester.cpp | 38 --------------------------- 1 file changed, 38 deletions(-) diff --git a/Svc/Version/test/ut/VersionTester.cpp b/Svc/Version/test/ut/VersionTester.cpp index 105bf9c66a..7fa4f40f01 100644 --- a/Svc/Version/test/ut/VersionTester.cpp +++ b/Svc/Version/test/ut/VersionTester.cpp @@ -350,42 +350,4 @@ void VersionTester::test_ports() { this->test_setVer(true); this->test_getVer(); } - -// ---------------------------------------------------------------------- -// Helper methods -// ---------------------------------------------------------------------- -/* -void VersionTester::connectPorts() { - // Connect custom ports - this->connect_to_run(0, this->component.get_run_InputPort(0)); - this->connect_to_getVersion (0, this->component.get_getVersion_InputPort(0)); - this->connect_to_setVersion (0, this->component.get_setVersion_InputPort(0)); - - // CmdIn - this->connect_to_cmdIn (0, this->component.get_cmdIn_InputPort(0)); - - // CmdReg - this->component.set_cmdRegOut_OutputPort(0,this->get_from_cmdRegOut(0)); - - // CmdStatus - this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0)); - - // Tlm - this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0)); - - // Time - this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0)); - - // Log - this->component.set_logOut_OutputPort(0, this->get_from_logOut(0)); - - // LogText - this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0)); -} - -void VersionTester::initComponents() { - this->init(); - this->component.init(0); -} -*/ } // namespace Svc From 0ad18281d32cce231e7f06cc1107ada2753b1535 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Jun 2024 19:12:53 -0700 Subject: [PATCH 33/36] Removing blanks in SDD --- Svc/Version/docs/sdd.md | 57 +++-------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/Svc/Version/docs/sdd.md b/Svc/Version/docs/sdd.md index a3f74cde31..6fe1b50bd1 100644 --- a/Svc/Version/docs/sdd.md +++ b/Svc/Version/docs/sdd.md @@ -2,58 +2,6 @@ Tracks versions for framework,project, libraries and user defined project specific versions. -## 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 | Name | Description | Validation | @@ -74,8 +22,11 @@ Add unit test descriptions in the chart below |SVC-VERSION-014|`Svc::Version` shall provide an interface for other components to set custom versions.| Enables projects to set hardware and FPGA versions, say, as needed. Also generates Events/TLM| |SVC-VERSION-015|`Svc::Version` shall provide an interface for other components to get custom versions.| Also generates Events/TLM| +## Emitting Versions on Start-Up + +The version component can emit versions on startup by calling `version.config(true);` during component configuration. ## Change Log | Date | Description | |---|---| -|---| Initial Draft | \ No newline at end of file +|---| Initial Draft | From dd5af247f1b492e37c94d48e9be4aa004a28e202 Mon Sep 17 00:00:00 2001 From: M Starch Date: Wed, 12 Jun 2024 19:14:18 -0700 Subject: [PATCH 34/36] Removing parameter ports (unused) --- Svc/Version/Version.fpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 2e00d3fd72..31ce26bb69 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -134,12 +134,5 @@ module Svc { @ 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 - } -} \ No newline at end of file +} From f8f0f165aed876f3958482851f7cc78b88fca0a0 Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 9 Jul 2024 13:26:41 -0700 Subject: [PATCH 35/36] FP-2604: Updates to versions based on peer review comments and code scrubbing --- Svc/Version/Version.cpp | 2 +- Svc/Version/Version.fpp | 1 - Svc/Version/Version.hpp | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Svc/Version/Version.cpp b/Svc/Version/Version.cpp index 55c8a05e39..c659ce688d 100644 --- a/Svc/Version/Version.cpp +++ b/Svc/Version/Version.cpp @@ -16,7 +16,7 @@ namespace Svc { // ---------------------------------------------------------------------- Version ::Version(const char* const compName) - : VersionComponentBase(compName), m_enable(false), m_startup_done(false), m_num_library_elements(0), m_num_custom_elements(0) { + : VersionComponentBase(compName), m_enable(false), m_num_custom_elements(0) { Fw::String version_string = "no_ver"; // initialize all custom entries for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) { diff --git a/Svc/Version/Version.fpp b/Svc/Version/Version.fpp index 31ce26bb69..174fc8fc01 100644 --- a/Svc/Version/Version.fpp +++ b/Svc/Version/Version.fpp @@ -1,7 +1,6 @@ module Svc { @ Tracks versions for project, framework and user defined versions etc - enum VersionEnabled { DISABLED = 0 @< verbosity disabled ENABLED = 1 @< verbosity enabled diff --git a/Svc/Version/Version.hpp b/Svc/Version/Version.hpp index b9b8bb6b27..5471c86436 100644 --- a/Svc/Version/Version.hpp +++ b/Svc/Version/Version.hpp @@ -94,16 +94,16 @@ class Version : public VersionComponentBase { VER_SLOT_09 = 9 }; - //void process_libraryVersion(); - void process_CustomVersion(); - void fwVersion_tlm(); - void projectVersion_tlm(); + // function to log framework version events and channels + void fwVersion_tlm(); + // function to log project version events and channels + void projectVersion_tlm(); + // function to log library version events and channels void libraryVersion_tlm(); + // function to log custom version events and channels void customVersion_tlm(VersionSlot custom_slot); void customVersion_tlm_all(); bool m_enable; /*!*/ - bool m_startup_done; - U8 m_num_library_elements; // number of library versions U8 m_num_custom_elements; // number of custom versions }; From bb652165e319f726047a8cdaf08f6fa4e9da737e Mon Sep 17 00:00:00 2001 From: Shivaly Date: Tue, 9 Jul 2024 13:28:07 -0700 Subject: [PATCH 36/36] FP-2604: Formatting fixes --- cmake/target/version/generate_version_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/target/version/generate_version_info.py b/cmake/target/version/generate_version_info.py index 55229c224c..ea04becf03 100755 --- a/cmake/target/version/generate_version_info.py +++ b/cmake/target/version/generate_version_info.py @@ -85,7 +85,7 @@ def create_version_file_cpp(output_dir, framework_version, project_version): if len(lib_versions) == 0: fid.write(f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = 0; \n") fid.write(f" const char* const Version::LIBRARY_VERSIONS[] = {{ \n") - fid.write(" nullptr\n") # nullptr when no libraries are present + fid.write(" nullptr\n") # nullptr when no libraries are present else: fid.write( f" const FwIndexType Version::LIBRARY_VERSIONS_COUNT = {len(lib_versions)}; \n"