-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_temp_pressure.py
executable file
·58 lines (44 loc) · 1.63 KB
/
log_temp_pressure.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Log PV in a file
'''
from __future__ import print_function
import os
import time
import numpy as np
from epics import PV
from datetime import datetime
import log
variableDict = {
'AD_Prefix': '2bmbSP1:', # options: 1. PointGrey: '2bmbPG3:', 2. Gbe '2bmbSP1:'
'Station': '2-BM-A'
}
global_PVs = {}
def init_general_PVs(global_PVs, variableDict):
# shutter PVs 2bma:D1Dmm_raw.VAL
global_PVs['Temperature'] = PV('2bma:D1Dmm_raw')
global_PVs['Voltage'] = PV('2bmS1:D1Dmm_raw')
global_PVs['HDF1_FullFileName_RBV'] = PV(variableDict['AD_Prefix'] + 'HDF1:FullFileName_RBV')
def main():
home = os.path.expanduser("~")
logs_home = home + '/logs/'
# make sure logs directory exists
if not os.path.exists(logs_home):
os.makedirs(logs_home)
lfname = logs_home + 'viktor_' + datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S") + '.log'
log.setup_custom_logger(lfname)
init_general_PVs(global_PVs, variableDict)
try:
while True:
h5fname = global_PVs['HDF1_FullFileName_RBV'].get()
h5fname_str = "".join([chr(item) for item in h5fname])
temp = global_PVs['Temperature'].get()
pressure = global_PVs['Voltage'].get()*1500/4.8434 # to calibrate
log.warning('Temperature: %4.4f C; Pressure: %4.4f psi: %s' % (temp, pressure, h5fname_str))
time.sleep(5)
except KeyboardInterrupt:
log.warning('interrupted!')
log.warning('Log information saved at: %s', lfname)
if __name__ == '__main__':
main()