forked from viamrobotics/viam-flutter-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpower_sensor.dart
76 lines (67 loc) · 2.8 KB
/
power_sensor.dart
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
70
71
72
73
74
75
76
import '../../gen/common/v1/common.pb.dart';
import '../../gen/component/powersensor/v1/powersensor.pb.dart';
import '../../resource/base.dart';
import '../../robot/client.dart';
/// {@category Viam SDK}
typedef Voltage = GetVoltageResponse;
/// {@category Viam SDK}
typedef Current = GetCurrentResponse;
/// {@category Viam SDK}
/// PowerSensor reports information about voltage, current, and power.
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
abstract class PowerSensor extends Resource {
static const Subtype subtype = Subtype(resourceNamespaceRDK, resourceTypeComponent, 'power_sensor');
/// Get the measurements or readings from this [PowerSensor].
/// If a sensor is not configured correctly or fails to read a
/// piece of data, it will not appear in the readings dictionary.
///
/// ```
/// var readings = await myPowerSensor.readings();
/// ```
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
Future<Map<String, dynamic>> readings({Map<String, dynamic>? extra});
/// Get the voltage in volts, and whether the power is
/// AC (true) or DC (false).
///
/// ```
/// var voltageObject = await myPowerSensor.voltage();
/// double voltageInVolts = voltageObject.volts;
/// bool isItAC = voltageObject.isAc;
/// ```
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
Future<Voltage> voltage({Map<String, dynamic>? extra});
/// Get the current in amperes, and whether the current
/// is AC (true) or DC (false).
///
/// ```
/// var currentObject = await myPowerSensor.current();
/// double amps = currentObject.amperes;
/// bool isItAC = currentObject.isAc;
/// ```
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
Future<Current> current({Map<String, dynamic>? extra});
/// Get the power (watts)
///
/// ```
/// var power = await myPowerSensor.power();
/// ```
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
Future<double> power({Map<String, dynamic>? extra});
/// Get the [ResourceName] for this [PowerSensor] with the given [name].
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
static ResourceName getResourceName(String name) {
return PowerSensor.subtype.getResourceName(name);
}
/// Get the [PowerSensor] named [name] from the provided robot.
///
/// For more information, see [Power Sensor component](https://docs.viam.com/components/power-sensor/).
static PowerSensor fromRobot(RobotClient robot, String name) {
return robot.getResource(PowerSensor.getResourceName(name));
}
}