Thomas Boyer-Chammard d014f30a96
Add Framing subtopologies and use them within Com subtopologies (#4113)
* Update ComX subtopologies to not include ComStub and update Ref

* Cosmetic updates

* Working FramingCcsds subtopology used in ComCcsds

* Revert Ref to use ComCcsds

* Move FramingSubtopology into ComCcsds build module

* Working ComFprime subtopology

* Cosmetic updates

* formatting
2025-09-03 18:04:37 -07:00

193 lines
8.5 KiB
Fortran

module ComCcsds {
# ComPacket Queue enum for queue types
enum Ports_ComPacketQueue {
EVENTS,
TELEMETRY
}
enum Ports_ComBufferQueue {
FILE
}
# ----------------------------------------------------------------------
# Active Components
# ----------------------------------------------------------------------
instance comQueue: Svc.ComQueue base id ComCcsdsConfig.BASE_ID + 0x00000 \
queue size ComCcsdsConfig.QueueSizes.comQueue \
stack size ComCcsdsConfig.StackSizes.comQueue \
priority ComCcsdsConfig.Priorities.comQueue \
{
phase Fpp.ToCpp.Phases.configComponents """
using namespace ComCcsds;
Svc::ComQueue::QueueConfigurationTable configurationTable;
// Events (highest-priority)
configurationTable.entries[Ports_ComPacketQueue::EVENTS].depth = ComCcsdsConfig::QueueDepths::events;
configurationTable.entries[Ports_ComPacketQueue::EVENTS].priority = ComCcsdsConfig::QueuePriorities::events;
// Telemetry
configurationTable.entries[Ports_ComPacketQueue::TELEMETRY].depth = ComCcsdsConfig::QueueDepths::tlm;
configurationTable.entries[Ports_ComPacketQueue::TELEMETRY].priority = ComCcsdsConfig::QueuePriorities::tlm;
// File Downlink Queue (buffer queue using NUM_CONSTANTS offset)
configurationTable.entries[Ports_ComPacketQueue::NUM_CONSTANTS + Ports_ComBufferQueue::FILE].depth = ComCcsdsConfig::QueueDepths::file;
configurationTable.entries[Ports_ComPacketQueue::NUM_CONSTANTS + Ports_ComBufferQueue::FILE].priority = ComCcsdsConfig::QueuePriorities::file;
// Allocation identifier is 0 as the MallocAllocator discards it
ComCcsds::comQueue.configure(configurationTable, 0, ComCcsds::Allocation::memAllocator);
"""
phase Fpp.ToCpp.Phases.tearDownComponents """
ComCcsds::comQueue.cleanup();
"""
}
# ----------------------------------------------------------------------
# Passive Components
# ----------------------------------------------------------------------
instance frameAccumulator: Svc.FrameAccumulator base id ComCcsdsConfig.BASE_ID + 0x01000 \
{
phase Fpp.ToCpp.Phases.configObjects """
Svc::FrameDetectors::CcsdsTcFrameDetector frameDetector;
"""
phase Fpp.ToCpp.Phases.configComponents """
ComCcsds::frameAccumulator.configure(
ConfigObjects::ComCcsds_frameAccumulator::frameDetector,
1,
ComCcsds::Allocation::memAllocator,
ComCcsdsConfig::BuffMgr::frameAccumulatorSize
);
"""
phase Fpp.ToCpp.Phases.tearDownComponents """
ComCcsds::frameAccumulator.cleanup();
"""
}
instance commsBufferManager: Svc.BufferManager base id ComCcsdsConfig.BASE_ID + 0x02000 \
{
phase Fpp.ToCpp.Phases.configObjects """
Svc::BufferManager::BufferBins bins;
"""
phase Fpp.ToCpp.Phases.configComponents """
memset(&ConfigObjects::ComCcsds_commsBufferManager::bins, 0, sizeof(ConfigObjects::ComCcsds_commsBufferManager::bins));
ConfigObjects::ComCcsds_commsBufferManager::bins.bins[0].bufferSize = ComCcsdsConfig::BuffMgr::commsBuffSize;
ConfigObjects::ComCcsds_commsBufferManager::bins.bins[0].numBuffers = ComCcsdsConfig::BuffMgr::commsBuffCount;
ConfigObjects::ComCcsds_commsBufferManager::bins.bins[1].bufferSize = ComCcsdsConfig::BuffMgr::commsFileBuffSize;
ConfigObjects::ComCcsds_commsBufferManager::bins.bins[1].numBuffers = ComCcsdsConfig::BuffMgr::commsFileBuffCount;
ComCcsds::commsBufferManager.setup(
ComCcsdsConfig::BuffMgr::commsBuffMgrId,
0,
ComCcsds::Allocation::memAllocator,
ConfigObjects::ComCcsds_commsBufferManager::bins
);
"""
phase Fpp.ToCpp.Phases.tearDownComponents """
ComCcsds::commsBufferManager.cleanup();
"""
}
instance fprimeRouter: Svc.FprimeRouter base id ComCcsdsConfig.BASE_ID + 0x03000
instance tcDeframer: Svc.Ccsds.TcDeframer base id ComCcsdsConfig.BASE_ID + 0x04000
instance spacePacketDeframer: Svc.Ccsds.SpacePacketDeframer base id ComCcsdsConfig.BASE_ID + 0x05000
# NOTE: name 'framer' is used for the framer that connects to the Com Adapter Interface for better subtopology interoperability
instance framer: Svc.Ccsds.TmFramer base id ComCcsdsConfig.BASE_ID + 0x06000
instance spacePacketFramer: Svc.Ccsds.SpacePacketFramer base id ComCcsdsConfig.BASE_ID + 0x07000
instance apidManager: Svc.Ccsds.ApidManager base id ComCcsdsConfig.BASE_ID + 0x08000
instance comStub: Svc.ComStub base id ComCcsdsConfig.BASE_ID + 0x09000
topology FramingSubtopology {
# Usage Note:
#
# When importing this subtopology, users shall establish 5 port connections with a component implementing
# the Svc.Com (Svc/Interfaces/Com.fpp) interface. They are as follows:
#
# 1) Outputs:
# - ComCcsds.framer.dataOut -> [Svc.Com].dataIn
# - ComCcsds.frameAccumulator.dataReturnOut -> [Svc.Com].dataReturnIn
# 2) Inputs:
# - [Svc.Com].dataReturnOut -> ComCcsds.framer.dataReturnIn
# - [Svc.Com].comStatusOut -> ComCcsds.framer.comStatusIn
# - [Svc.Com].dataOut -> ComCcsds.frameAccumulator.dataIn
# Active Components
instance comQueue
# Passive Components
instance commsBufferManager
instance frameAccumulator
instance fprimeRouter
instance tcDeframer
instance spacePacketDeframer
instance framer
instance spacePacketFramer
instance apidManager
connections Downlink {
# ComQueue <-> SpacePacketFramer
comQueue.dataOut -> spacePacketFramer.dataIn
spacePacketFramer.dataReturnOut -> comQueue.dataReturnIn
# SpacePacketFramer buffer and APID management
spacePacketFramer.bufferAllocate -> commsBufferManager.bufferGetCallee
spacePacketFramer.bufferDeallocate -> commsBufferManager.bufferSendIn
spacePacketFramer.getApidSeqCount -> apidManager.getApidSeqCountIn
# SpacePacketFramer <-> TmFramer
spacePacketFramer.dataOut -> framer.dataIn
framer.dataReturnOut -> spacePacketFramer.dataReturnIn
# ComStatus
framer.comStatusOut -> spacePacketFramer.comStatusIn
spacePacketFramer.comStatusOut -> comQueue.comStatusIn
# (Outgoing) Framer <-> ComInterface connections shall be established by the user
}
connections Uplink {
# (Incoming) ComInterface <-> FrameAccumulator connections shall be established by the user
# FrameAccumulator buffer allocations
frameAccumulator.bufferDeallocate -> commsBufferManager.bufferSendIn
frameAccumulator.bufferAllocate -> commsBufferManager.bufferGetCallee
# FrameAccumulator <-> TcDeframer
frameAccumulator.dataOut -> tcDeframer.dataIn
tcDeframer.dataReturnOut -> frameAccumulator.dataReturnIn
# TcDeframer <-> SpacePacketDeframer
tcDeframer.dataOut -> spacePacketDeframer.dataIn
spacePacketDeframer.dataReturnOut -> tcDeframer.dataReturnIn
# SpacePacketDeframer APID validation
spacePacketDeframer.validateApidSeqCount -> apidManager.validateApidSeqCountIn
# SpacePacketDeframer <-> Router
spacePacketDeframer.dataOut -> fprimeRouter.dataIn
fprimeRouter.dataReturnOut -> spacePacketDeframer.dataReturnIn
# Router buffer allocations
fprimeRouter.bufferAllocate -> commsBufferManager.bufferGetCallee
fprimeRouter.bufferDeallocate -> commsBufferManager.bufferSendIn
}
} # end FramingSubtopology
# This subtopology uses FramingSubtopology with a ComStub component for Com Interface
topology Subtopology {
import FramingSubtopology
instance comStub
connections ComStub {
# Framer <-> ComStub (Downlink)
ComCcsds.framer.dataOut -> comStub.dataIn
comStub.dataReturnOut -> ComCcsds.framer.dataReturnIn
comStub.comStatusOut -> ComCcsds.framer.comStatusIn
# ComStub <-> FrameAccumulator (Uplink)
comStub.dataOut -> ComCcsds.frameAccumulator.dataIn
ComCcsds.frameAccumulator.dataReturnOut -> comStub.dataReturnIn
}
} # end Subtopology
} # end ComCcsds