F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
PassiveRateGroup.cpp
Go to the documentation of this file.
1/*
2 * \author: Tim Canham
3 * \file:
4 * \brief
5 *
6 * This file implements the PassiveRateGroup component,
7 * which invokes a set of components the comprise the rate group.
8 *
9 * Copyright 2014-2015, by the California Institute of Technology.
10 * ALL RIGHTS RESERVED. United States Government Sponsorship
11 * acknowledged.
12 */
13
14#include <FpConfig.hpp>
15#include <Fw/Types/Assert.hpp>
16#include <Os/Console.hpp>
18
19namespace Svc {
21 : PassiveRateGroupComponentBase(compName), m_cycles(0), m_maxTime(0), m_numContexts(0) {
22}
23
25
27 FW_ASSERT(contexts);
30 FW_NUM_ARRAY_ELEMENTS(this->m_contexts),
32
33 this->m_numContexts = numContexts;
34 // copy context values
35 for (NATIVE_INT_TYPE entry = 0; entry < this->m_numContexts; entry++) {
36 this->m_contexts[entry] = static_cast<U32>(contexts[entry]);
37 }
38}
39
40
41void PassiveRateGroup::CycleIn_handler(NATIVE_INT_TYPE portNum, Os::RawTime& cycleStart) {
42 Os::RawTime endTime;
43 FW_ASSERT(this->m_numContexts);
44
45 // invoke any members of the rate group
46 for (NATIVE_INT_TYPE port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) {
48 this->RateGroupMemberOut_out(port, this->m_contexts[port]);
49 }
50 }
51
52 // grab timer for endTime of cycle
53 endTime.now();
54
55 // get rate group execution time
56 U32 cycleTime;
57 // Cast to void as the only possible error is overflow, which we can't handle other
58 // than capping cycleTime to max value of U32 (which is done in getDiffUsec anyways)
59 (void) endTime.getDiffUsec(cycleStart, cycleTime);
60 // check to see if the time has exceeded the previous maximum
61 if (cycleTime > this->m_maxTime) {
62 this->m_maxTime = cycleTime;
63 }
64 this->tlmWrite_MaxCycleTime(this->m_maxTime);
65 this->tlmWrite_CycleTime(cycleTime);
66 this->tlmWrite_CycleCount(++this->m_cycles);
67}
68
69} // namespace Svc
#define FW_ASSERT(...)
Definition Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:70
C++-compatible configuration header for fprime configuration.
Status getDiffUsec(const RawTime &other, U32 &result) const
Calculate the difference in microseconds between two RawTime objects.
Definition RawTime.cpp:56
Status now() override
Get the current time.
Definition RawTime.cpp:36
Auto-generated base for PassiveRateGroup component.
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void RateGroupMemberOut_out(FwIndexType portNum, U32 context)
Invoke output port RateGroupMemberOut.
void tlmWrite_CycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
~PassiveRateGroup()
PassiveRateGroupImpl destructor.
void configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts)
PassiveRateGroupImpl initialization function.
PassiveRateGroup(const char *compName)
PassiveRateGroupImpl constructor.