-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (31 loc) · 1.03 KB
/
main.py
File metadata and controls
38 lines (31 loc) · 1.03 KB
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
import re
import sys
import time
from dp100_ctrl import Dp100
def main(argv):
if len(argv) == 0:
dp100.status()
sys.exit(0)
for param in argv:
if re.search('off', param, re.IGNORECASE):
dp100.set(output=False)
if re.search('on', param, re.IGNORECASE):
dp100.set(output=True)
if re.search('[0-9]+V', param, re.IGNORECASE):
dp100.set(vset=int(param[:-1])*1000)
if re.search('[0-9]+mV', param, re.IGNORECASE):
dp100.set(vset=int(param[:-2]))
if re.search('[0-9]+A', param, re.IGNORECASE):
dp100.set(iset=int(param[:-1])*1000)
if re.search('[0-9]+mA', param, re.IGNORECASE):
dp100.set(iset=int(param[:-2]))
dp100.basic_set()
if __name__ == '__main__':
try:
dp100 = Dp100()
except:
print("Could not communicate to device")
sys.exit(1)
print(f"Device Manufacturer: {dp100.device.manufacturer}")
print(f"Device Serial: {dp100.device.serial}")
main(sys.argv[1:])