-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
executable file
·50 lines (41 loc) · 1.74 KB
/
make.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
"""
Generate harmonica.db
"""
# Parse arguments
import argparse
parser = argparse.ArgumentParser(prog='make', description='Generate harmonica db.')
parser.add_argument('-f', '--file', type=str, help='configuration file', default='config.yaml')
args = parser.parse_args()
# Import
import yaml
from harmonica.util import record_make
# Load configuration
with open(args.file, 'r') as stream:
try:
config = yaml.safe_load(stream)
except yaml.YAMLError as exception:
exit(exception)
# Common
common = """
# LOCATION
record(waveform, "H:LOCATION:COUNT") {field(NELM, "1") field(FTVL, "SHORT")}
record(waveform, "H:LOCATION:LIST") {field(NELM, "1024") field(FTVL, "STRING")}
record(waveform, "H:MONITOR:COUNT") {field(NELM, "1") field(FTVL, "SHORT")}
record(waveform, "H:MONITOR:LIST") {field(NELM, "1024") field(FTVL, "STRING")}
# FREQUENCY
record(waveform, "H:FREQUENCY:MODEL:X") {field(NELM, "1") field(FTVL, "DOUBLE")}
record(waveform, "H:FREQUENCY:MODEL:Y") {field(NELM, "1") field(FTVL, "DOUBLE")}
record(waveform, "H:FREQUENCY:VALUE:X") {field(NELM, "1") field(FTVL, "DOUBLE")}
record(waveform, "H:FREQUENCY:VALUE:Y") {field(NELM, "1") field(FTVL, "DOUBLE")}
record(waveform, "H:FREQUENCY:ERROR:X") {field(NELM, "1") field(FTVL, "DOUBLE")}
record(waveform, "H:FREQUENCY:ERROR:Y") {field(NELM, "1") field(FTVL, "DOUBLE")}
"""
# Generate records
records = [record_make(name) for name in config]
# Generate file
with open('harmonica.db', 'w') as stream:
stream.write('# Start all PVs (attached to console)\n')
stream.write('# softIoc -d harmonica.db\n')
stream.write(common)
for record in records:
stream.write(record)