F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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);
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] = 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++) {
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:14
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.
Auto-generated base for PassiveRateGroup component.
void tlmWrite_CycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void RateGroupMemberOut_out(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)
Invoke output port RateGroupMemberOut.
NATIVE_INT_TYPE getNum_RateGroupMemberOut_OutputPorts() const
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
bool isConnected_RateGroupMemberOut_OutputPort(NATIVE_INT_TYPE portNum)
~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