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 }
23 
25 
26 void PassiveRateGroup::configure(U32 contexts[], FwIndexType numContexts) {
27  FW_ASSERT(contexts);
28  FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(),
29  static_cast<FwAssertArgType>(numContexts),
30  static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
32  static_cast<FwAssertArgType>(FW_NUM_ARRAY_ELEMENTS(this->m_contexts)),
33  static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
34 
35  this->m_numContexts = numContexts;
36  // copy context values
37  for (FwIndexType entry = 0; entry < this->m_numContexts; entry++) {
38  this->m_contexts[entry] = static_cast<U32>(contexts[entry]);
39  }
40 }
41 
42 
43 void PassiveRateGroup::CycleIn_handler(FwIndexType portNum, Os::RawTime& cycleStart) {
44  Os::RawTime endTime;
45  FW_ASSERT(this->m_numContexts);
46 
47  // invoke any members of the rate group
48  for (FwIndexType port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) {
50  this->RateGroupMemberOut_out(port, this->m_contexts[port]);
51  }
52  }
53 
54  // grab timer for endTime of cycle
55  endTime.now();
56 
57  // get rate group execution time
58  U32 cycleTime;
59  // Cast to void as the only possible error is overflow, which we can't handle other
60  // than capping cycleTime to max value of U32 (which is done in getDiffUsec anyways)
61  (void) endTime.getDiffUsec(cycleStart, cycleTime);
62  // check to see if the time has exceeded the previous maximum
63  if (cycleTime > this->m_maxTime) {
64  this->m_maxTime = cycleTime;
65  }
66  this->tlmWrite_MaxCycleTime(this->m_maxTime);
67  this->tlmWrite_CycleTime(cycleTime);
68  this->tlmWrite_CycleCount(++this->m_cycles);
69 }
70 
71 } // 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:93
~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