5 #ifndef UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED 6 #define UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED 9 #include <uavcan/protocol/param/GetSet.hpp> 10 #include <uavcan/protocol/param/ExecuteOpcode.hpp> 27 typedef protocol::param::Value
Value;
35 virtual void getParamNameByIndex(Index index, Name& out_name)
const = 0;
40 virtual void assignParamValue(
const Name& name,
const Value& value) = 0;
45 virtual void readParamValue(
const Name& name, Value& out_value)
const = 0;
53 NumericValue& out_max, NumericValue& out_min)
const 65 virtual int saveAllParams() = 0;
71 virtual int eraseAllParams() = 0;
84 void (ParamServer::*)(
const protocol::param::ExecuteOpcode::Request&,
91 void handleGetSet(
const protocol::param::GetSet::Request& in, protocol::param::GetSet::Response& out)
99 UAVCAN_TRACE(
"ParamServer",
"GetSet: Index %i --> '%s'",
int(in.index), out.name.c_str());
106 if (out.name.empty())
108 UAVCAN_TRACE(
"ParamServer",
"GetSet: Can't resolve parameter name, index=%i",
int(in.index));
113 if (!in.value.is(protocol::param::Value::Tag::empty))
120 if (!out.value.is(protocol::param::Value::Tag::empty))
126 UAVCAN_TRACE(
"ParamServer",
"GetSet: Unknown param: index=%i name='%s'",
int(in.index), out.name.c_str());
132 protocol::param::ExecuteOpcode::Response& out)
136 if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_SAVE)
140 else if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_ERASE)
146 UAVCAN_TRACE(
"ParamServer",
"ExecuteOpcode: invalid opcode %i",
int(in.opcode));
154 , save_erase_srv_(node)
166 return -ErrInvalidParam;
192 #endif // UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED int start(IParamManager *manager)
void handleGetSet(const protocol::param::GetSet::Request &in, protocol::param::GetSet::Response &out)
ServiceServer< protocol::param::GetSet, GetSetCallback > get_set_srv_
protocol::param::Value Value
IParamManager * getParamManager() const
virtual void getParamNameByIndex(Index index, Name &out_name) const =0
StorageType< typename protocol::param::GetSet::Response::FieldTypes::name >::Type Name
#define UAVCAN_TRACE(...)
virtual void assignParamValue(const Name &name, const Value &value)=0
virtual void readParamDefaultMaxMin(const Name &name, Value &out_default, NumericValue &out_max, NumericValue &out_min) const
protocol::param::NumericValue NumericValue
StorageType< typename protocol::param::GetSet::Request::FieldTypes::index >::Type Index
virtual void readParamValue(const Name &name, Value &out_value) const =0
virtual int saveAllParams()=0
void handleExecuteOpcode(const protocol::param::ExecuteOpcode::Request &in, protocol::param::ExecuteOpcode::Response &out)
ServiceServer< protocol::param::ExecuteOpcode, ExecuteOpcodeCallback > save_erase_srv_
int start(const Callback &callback)
virtual int eraseAllParams()=0