F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 <Fw/FPrimeBasicTypes.hpp>
15 #include <Fw/Types/Assert.hpp>
16 #include <Os/Console.hpp>
18 
19 namespace Svc {
21  : PassiveRateGroupComponentBase(compName), m_cycles(0), m_maxTime(0), m_numContexts(0) {}
22 
24 
25 void PassiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) {
26  FW_ASSERT(contexts);
27  FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(), static_cast<FwAssertArgType>(numContexts),
28  static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
30  static_cast<FwAssertArgType>(FW_NUM_ARRAY_ELEMENTS(this->m_contexts)),
31  static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
32 
33  this->m_numContexts = numContexts;
34  // copy context values
35  for (FwIndexType entry = 0; entry < this->m_numContexts; entry++) {
36  this->m_contexts[entry] = static_cast<U32>(contexts[entry]);
37  }
38 }
39 
40 void PassiveRateGroup::CycleIn_handler(FwIndexType portNum, Os::RawTime& cycleStart) {
41  Os::RawTime endTime;
42  FW_ASSERT(this->m_numContexts);
43 
44  // invoke any members of the rate group
45  for (FwIndexType port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) {
47  this->RateGroupMemberOut_out(port, this->m_contexts[port]);
48  }
49  }
50 
51  // grab timer for endTime of cycle
52  endTime.now();
53 
54  // get rate group execution time
55  U32 cycleTime;
56  // Cast to void as the only possible error is overflow, which we can't handle other
57  // than capping cycleTime to max value of U32 (which is done in getDiffUsec anyways)
58  (void)endTime.getDiffUsec(cycleStart, cycleTime);
59  // check to see if the time has exceeded the previous maximum
60  if (cycleTime > this->m_maxTime) {
61  this->m_maxTime = cycleTime;
62  }
63  this->tlmWrite_MaxCycleTime(this->m_maxTime);
64  this->tlmWrite_CycleTime(cycleTime);
65  this->tlmWrite_CycleCount(++this->m_cycles);
66 }
67 
68 } // namespace Svc
PassiveRateGroup(const char *compName)
PassiveRateGroupImpl constructor.
Status now() override
Get the current time.
Definition: RawTime.cpp:36
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
void configure(U32 contexts[], FwIndexType numContexts)
PassiveRateGroupImpl initialization function.
void tlmWrite_CycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
Auto-generated base for PassiveRateGroup component.
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
PlatformIndexType FwIndexType
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:90
~PassiveRateGroup()
PassiveRateGroupImpl destructor.
void RateGroupMemberOut_out(FwIndexType portNum, U32 context)
Invoke output port RateGroupMemberOut.
RateGroupDivider component implementation.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Status getDiffUsec(const RawTime &other, U32 &result) const
Calculate the difference in microseconds between two RawTime objects.
Definition: RawTime.cpp:56