-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequencer.py
More file actions
114 lines (85 loc) · 2.91 KB
/
Copy pathsequencer.py
File metadata and controls
114 lines (85 loc) · 2.91 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from argparse import ArgumentParser
from os import getcwd
from dls_fe_sequencer.fe_sequencer import FESequencer
# Import the basic framework components.
from softioc import builder, softioc
from softioc.softioc import devIocStats
from fe_sequencers.sequences import (
OneAbsorber,
Sequence,
TwoAbsorbers,
TwoAbsorbersFull,
)
def _run(absorber_cls, args=None):
"""
Shared CLI implementation for all absorber entry points.
This parses the front-end identifier from the command line and
invokes the sequencer with the selected absorber topology.
Args:
absorber_cls:
Absorber class to instantiate (e.g. OneAbsorber, TwoAbsorbers).
args:
Optional argument list for testing. If None, arguments are
taken from sys.argv.
"""
parser = ArgumentParser()
parser.add_argument(
"fe",
help="Front-end identifier (e.g. FE15I, FE16B)",
)
ns = parser.parse_args(args)
sequencer(ns.fe, absorber_cls())
def one_absorber(args=None):
"""
Entry point for single-absorber front-end sequencers.
Example:
one-absorber FE15I
"""
_run(OneAbsorber, args)
def two_absorbers(args=None):
"""
Entry point for double-absorber front-end sequencers.
Example:
two-absorbers FE16B
"""
_run(TwoAbsorbers, args)
def two_absorbers_full(args=None):
"""
Entry point for full-config double-absorber front-end sequencers.
Example:
two-absorbers-full FE99B
"""
_run(TwoAbsorbersFull, args)
def sequencer(front_end: str, sequence: Sequence):
"""
Configure and run a softIOC-based FE sequencer.
This function performs all IOC setup, sequence configuration,
database loading, and enters interactive IOC mode.
Args:
front_end:
Front-end identifier (e.g. 'FE99B').
sequence:
Sequence definition object providing absorber configuration
and open/close sequencing behaviour.
"""
devIocStats(f"{front_end}-PY-IOC-01")
# Set current working directory
builder.SetDeviceName(f"{front_end}-PY-IOC-01")
app_dir = builder.Waveform("APP_DIR", NELM=255, FTVL="CHAR")
app_dir.set([ord(c) for c in getcwd()])
# Create sequencer object
sequencer = FESequencer(front_end, sequence.no_of_absorbers)
# Configure open sequence
open_actions, open_conditions = sequence.define_open_sequence()
sequencer.configure_open_sequence(open_actions, open_conditions)
# Configure close sequence
close_actions, close_conditions = sequence.define_close_sequence()
sequencer.configure_close_sequence(close_actions, close_conditions)
sequencer.run()
# Boilerplate get the IOC started
builder.LoadDatabase()
softioc.iocInit()
# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())
if __name__ == "__main__":
two_absorbers("FE99B")