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
use driver::Driver;
use driver::Attribute;
use driver::AttributeResult;
pub struct PowerSupply {
driver: Driver
}
impl PowerSupply {
pub fn new() -> Option<PowerSupply> {
return Some(PowerSupply {
driver: Driver::new(String::from("power_supply"), String::from("legoev3-battery"))
});
}
fn get_attribute(&mut self, name: &str) -> &Attribute {
self.driver.get_attribute(name)
}
pub fn get_current_now(&mut self) -> AttributeResult<isize> {
self.get_attribute("current_now").get_int()
}
pub fn get_scope(&mut self) -> AttributeResult<String> {
self.get_attribute("scope").get_str()
}
pub fn get_technology(&mut self) -> AttributeResult<String> {
self.get_attribute("technology").get_str()
}
pub fn get_type(&mut self) -> AttributeResult<String> {
self.get_attribute("type").get_str()
}
pub fn get_voltage_max_design(&mut self) -> AttributeResult<isize> {
self.get_attribute("voltage_max_design").get_int()
}
pub fn get_voltage_min_design(&mut self) -> AttributeResult<isize> {
self.get_attribute("voltage_min_design").get_int()
}
pub fn get_voltage_now(&mut self) -> AttributeResult<isize> {
self.get_attribute("voltage_now").get_int()
}
}