fprime/Ref/Top/RefTopology.cpp
Moises Mata d69b7a10d1
Add Core Subtopologies: ComFprime, ComCcsds, DataProducts, FileHandling (#3768)
* Added led-blinker workflow for aarch64-linux platform

* Update runner label

* Added Tags to RPI self hosted workflows, sparse-checkout-cone-mode false

* Add subtopologies to Svc/ restructing of Ref to include CDH subtopology

* CDHCore Subtopology added under Svc and integrated into Ref

* Health instance within CDHCore references CDHCoreConfig for queue size

* Update metadata

check-spelling run (push) for add-subtopologies

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>

* Added AssertFatalAdapter Version PassiveTextLogger to Subtopology, config clarity improvements

* Comms subtopology without cmdSeq created, integrated in Ref

* Added cmdSeq to Comms Subtopology, integrated into Ref

* Add FileHandling Subtopology, initial structure

* Fixed Spelling, Flie -> File

* Update metadata

check-spelling run (push) for add-subtopologies

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>

* Added working FileHandling, DataProducts subtopology, integrated into Ref

* prmDb part of FileHandling, fatalHandler part of CDHCore

* Update metadata

check-spelling run (push) for add-subtopologies

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>

* Update comment for clarity

* Initial move to phasing components

* Fixing Phasing: Adding initial Phasing for CDHCore, DataProducts, FileHandling

* Renaming topologydefs.hpp, phasing fully working on all four subtopologies, needs cleaning up

* Cleanup with Ports_ComPacketQueue, definition only in Comms.fpp now

* Base project with all 4 subtopologies, integrated into Ref, and passing CI

* Initial Commit with all Subtopologies in Svc/Subtopologies

* Added posixtime back in to Ref Deployment (Accidentally Deleted)

* Updates to match new subtopology structure, integrate CCSDS into Ref

* Changes to CommCCSDS that go with last changes

* Standardize subtopology structure and naming to PascalCase

* Namespace fixe for ComFprime

* CDHCore->Cdhcore for consistency

* Rename CDHCore to CdhCore for consistency

* Update metadata

check-spelling run (pull_request_target) for add-subtopologies

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>

* Reorder on teardown phases for Com Subtopolgies

* Cpp check style fix

* Fix: Add missing tearDownComponents cleanup for DataProducts dpBufferManager

* Delete old comments, test using same mallocator for all subtopologies

* fix: Deallocated DataProducts BufferMgr

* Fix DataProducts subtopology memory cleanup

* Fix: Dataproducts subtopology teardown order

* Added tearDownComponents(state)

* Consolidate all cleanup to teardowncomponents

* Fix memory leaks: restore teardown phases

* Removal of redundant teardowncomponents()

* Revert "Removal of redundant teardowncomponents()"

This reverts commit 29d4ff8242574f1afc1bb6aacdf5cfef4d79987d.

* Fix formatting, remove commented out code

* Swap hardcoded numbers to config constants in subtopologies

* register_fprime_config() in config modules, isolated ComDriver into a separate config fpp file

* Added explicit CMake Module Names and Depends between Subtopologies and their Configs

* Fixed CCSDS case, more config constants

* Added explicit depends for each subtopology config

* added mallocator config, subtopology state structure

* Update subtopology config names for clarity, fixes #3571

* Fix reference to dpBuffer config Constants

---------

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
Co-authored-by: Moises Mata <moisesmata@users.noreply.github.com>
2025-06-26 15:00:57 -07:00

94 lines
3.9 KiB
C++

// ======================================================================
// \title Topology.cpp
// \author mstarch
// \brief cpp file containing the topology instantiation code
//
// \copyright
// Copyright 2009-2022, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
// Provides access to autocoded functions
#include <Ref/Top/RefTopologyAc.hpp>
// Necessary project-specified types
#include <Fw/Types/MallocAllocator.hpp>
#include <Os/Console.hpp>
// Used for 1Hz synthetic cycling
#include <Os/Mutex.hpp>
// Allows easy reference to objects in FPP/autocoder required namespaces
using namespace Ref;
// Instantiate a system logger that will handle Fw::Logger::log calls
Os::Console logger;
// The reference topology divides the incoming clock signal (1Hz) into sub-signals: 1Hz, 1/2Hz, and 1/4Hz and
// zero offset for all the dividers
Svc::RateGroupDriver::DividerSet rateGroupDivisorsSet{{{1, 0}, {2, 0}, {4, 0}}};
// Rate groups may supply a context token to each of the attached children whose purpose is set by the project. The
// reference topology sets each token to zero as these contexts are unused in this project.
U32 rateGroup1Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
U32 rateGroup2Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
U32 rateGroup3Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
/**
* \brief configure/setup components in project-specific way
*
* This is a *helper* function which configures/sets up each component requiring project specific input. This includes
* allocating resources, passing-in arguments, etc. This function may be inlined into the topology setup function if
* desired, but is extracted here for clarity.
*/
void configureTopology() {
// Rate group driver needs a divisor list
rateGroupDriverComp.configure(rateGroupDivisorsSet);
// Rate groups require context arrays. Empty for Reference example.
rateGroup1Comp.configure(rateGroup1Context, FW_NUM_ARRAY_ELEMENTS(rateGroup1Context));
rateGroup2Comp.configure(rateGroup2Context, FW_NUM_ARRAY_ELEMENTS(rateGroup2Context));
rateGroup3Comp.configure(rateGroup3Context, FW_NUM_ARRAY_ELEMENTS(rateGroup3Context));
}
// Public functions for use in main program are namespaced with deployment name Ref
namespace Ref {
void setupTopology(const TopologyState& state) {
// Autocoded initialization. Function provided by autocoder.
initComponents(state);
// Autocoded id setup. Function provided by autocoder.
setBaseIds();
// Autocoded connection wiring. Function provided by autocoder.
connectComponents();
// Autocoded command registration. Function provided by autocoder.
regCommands();
// Autocoded configuration. Function provided by autocoder.
configComponents(state);
// Project-specific component configuration. Function provided above. May be inlined, if desired.
configureTopology();
// Autocoded parameter loading. Function provided by autocoder.
loadParameters();
// Autocoded task kick-off (active components). Function provided by autocoder.
startTasks(state);
}
void startRateGroups(Fw::TimeInterval interval) {
// This timer drives the fundamental tick rate of the system.
// Svc::RateGroupDriver will divide this down to the slower rate groups.
// This call will block until the stopRateGroups() call is made.
// For this Linux demo, that call is made from a signal handler.
linuxTimer.startTimer(interval.getSeconds()*1000+interval.getUSeconds()/1000);
}
void stopRateGroups() {
linuxTimer.quit();
}
void teardownTopology(const TopologyState& state) {
// Autocoded (active component) task clean-up. Functions provided by topology autocoder.
stopTasks(state);
freeThreads(state);
tearDownComponents(state);
}
} // namespace Ref