Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
elementary_supervision.h
1#ifndef ELEMENTARY_SUPERVISION_H
2#define ELEMENTARY_SUPERVISION_H
3
4#include <cstdint>
5#include <functional>
6#include "../recovery_action.h"
7
8namespace ara
9{
10
11 namespace phm
12 {
13 namespace supervisors
14 {
16 enum class SupervisionStatus : uint8_t
17 {
18 kDeactivated = 0,
19 kOk = 1,
20 kFailed = 2,
21 kExpired =3
22 };
23
26 {
27 private:
28 const TypeOfSupervision cSupervisionType;
29
30 SupervisionStatus mStatus;
31 std::function<void(SupervisionStatus)> mOnStatusChanged;
32
33 protected:
37 TypeOfSupervision supervisionType) noexcept;
38
41 void Report(SupervisionStatus status);
42
43 public:
44 virtual ~ElementarySupervision() noexcept = default;
45
48 SupervisionStatus GetStatus() const noexcept;
49
52 TypeOfSupervision GetType() const noexcept;
53
56 void SetCallback(
57 std::function<void(SupervisionStatus)> &&callback);
58 };
59 }
60 }
61}
62
63#endif
An abstract class the enables a supervision method to report its elementary supervion status.
Definition: elementary_supervision.h:26
SupervisionStatus GetStatus() const noexcept
Get the supervision status.
Definition: elementary_supervision.cpp:52
void SetCallback(std::function< void(SupervisionStatus)> &&callback)
Set a callback to be invoked on the supervision status change.
Definition: elementary_supervision.cpp:62
void Report(SupervisionStatus status)
Report the new supervision status.
Definition: elementary_supervision.cpp:17
ElementarySupervision(TypeOfSupervision supervisionType) noexcept
Constructor.
Definition: elementary_supervision.cpp:10
TypeOfSupervision GetType() const noexcept
Get the type of supervision.
Definition: elementary_supervision.cpp:57
SupervisionStatus
Supervision finite state machine status.
Definition: elementary_supervision.h:17
@ kFailed
!< Supervision is correct
@ kExpired
!< Supervision is incorrect but does not exceed the tolerance
@ kOk
!< Supervision has not been started or has been terminated
TypeOfSupervision
Supervision algorithm type.
Definition: recovery_action.h:14