F´ Flight Software - C/C++ Documentation
NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
g
h
i
m
r
s
t
v
w
Variables
Typedefs
Enumerations
Enumerator
a
b
c
f
h
i
l
m
n
o
p
s
t
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
c
t
u
w
Enumerations
b
c
d
e
f
g
h
i
m
o
p
q
s
t
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
w
Related Functions
a
b
c
f
g
h
l
p
r
s
t
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Functions
f
i
m
s
u
Variables
_
c
f
i
l
p
t
Typedefs
Enumerations
Enumerator
a
c
d
f
i
m
p
r
s
t
w
Macros
a
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
RateGroupDriverImpl.cpp
Go to the documentation of this file.
1
#include <
Svc/RateGroupDriver/RateGroupDriverImpl.hpp
>
2
#include <
Fw/Types/BasicTypes.hpp
>
3
#include <cstring>
4
#include <
Fw/Types/Assert.hpp
>
5
#include <stdio.h>
6
7
namespace
Svc
{
8
9
RateGroupDriverImpl::RateGroupDriverImpl
(
const
char
* compName, I32 dividers[], I32 numDividers) :
10
RateGroupDriverComponentBase
(compName),
11
m_ticks(0),m_rollover(1)
12
{
13
14
// double check arguments
15
FW_ASSERT
(dividers);
16
FW_ASSERT
(numDividers <=
static_cast<
NATIVE_INT_TYPE
>
(
FW_NUM_ARRAY_ELEMENTS
(this->
m_dividers
)),
17
numDividers,
18
static_cast<
NATIVE_INT_TYPE
>
(
FW_NUM_ARRAY_ELEMENTS
(this->
m_dividers
)));
19
// verify port/table size matches
20
FW_ASSERT
(
FW_NUM_ARRAY_ELEMENTS
(this->
m_dividers
) == this->getNum_CycleOut_OutputPorts(),
21
static_cast<
NATIVE_INT_TYPE
>
(
FW_NUM_ARRAY_ELEMENTS
(this->
m_dividers
)),
22
this->getNum_CycleOut_OutputPorts());
23
// clear table
24
::memset(this->
m_dividers
,0,
sizeof
(this->
m_dividers
));
25
for
(
NATIVE_INT_TYPE
entry = 0; entry < numDividers; entry++) {
26
this->
m_dividers
[entry] = dividers[entry];
27
// rollover value should be product of all dividers to make sure integer rollover doesn't jump cycles
28
// only use non-zero dividers
29
if
(dividers[entry] != 0) {
30
this->
m_rollover
*= dividers[entry];
31
}
32
}
33
34
}
35
36
RateGroupDriverImpl::~RateGroupDriverImpl
(
void
) {
37
38
}
39
40
void
RateGroupDriverImpl::init
(
void
) {
41
RateGroupDriverComponentBase::init
();
42
}
43
44
void
RateGroupDriverImpl::CycleIn_handler(
NATIVE_INT_TYPE
portNum,
Svc::TimerVal
& cycleStart) {
45
46
// Loop through each divider. For a given port, the port will be called when the divider value
47
// divides evenly into the number of ticks. For example, if the divider value for a port is 4,
48
// it would be called every fourth invocation of the CycleIn port.
49
for
(
NATIVE_INT_TYPE
entry = 0; entry < static_cast<NATIVE_INT_TYPE>(
FW_NUM_ARRAY_ELEMENTS
(this->
m_dividers
)); entry++) {
50
if
(this->
m_dividers
[entry] != 0) {
51
if
(this->isConnected_CycleOut_OutputPort(entry)) {
52
if
((this->
m_ticks
% this->
m_dividers
[entry]) == 0) {
53
this->CycleOut_out(entry,
cycleStart
);
54
}
55
}
56
}
57
}
58
59
// rollover the tick value when the tick count reaches the rollover value
60
// the rollover value is the product of all the dividers. See comment in constructor.
61
this->
m_ticks
= (this->
m_ticks
+ 1) % this->
m_rollover
;
62
63
}
64
65
}
Svc::RateGroupDriverImpl::m_dividers
NATIVE_INT_TYPE m_dividers[NUM_CYCLEOUT_OUTPUT_PORTS]
divider array
Definition:
RateGroupDriverImpl.hpp:66
Svc::RateGroupDriverImpl::m_ticks
NATIVE_INT_TYPE m_ticks
tick counter
Definition:
RateGroupDriverImpl.hpp:69
RateGroupDriverImpl.hpp
RateGroupDivider component implementation.
FW_NUM_ARRAY_ELEMENTS
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition:
BasicTypes.hpp:103
Svc::RateGroupDriverImpl::init
void init(void)
RateGroupDriverImpl initialization function.
Definition:
RateGroupDriverImpl.cpp:40
Assert.hpp
Svc::RateGroupDriverImpl::m_rollover
NATIVE_INT_TYPE m_rollover
rollover counter
Definition:
RateGroupDriverImpl.hpp:71
Svc::TimerVal
Serializable class for carrying timer values.
Definition:
TimerVal.hpp:22
Svc::RateGroupDriverComponentBase
Auto-generated base for RateGroupDriver component.
Definition:
RateGroupDriverComponentAc.hpp:30
Fw::ObjBase::init
void init(void)
Object initializer.
Definition:
ObjBase.cpp:26
FW_ASSERT
#define FW_ASSERT(...)
Definition:
Assert.hpp:9
Svc::RateGroupDriverImpl::cycleStart
PRIVATE Svc::TimerVal & cycleStart
Definition:
RateGroupDriverImpl.hpp:63
Svc::RateGroupDriverImpl::~RateGroupDriverImpl
~RateGroupDriverImpl(void)
RateGroupDriverImpl destructor.
Definition:
RateGroupDriverImpl.cpp:36
Svc
Definition:
ActiveLoggerComponentAc.cpp:22
Svc::RateGroupDriverImpl::RateGroupDriverImpl
RateGroupDriverImpl(const char *compName, NATIVE_INT_TYPE dividers[], NATIVE_INT_TYPE numDividers)
RateGroupDriverImpl constructor.
Definition:
RateGroupDriverImpl.cpp:9
BasicTypes.hpp
Declares ISF basic types.
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition:
BasicTypes.hpp:29
Svc
RateGroupDriver
RateGroupDriverImpl.cpp
Generated by
1.8.19