Viam C++ SDK current
Loading...
Searching...
No Matches
switch_client.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <viam/api/component/switch/v1/switch.grpc.pb.h>
7
9#include <viam/sdk/rpc/dial.hpp>
10
11namespace viam {
12namespace sdk {
13namespace impl {
14
18class SwitchClient : public Switch {
19 public:
20 using interface_type = Switch;
21 SwitchClient(std::string name, const ViamChannel& channel);
22
23 const ViamChannel& channel() const {
24 return *channel_;
25 }
26
27 void set_position(uint32_t position, const ProtoStruct& extra) override;
28 uint32_t get_position(const ProtoStruct& extra) override;
29 uint32_t get_number_of_positions(const ProtoStruct& extra) override;
30 ProtoStruct do_command(const ProtoStruct& command) override;
31
32 // Using declarations to introduce convenience overloads of interface which do not need to be
33 // passed the ProtoStruct parameter.
37
38 private:
39 using StubType = viam::component::switch_::v1::SwitchService::StubInterface;
40 std::unique_ptr<StubType> stub_;
41 const ViamChannel* channel_;
42};
43
44} // namespace impl
45} // namespace sdk
46} // namespace viam
virtual std::string name() const
Return the resource's name.
A Switch represents a physical switch with multiple positions.
Definition switch.hpp:25
uint32_t get_number_of_positions()
Get the number of positions that the switch supports.
Definition switch.hpp:51
void set_position(uint32_t position)
Set the position of the switch.
Definition switch.hpp:29
uint32_t get_position()
Get the current position of the switch.
Definition switch.hpp:40
Definition dial.hpp:25
gRPC client implementation of a Switch component.
Definition switch_client.hpp:18
uint32_t get_number_of_positions(const ProtoStruct &extra) override
Get the number of positions that the switch supports.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
uint32_t get_position(const ProtoStruct &extra) override
Get the current position of the switch.
void set_position(uint32_t position, const ProtoStruct &extra) override
Set the position of the switch.
Current position of the motor relative to its home.
Defines a Switch component.