F´ Flight Software - C/C++ Documentation NASA-v1.6.0
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/Log.hpp>
18
19namespace Svc {
21 : PassiveRateGroupComponentBase(compName), m_cycles(0), m_maxTime(0), m_numContexts(0) {
22}
23
25
27 FW_ASSERT(contexts);
28 FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),numContexts,this->getNum_RateGroupMemberOut_OutputPorts());
29 FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(),
30 FW_NUM_ARRAY_ELEMENTS(this->m_contexts),
31 this->getNum_RateGroupMemberOut_OutputPorts());
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] = contexts[entry];
37 }
38}
39
40
41void PassiveRateGroup::CycleIn_handler(NATIVE_INT_TYPE portNum, Svc::TimerVal& cycleStart) {
42 TimerVal end;
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++) {
47 if (this->isConnected_RateGroupMemberOut_OutputPort(port)) {
48 this->RateGroupMemberOut_out(port, this->m_contexts[port]);
49 }
50 }
51
52 // grab timer for end of cycle
53 end.take();
54
55 // get rate group execution time
56 U32 cycle_time = end.diffUSec(cycleStart);
57
58 // check to see if the time has exceeded the previous maximum
59 if (cycle_time > this->m_maxTime) {
60 this->m_maxTime = cycle_time;
61 }
62 this->tlmWrite_MaxCycleTime(this->m_maxTime);
63 this->tlmWrite_CycleTime(cycle_time);
64 this->tlmWrite_CycleCount(++this->m_cycles);
65}
66
67} // namespace Svc
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
C++-compatible configuration header for fprime configuration.
~PassiveRateGroup()
PassiveRateGroupImpl destructor.
void configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE numContexts)
PassiveRateGroupImpl initialization function.
PassiveRateGroup(const char *compName)
PassiveRateGroupImpl constructor.
Serializable class for carrying timer values.
Definition TimerVal.hpp:22
void take()
Function to store a timer value.
Definition TimerVal.cpp:38
U32 diffUSec(const TimerVal &time)
Compute difference function.
Definition TimerVal.cpp:42