6 #ifndef CM_MOTORCORTEX_H
7 #define CM_MOTORCORTEX_H
9 #include "cm_conndata.h"
10 #include "cm_rpcprocessor.h"
11 #include "motorcortex.pb.h"
12 #include "motorcortex_hash.h"
20 namespace parameter_server {
28 struct RequestParamList;
32 static constexpr
auto MAX_NUM_OF_REQ_ITR = 100;
33 static constexpr
struct timespec SHORT_WAIT_TIME_MSEC { .tv_sec = 0, .tv_nsec = 1000000 };
34 static constexpr
auto PARAMETER_SERIALIZATION_TIMEOUT_MSEC = 2000;
35 static constexpr
auto PARAMETER_SERIALIZATION_N_TRIALS = 2;
42 [[nodiscard]] MsgHashSet getHashList()
const override;
44 constexpr
static int getHashSize() {
return motorcortex::getHashSize(); }
46 void setConfigPath(
const std::string& path);
63 static bool decodeGetParameterListMsgHook(pb_istream_s* stream,
const pb_field_t* field,
void** arg);
65 static bool decodeGetParameterListMsg(
const RequestMsg& request,
66 std::vector<motorcortex_GetParameterMsg>& get_param_list);
68 static bool decodeSetParameterMsgHook(pb_istream_s* stream,
const pb_field_t* field,
void** arg);
70 bool decodeSetParameterMsg(
const RequestMsg& msg);
72 static bool decodeOverwriteParameterMsgHook(pb_istream_s* stream,
const pb_field_t* field,
void** arg);
74 bool decodeOverwriteParameterMsg(
const RequestMsg& msg);
76 bool decodeReleaseParameterMsg(
const RequestMsg& msg);
78 static bool decodeSetParameterListMsgHook(pb_istream_s* stream,
const pb_field_t* field,
void** arg);
80 bool decodeSetParameterListMsg(
const RequestMsg& msg);
82 static size_t guessParamSize(
size_t param_size,
size_t path_length);
84 static bool encodeEmptyParameterMsgHook(pb_ostream_s* stream,
const pb_field_t* field,
void*
const* arg);
86 static bool encodeParameterMsgHook(pb_ostream_s* stream,
const pb_field_t* field,
void*
const* arg);
88 bool encodeEmptyParameterMsg(
RequestParam& req_param, motorcortex_StatusCode status,
ReplyMsg& output_msg);
92 static bool encodeParameterListMsgHook(pb_ostream_s* stream,
const pb_field_t* field,
void*
const* arg);
104 std::string config_path_;