-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstartRun.py
More file actions
executable file
·60 lines (44 loc) · 1.4 KB
/
startRun.py
File metadata and controls
executable file
·60 lines (44 loc) · 1.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /usr/bin/python3
import os
import sys
import time
import subprocess
from subprocess import Popen, PIPE
from optparse import OptionParser
from datetime import datetime
sys.path.append("/home/cmsdaq/DAQ/TXP3510P/")
from TXP3510PWrapper import TXP3510P
parser = OptionParser()
parser.add_option("-r","--run")
(options,args)=parser.parse_args()
mykey = TXP3510P('/dev/TTi-3')
mykey_state = 0
proc = Popen(['python3','/home/cmsdaq/DAQ/DMThermalTests/read_PT1000.py','--dev','/dev/ttyACM5','--log','run%04d.log'%int(options.run)])
pid = proc.pid
print(pid)
timestamp_init = datetime.now()
time.sleep(3)
while True:
try:
os.system('tail -n 1 run%04d.log'%int(options.run))
time.sleep(2)
timestamp_curr = datetime.now()
time_elapsed = float((timestamp_curr - timestamp_init).total_seconds())
if time_elapsed > 30. and time_elapsed < 60. and mykey_state == 0:
mykey.setVoltage(20.)
mykey.setCurrent(0.25)
mykey.powerOn()
mykey_state = 1
if time_elapsed > 60.:
if mykey_state != 0:
mykey.setVoltage(0.)
mykey.powerOff()
mykey_state = 0
if time_elapsed > 120.:
break
except KeyboardInterrupt:
break
print('killing process %d'%pid)
os.system('kill -9 %d'%pid)
mykey.setVoltage(0)
mykey.powerOff()