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:
30 uint32_t num_positions;
31 std::vector<std::string> position_labels;
32 };
33
36 inline void set_position(uint32_t position) {
38 }
39
43 virtual void set_position(uint32_t position, const ProtoStruct& extra) = 0;
44
47 inline uint32_t get_position() {
48 return get_position({});
49 }
50
54 virtual uint32_t get_position(const ProtoStruct& extra) = 0;
55
61
65 virtual position_info get_number_of_positions(const ProtoStruct& extra) = 0;
66
70 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
71
72 API api() const override;
73
74 protected:
75 explicit Switch(std::string name);
76};
77
78template <>
80 static API api();
81};
82
83} // namespace sdk
84} // 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
void set_position(uint32_t position)
Set the position of the switch.
Definition switch.hpp:36
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 position_info get_number_of_positions(const ProtoStruct &extra)=0
Get the position_info supported by this switch.
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:47
position_info get_number_of_positions()
Get the position_info supported by this switch.
Definition switch.hpp:58
Current position of the motor relative to its home.
Definition resource_api.hpp:46
Information on the positions supported by this switch and their labels.
Definition switch.hpp:29