Viam C++ SDK current
Loading...
Searching...
No Matches
switch.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <cstdint>
7
8#include <string>
9
10#include <viam/sdk/common/proto_value.hpp>
11#include <viam/sdk/components/component.hpp>
12#include <viam/sdk/resource/resource_api.hpp>
13
14namespace viam {
15namespace sdk {
16
18
25class Switch : public Component {
26 public:
29 inline void set_position(uint32_t position) {
31 }
32
36 virtual void set_position(uint32_t position, const ProtoStruct& extra) = 0;
37
40 inline uint32_t get_position() {
41 return get_position({});
42 }
43
47 virtual uint32_t get_position(const ProtoStruct& extra) = 0;
48
51 inline uint32_t get_number_of_positions() {
52 return get_number_of_positions({});
53 }
54
58 virtual uint32_t get_number_of_positions(const ProtoStruct& extra) = 0;
59
63 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
64
65 API api() const override;
66
67 protected:
68 explicit Switch(std::string name);
69};
70
71template <>
73 static API api();
74};
75
76} // namespace sdk
77} // namespace viam
Definition resource_api.hpp:21
Definition component.hpp:10
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
API api() const override
Returns the API associated with a particular resource.
virtual void set_position(uint32_t position, const ProtoStruct &extra)=0
Set the position of the switch.
virtual uint32_t get_number_of_positions(const ProtoStruct &extra)=0
Get the number of positions that the switch supports.
virtual ProtoStruct do_command(const ProtoStruct &command)=0
Send/receive arbitrary commands to the resource.
virtual uint32_t get_position(const ProtoStruct &extra)=0
Get the current position of the switch.
uint32_t get_position()
Get the current position of the switch.
Definition switch.hpp:40
Current position of the motor relative to its home.
Definition resource_api.hpp:46