-
Notifications
You must be signed in to change notification settings - Fork 1
/
GetVoltageStep.py
36 lines (27 loc) · 1.13 KB
/
GetVoltageStep.py
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
"""
Test step to get the voltage on a PV1-3 pin
"""
from OpenTap import Display, Output, Unit, Verdict
from System import Double
from opentap import *
from .PowerSupply import *
@attribute(Display("Get Voltage", "Gets voltage of pin (in V)", Groups=["PSLab", "Power Supply"]))
class GetVoltageStep(TestStep):
# Properties
Pin = property(PowerPin, PowerPin.ONE) \
.add_attribute(Display("Pin", "The chosen PV pin", "", -50))
PowerSupply = property(PowerSupply, None) \
.add_attribute(Display("Power Supply", "", "Resources", 0))
OutputValue = property(Double, 0.0) \
.add_attribute(Display("Current ", "Read voltage", "Output", 99)) \
.add_attribute(Unit("V")) \
.add_attribute(Output())
def __init__(self):
super(GetVoltageStep, self).__init__()
def Run(self):
super().Run() # 3.0: Required for debugging to work.
voltage = float(self.PowerSupply.getVoltage(self.Pin))
self.OutputValue = voltage
self.log.Debug(f"Voltage: {voltage} V")
self.PublishResult("PowerSupply", ["Voltage (V)"], [voltage])
self.UpgradeVerdict(Verdict.Pass)