F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
OnChangeChannel.hpp
Go to the documentation of this file.
1
// ======================================================================
2
// \title OnChangeChannel.hpp
3
// \author Rob Bocchino
4
// \brief A model of an on-change channel for testing
5
//
6
// \copyright
7
// Copyright (C) 2023 California Institute of Technology.
8
// ALL RIGHTS RESERVED. United States Government Sponsorship
9
// acknowledged. Any commercial use must be negotiated with the Office
10
// of Technology Transfer at the California Institute of Technology.
11
// ======================================================================
12
13
#ifndef TestUtils_OnChangeChannel_HPP
14
#define TestUtils_OnChangeChannel_HPP
15
16
#include <
FpConfig.hpp
>
17
#include <cstring>
18
19
#include "
TestUtils/Option.hpp
"
20
21
namespace
TestUtils
{
22
24
enum class
OnChangeStatus
{
CHANGED
,
NOT_CHANGED
};
25
27
template
<
typename
T>
28
class
OnChangeChannel
{
29
public
:
31
explicit
OnChangeChannel
(T
value
) :
value
(
value
) {}
33
OnChangeStatus
updatePrev
() {
34
const
auto
status = ((!this->prev.hasValue()) || (this->
value
!= this->prev.get()))
35
?
OnChangeStatus::CHANGED
36
:
OnChangeStatus::NOT_CHANGED
;
37
this->prev.set(this->
value
);
38
return
status;
39
}
40
41
public
:
43
T
value
;
44
45
private
:
47
Option<T>
prev;
48
};
49
50
}
// namespace TestUtils
51
52
#endif
FpConfig.hpp
C++-compatible configuration header for fprime configuration.
Option.hpp
TestUtils::OnChangeChannel
A model of an on-change telemetry channel.
Definition:
OnChangeChannel.hpp:28
TestUtils::OnChangeChannel::value
T value
The current value.
Definition:
OnChangeChannel.hpp:43
TestUtils::OnChangeChannel::updatePrev
OnChangeStatus updatePrev()
Update the previous value.
Definition:
OnChangeChannel.hpp:33
TestUtils::OnChangeChannel::OnChangeChannel
OnChangeChannel(T value)
Constructor.
Definition:
OnChangeChannel.hpp:31
TestUtils::Option
An optional value.
Definition:
Option.hpp:20
TestUtils
Definition:
OnChangeChannel.hpp:21
TestUtils::OnChangeStatus
OnChangeStatus
The status of an on-change telemetry channel.
Definition:
OnChangeChannel.hpp:24
TestUtils::OnChangeStatus::NOT_CHANGED
@ NOT_CHANGED
TestUtils::OnChangeStatus::CHANGED
@ CHANGED
TestUtils
OnChangeChannel.hpp
Generated by
1.9.1