Motorcortex Core  version: 2.7.6
cm_rpctypes.h
1 /*
2  * Developer : Alexey Zakharov (alexey.zakharov@vectioneer.com)
3  * All rights reserved. Copyright (c) 2018 VECTIONEER.
4  */
5 
6 #ifndef MOTORCORTEX_CORE_CM_RPCTYPES_H
7 #define MOTORCORTEX_CORE_CM_RPCTYPES_H
8 
9 #include "ps_types.h"
10 
11 #include <set>
12 #include <atomic>
13 #include <thread>
14 #include <nng/nng.h>
15 
16 namespace mcx::comm {
17 
18 typedef std::set<uint32_t> MsgHashSet;
19 
20 enum class RequestFlags {
21  USER_HAS_CONTROL = 1,
22 };
23 
24 struct RequestMsg {
25  bool client_has_control;
26  parameter_server::UserGroup user_group;
27  uint8_t* msg;
28  size_t size;
29  uint32_t hash;
30  uint32_t client_id;
31 };
32 
33 struct ReplyMsg {
34  size_t size;
35  nng_msg* msg;
36  uint8_t* body;
37 };
38 
39 enum class ReplyState {
40  EMPTY = 0,
41  PROCESSING,
42  READY,
43  ERROR,
44  TIMEOUT
45 };
46 
47 struct ReplyHandle {
48  std::atomic<ReplyState> state;
49  uint32_t id;
50 };
51 
52 ReplyMsg allocateMsgMem(size_t size);
53 
54 ReplyMsg duplicateMsgMem(ReplyMsg msg);
55 
56 ReplyMsg reallocateMsgMem(ReplyMsg msg_mem, size_t size);
57 
58 void deallocateMsgMem(ReplyMsg msg_mem);
59 
60 } // namespace mcx::comm
61 
62 #endif //MOTORCORTEX_CORE_CM_RPCTYPES_H
mcx::comm::ReplyMsg
Definition: cm_rpctypes.h:33
mcx::comm::ReplyHandle
Definition: cm_rpctypes.h:47
mcx::comm::RequestMsg
Definition: cm_rpctypes.h:24