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 <grpcpp/channel.h>
7
8#include <viam/api/component/switch/v1/switch.grpc.pb.h>
9
11
12namespace viam {
13namespace sdk {
14namespace impl {
15
19class SwitchClient : public Switch {
20 public:
21 using interface_type = Switch;
22 SwitchClient(std::string name, std::shared_ptr<grpc::Channel> channel);
23
24 void set_position(uint32_t position, const ProtoStruct& extra) override;
25 uint32_t get_position(const ProtoStruct& extra) override;
26 uint32_t get_number_of_positions(const ProtoStruct& extra) override;
27 ProtoStruct do_command(const ProtoStruct& command) override;
28
29 // Using declarations to introduce convenience overloads of interface which do not need to be
30 // passed the ProtoStruct parameter.
34
35 private:
36 using StubType = viam::component::switch_::v1::SwitchService::StubInterface;
37 std::unique_ptr<StubType> stub_;
38 std::shared_ptr<grpc::Channel> channel_;
39};
40
41} // namespace impl
42} // namespace sdk
43} // 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
gRPC client implementation of a Switch component.
Definition switch_client.hpp:19
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.