F´ Flight Software - C/C++ Documentation  NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ActiveRateGroupImpl.cpp
Go to the documentation of this file.
1 /*
2 * \author: Tim Canham
3 * \file:
4 * \brief
5 *
6 * This file implements the ActiveRateGroup 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 
17 #include <Fw/Types/BasicTypes.hpp>
18 #include <Fw/Types/Assert.hpp>
19 #include <Os/Log.hpp>
20 
21 namespace Svc {
22 
23  ActiveRateGroupImpl::ActiveRateGroupImpl(const char* compName, NATIVE_UINT_TYPE contexts[], NATIVE_UINT_TYPE numContexts) :
25  m_cycles(0),
26  m_maxTime(0),
27  m_cycleStarted(false),
28  m_overrunThrottle(0),
29  m_cycleSlips(0) {
30  FW_ASSERT(contexts);
31  FW_ASSERT(numContexts == static_cast<NATIVE_UINT_TYPE>(this->getNum_RateGroupMemberOut_OutputPorts()),numContexts,this->getNum_RateGroupMemberOut_OutputPorts());
32  FW_ASSERT(FW_NUM_ARRAY_ELEMENTS(this->m_contexts) == this->getNum_RateGroupMemberOut_OutputPorts(),
34  this->getNum_RateGroupMemberOut_OutputPorts());
35 
36  // copy context values
37  for (NATIVE_INT_TYPE entry = 0; entry < this->getNum_RateGroupMemberOut_OutputPorts(); entry++) {
38  this->m_contexts[entry] = contexts[entry];
39  }
40  }
41 
43  ActiveRateGroupComponentBase::init(queueDepth,instance);
44  }
45 
47 
48  }
49 
51  this->log_DIAGNOSTIC_RateGroupStarted();
52  }
53 
54  void ActiveRateGroupImpl::CycleIn_handler(NATIVE_INT_TYPE portNum, Svc::TimerVal& cycleStart) {
55 
56  TimerVal end;
57 
58  this->m_cycleStarted = false;
59 
60  // invoke any members of the rate group
61  for (NATIVE_INT_TYPE port = 0; port < this->getNum_RateGroupMemberOut_OutputPorts(); port++) {
62  if (this->isConnected_RateGroupMemberOut_OutputPort(port)) {
63  this->RateGroupMemberOut_out(port,this->m_contexts[port]);
64  }
65  }
66 
67  // grab timer for end of cycle
68  end.take();
69 
70  // get rate group execution time
71  U32 cycle_time = end.diffUSec(cycleStart);
72 
73  // check to see if the time has exceeded the previous maximum
74  if (cycle_time > this->m_maxTime) {
75  this->m_maxTime = cycle_time;
76  }
77 
78  // update cycle telemetry
79  this->tlmWrite_RgMaxTime(this->m_maxTime);
80 
81  // check for cycle slip. That will happen if new cycle message has been received
82  // which will cause flag will be set again.
83  if (this->m_cycleStarted) {
84  this->m_cycleSlips++;
87  this->m_overrunThrottle++;
88  }
89  // update cycle cycle slips
91  } else { // if cycle is okay start decrementing throttle value
92  if (this->m_overrunThrottle > 0) {
93  this->m_overrunThrottle--;
94  }
95  }
96 
97  // increment cycle
98  this->m_cycles++;
99 
100  }
101 
103  // set flag to indicate cycle has started. Check in thread for overflow.
104  this->m_cycleStarted = true;
105  }
106 
108  // return the key to health
109  this->PingOut_out(0,key);
110  }
111 
112 
113 }
Svc::ActiveRateGroupImpl::m_overrunThrottle
NATIVE_INT_TYPE m_overrunThrottle
throttle value for overrun events
Definition: ActiveRateGroupImpl.hpp:106
Svc::TimerVal::diffUSec
U32 diffUSec(const TimerVal &time)
Compute difference function.
Definition: TimerVal.cpp:41
Svc::ActiveRateGroupImpl::m_cycleStarted
volatile bool m_cycleStarted
indicate that cycle has started. Used to detect overruns.
Definition: ActiveRateGroupImpl.hpp:104
ActiveRateGroupImplCfg.hpp
FW_NUM_ARRAY_ELEMENTS
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.hpp:103
Svc::ActiveRateGroupImpl::m_cycleSlips
U32 m_cycleSlips
tracks number of cycle slips
Definition: ActiveRateGroupImpl.hpp:107
Svc::ActiveRateGroupImpl::m_maxTime
U32 m_maxTime
maximum execution time in microseconds
Definition: ActiveRateGroupImpl.hpp:103
Svc::ActiveRateGroupImpl::preamble
void preamble(void)
Task preamble.
Definition: ActiveRateGroupImpl.cpp:50
Svc::ActiveRateGroupComponentBase::tlmWrite_RgCycleSlips
void tlmWrite_RgCycleSlips(U32 arg)
Definition: ActiveRateGroupComponentAc.cpp:683
Assert.hpp
Svc::ActiveRateGroupImpl::~ActiveRateGroupImpl
~ActiveRateGroupImpl(void)
ActiveRateGroupImpl destructor.
Definition: ActiveRateGroupImpl.cpp:46
Svc::ActiveRateGroupImpl::ActiveRateGroupImpl
ActiveRateGroupImpl(const char *compName, NATIVE_UINT_TYPE contexts[], NATIVE_UINT_TYPE numContexts)
ActiveRateGroupImpl constructor.
Definition: ActiveRateGroupImpl.cpp:23
Svc::TimerVal
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
Fw::ObjBase::init
void init(void)
Object initializer.
Definition: ObjBase.cpp:26
Svc::ActiveRateGroupComponentBase::PingOut_out
void PingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Definition: ActiveRateGroupComponentAc.cpp:490
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
Svc::ActiveRateGroupImpl::m_contexts
NATIVE_UINT_TYPE m_contexts[NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS]
Must match number of output ports.
Definition: ActiveRateGroupImpl.hpp:105
Svc::ActiveRateGroupComponentBase
Auto-generated base for ActiveRateGroup component.
Definition: ActiveRateGroupComponentAc.hpp:45
Svc::ActiveRateGroupImpl::PingIn_handler
void PingIn_handler(NATIVE_INT_TYPE portNum, U32 key)
Input ping port handler.
Definition: ActiveRateGroupImpl.cpp:107
Svc::TimerVal::take
void take(void)
Function to store a timer value.
Definition: TimerVal.cpp:37
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
ActiveRateGroupImpl.hpp
Svc::ActiveRateGroupImpl::cycleStart
PRIVATE Svc::TimerVal & cycleStart
Definition: ActiveRateGroupImpl.hpp:73
Svc::ACTIVE_RATE_GROUP_OVERRUN_THROTTLE
@ ACTIVE_RATE_GROUP_OVERRUN_THROTTLE
Number of overruns allowed before overrun event is throttled.
Definition: ActiveRateGroupImplCfg.hpp:22
Svc::ActiveRateGroupImpl::CycleIn_preMsgHook
void CycleIn_preMsgHook(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Input cycle port pre message hook.
Definition: ActiveRateGroupImpl.cpp:102
Svc
Definition: ActiveLoggerComponentAc.cpp:22
BasicTypes.hpp
Declares ISF basic types.
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Svc::ActiveRateGroupImpl::m_cycles
U32 m_cycles
cycles executed
Definition: ActiveRateGroupImpl.hpp:102
Svc::ActiveRateGroupComponentBase::log_WARNING_HI_RateGroupCycleSlip
void log_WARNING_HI_RateGroupCycleSlip(U32 cycle)
Definition: ActiveRateGroupComponentAc.cpp:825
Log.hpp