Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
state_server.h
1#ifndef STATE_SERVER_H
2#define STATE_SERVER_H
3
4#include <atomic>
5#include <map>
6#include <mutex>
7#include <set>
8#include "../com/someip/rpc/rpc_server.h"
9#include "../sm/trigger.h"
10#include "./exec_exception.h"
11
12namespace ara
13{
14 namespace exec
15 {
20 {
21 private:
22 const uint16_t cServiceId{3};
23 const uint16_t cSetStateId{1};
24 const uint16_t cStateTransitionId{2};
25
26 com::someip::rpc::RpcServer *const mRpcServer;
27 const std::set<std::pair<std::string, std::string>> mFunctionGroupStates;
28 std::map<std::string, sm::Trigger<std::string> *> mNotifiers;
29 std::map<std::string, std::string> mCurrentStates;
30 std::atomic_bool mInitialized;
31 std::mutex mMutex;
32
33 void injectErrorCode(
34 std::vector<uint8_t> &payload, ExecErrc errorCode);
35
36 void notify(std::string functionGroup, std::string state);
37
38 bool handleSetState(
39 const std::vector<uint8_t> &rpcRequestPayload,
40 std::vector<uint8_t> &rpcResponsePayload);
41
42 bool handleStateTransition(
43 const std::vector<uint8_t> &rpcRequestPayload,
44 std::vector<uint8_t> &rpcResponsePayload);
45
46 public:
55 std::set<std::pair<std::string, std::string>> &&functionGroupStates,
56 std::map<std::string, std::string> &&initialStates);
57
63 bool TryGetState(
64 std::string functionGroup, std::string &state);
65
70 void SetNotifier(
71 std::string functionGroup, std::function<void()> callback);
72
76 bool Initialized() const noexcept;
77
79 };
80 }
81}
82
83#endif
SOME/IP RPC server.
Definition: rpc_server.h:23
A class to handle the state client requests at the EM side.
Definition: state_server.h:20
StateServer(com::someip::rpc::RpcServer *rpcServer, std::set< std::pair< std::string, std::string > > &&functionGroupStates, std::map< std::string, std::string > &&initialStates)
Constructor.
Definition: state_server.cpp:7
bool Initialized() const noexcept
Indicate whether or not EM has been initialized.
Definition: state_server.cpp:231
void SetNotifier(std::string functionGroup, std::function< void()> callback)
Set a notifier at the state changed of a function group.
Definition: state_server.cpp:212
bool TryGetState(std::string functionGroup, std::string &state)
Try to get the state of a function group.
Definition: state_server.cpp:189
ExecErrc
Execution Management error codes.
Definition: exec_error_domain.h:13