forked from viamrobotics/viam-typescript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch.ts
69 lines (66 loc) · 1.98 KB
/
switch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import type { Struct } from '@bufbuild/protobuf';
import type { Resource } from '../../types';
/** Represents a physical switch with multiple positions. */
export interface Switch extends Resource {
/**
* Set the switch to a specific position.
*
* @example
*
* ```ts
* const mySwitch = new VIAM.SwitchClient(machine, 'my_switch');
*
* // Update the switch from its current position to position 1
* await mySwitch.setPosition(1);
*
* // Update the switch from its current position to position 0
* await mySwitch.setPosition(0);
* ```
*
* For more information, see [Switch
* API](https://docs.viam.com/dev/reference/apis/components/switch/#setposition).
*/
setPosition: (position: number, extra?: Struct) => Promise<void>;
/**
* Get the current position of the switch.
*
* @example
*
* ```ts
* const mySwitch = new VIAM.SwitchClient(machine, 'my_switch');
*
* // Update the switch to position 1
* await mySwitch.setPosition(1);
*
* // Get the current set position
* const pos1 = await mySwitch.getPosition();
*
* // Update the switch to position 0
* await mySwitch.setPosition(0);
*
* // Get the current set position
* const pos2 = await mySwitch.getPosition();
* ```
*
* For more information, see [Switch
* API](https://docs.viam.com/dev/reference/apis/components/switch/#getposition).
*/
getPosition: (extra?: Struct) => Promise<number>;
/**
* Get the total number of positions available on the switch.
*
* @example
*
* ```ts
* const mySwitch = new VIAM.SwitchClient(machine, 'my_switch');
*
* // Get the number of available positions
* const numPositions = await mySwitch.getNumberOfPositions();
* console.log('Number of positions:', numPositions);
* ```
*
* For more information, see [Switch
* API](https://docs.viam.com/dev/reference/apis/components/switch/#getnumberofpositions).
*/
getNumberOfPositions: (extra?: Struct) => Promise<number>;
}