Skip to content

Commit db16815

Browse files
authored
Merge pull request #20 from hz-b/dev/feature/select-machine-startup
[TASK] towards bdata: conversion by factors
2 parents efa882a + 08b7898 commit db16815

File tree

10 files changed

+76
-200
lines changed

10 files changed

+76
-200
lines changed

bpm_data_combiner_app/Db/bpm_bdata.db

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ record(waveform, "$(PREFIX):bdata")
55
field(DTYP, "pydev")
66
field(EGU, "??")
77
field(EGU, "nm")
8-
field(FTVL, "DOUBLE")
8+
field(FTVL, "SHORT")
99
field(SCAN, "I/O Intr")
1010
field(INP, "@pydev.iointr('$(PREFIX):bdata')")
11-
field(NELM, 128)
11+
field(NELM, 256)
1212
field(TPRO, 0)
1313
}

bpm_data_combiner_app/Db/bpm_cfg.db

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ record(bo, "$(PREFIX):cfg:comp:median")
1414
record(pycalc, "${PREFIX}:cfg:bpm_names")
1515
{
1616
field(DESC, "BPM names to facade")
17-
field(INPA, "${PREFIX}:bpm:nams:all CPP")
17+
field(INPA, "${PREFIX}:$(MACHINE):bpm:nams:all CPP")
18+
field(FTA, "STRING")
19+
field(MEA, 128)
1820
field(CALC, "update(dev_name=None, known_device_names=%A%)")
21+
field(TPRO, 1)
1922
}
2023

bpm_data_combiner_app/Db/bpm_dev_input.substitutions

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
file "db/bpm_dev_input_rec.db"
22
{
33
pattern { DEV_NAME }
4-
{ BPMZ5D8R }
5-
{ BPMZ6D8R }
6-
{ BPMZ7D8R }
7-
{ BPMZ1T8R }
8-
{ BPMZ2T8R }
9-
{ BPMZ3T8R }
10-
{ BPMZ4T8R }
4+
5+
{ BPMZ2K3RP }
6+
{ BPMZ3K3RP }
7+
{ BPMZ4K3RP }
8+
{ BPMZ5K3RP }
9+
{ BPMZ6K3RP }
10+
{ BPMZ7K3RP }
11+
{ BPMZ1L4RP }
12+
{ BPMZ2L4RP }
13+
{ BPMZ3L4RP }
14+
{ BPMZ4L4RP }
15+
{ BPMZ5L4RP }
16+
{ BPMZ6L4RP }
17+
{ BPMZ7L4RP }
18+
{ BPMZ1K1RP }
19+
{ BPMZ2K1RP }
20+
{ BPMZ3K1RP }
21+
{ BPMZ4K1RP }
22+
{ BPMZ5K1RP }
23+
{ BPMZ6K1RP }
24+
{ BPMZ7K1RP }
25+
{ BPMZ1L2RP }
26+
{ BPMZ2L2RP }
27+
{ BPMZ3L2RP }
28+
{ BPMZ4L2RP }
29+
{ BPMZ5L2RP }
30+
{ BPMZ6L2RP }
31+
{ BPMZ7L2RP }
32+
{ BPMZ1K3RP }
33+
1134

1235
## # The BESSY II ring ... with the special ones missing
1336
## { BPMZ5D1R }

bpm_data_combiner_app/Db/bpm_dev_input_rec.db

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,5 @@
11
# Input data collected from the different bpm devices
22

3-
# First get the data into here ...
4-
# Input of one record device ... collect them here
5-
# locally (again)
6-
# so one can check what the IOC uses
7-
record(longin, "$(PREFIX):inp:7:$(DEV_NAME):x")
8-
{
9-
field(DESC, "mirror: $(DEV_NAME) x value")
10-
field(EGU, "nm")
11-
# field(INP, {pva:{
12-
# pv:"$(DEV_NAME):pos",
13-
# field:"X",
14-
# proc:true,
15-
# }}
16-
# )
17-
# Forwarding data handled by separate fanout to ensure that
18-
# data are pushed in desired order to python
19-
# field(FLNK, "$(PREFIX)$(DEV_NAME):im:x")
20-
field(VAL, -100000000)
21-
}
22-
23-
record(longin, "$(PREFIX):inp:7:$(DEV_NAME):y")
24-
{
25-
field(DESC, "mirror: y value")
26-
field(EGU, "nm")
27-
# field(INP, {pva:{
28-
# pv:"$(DEV_NAME):pos",
29-
# field:"Y",
30-
# proc:true,
31-
# }}
32-
# )
33-
# field(FLNK, "$(PREFIX)$(DEV_NAME):im:y")
34-
field(VAL, -100000000)
35-
}
36-
37-
# I assume that I can rely on cnt to be updated when ever
38-
# x or y are updated
39-
record(longin, "$(PREFIX):inp:7:$(DEV_NAME):cnt")
40-
{
41-
field(DESC, "mirror: (time) cnt")
42-
# field(INP, {pva:{
43-
# pv:"$(DEV_NAME):pos",
44-
# field:"lmt_l",
45-
# proc:true
46-
# }}
47-
# )
48-
# done by epics 3 record currenty
49-
# field(FLNK, "$(PREFIX):im:$(DEV_NAME):psh")
50-
field(VAL, -1)
51-
}
52-
533
# # Input data collected from the different bpm devices
544
record(pycalc, "$(PREFIX):inp:$(DEV_NAME):posv")
555
{
@@ -58,7 +8,8 @@ record(pycalc, "$(PREFIX):inp:$(DEV_NAME):posv")
588
field(FTA, LONG)
599
field(MEA, 3)
6010
field(CALC, "update(dev_name='$(DEV_NAME)', reading=%A%, tpro=%TPRO%)")
61-
field(FLNK, "$(PREFIX):inp:$(DEV_NAME):trg")
11+
# trigger heart beat monitor
12+
field(FLNK, "$(PREFIX):im:$(DEV_NAME):mon:trg")
6213
# field(TPRO, 1)
6314
}
6415

@@ -76,7 +27,6 @@ record(mbbi, "$(PREFIX):inp:$(DEV_NAME):sync_stat")
7627
field(FLNK, "$(PREFIX):im:$(DEV_NAME):sync_stat")
7728
}
7829

79-
8030
#
8131
# Todo: Bug? shows 1 instead of 2 even if the value is 2
8232
#
@@ -96,62 +46,6 @@ record(mbbo, "$(PREFIX):im:$(DEV_NAME):sync_stat")
9646
}
9747

9848

99-
record(fanout, "$(PREFIX):inp:$(DEV_NAME):trg")
100-
{
101-
field(DESC, "mirror: $(DEV_NAME) trigger on new data")
102-
field(LNK0, "$(PREFIX):inp:$(DEV_NAME):x")
103-
field(LNK1, "$(PREFIX):inp:$(DEV_NAME):y")
104-
field(LNK2, "$(PREFIX):inp:$(DEV_NAME):cnt")
105-
}
106-
107-
record(subArray, "$(PREFIX):inp:$(DEV_NAME):x")
108-
{
109-
field(DESC, "mirror: $(DEV_NAME) x value")
110-
field(EGU, "nm")
111-
field(INP, "$(PREFIX):inp:$(DEV_NAME):posv.A")
112-
field(FTVL, "LONG")
113-
field(MALM, 3)
114-
field(NELM, 1)
115-
field(INDX, 1)
116-
# Forwarding data handled by separate fanout to ensure that
117-
# data are pushed in desired order to python
118-
# field(FLNK, "$(PREFIX)$(DEV_NAME):im:x")
119-
# field(VAL, -100000000)
120-
}
121-
122-
record(subArray, "$(PREFIX):inp:$(DEV_NAME):y")
123-
{
124-
field(DESC, "mirror: $(DEV_NAME) y value")
125-
field(EGU, "nm")
126-
field(INP, "$(PREFIX):inp:$(DEV_NAME):posv.A")
127-
# field(INP, "$(DEV_NAME):posv")
128-
field(FTVL, "LONG")
129-
field(MALM, 3)
130-
field(NELM, 1)
131-
field(INDX, 2)
132-
# Forwarding data handled by separate fanout to ensure that
133-
# data are pushed in desired order to python
134-
# field(FLNK, "$(PREFIX)$(DEV_NAME):im:y")
135-
# field(VAL, -100000000)
136-
}
137-
138-
record(subArray, "$(PREFIX):inp:$(DEV_NAME):cnt")
139-
{
140-
field(DESC, "mirror: $(DEV_NAME) cnt")
141-
field(EGU, "nm")
142-
field(INP, "$(PREFIX):inp:$(DEV_NAME):posv.A")
143-
# field(INP, "$(DEV_NAME):posv")
144-
field(FTVL, "LONG")
145-
field(MALM, 3)
146-
field(NELM, 1)
147-
field(INDX, 0)
148-
# Forwarding data handled by separate fanout to ensure that
149-
# data are pushed in desired order to python
150-
field(FLNK, "$(PREFIX):im:$(DEV_NAME):psh")
151-
# field(VAL, -100000000)
152-
}
153-
154-
15549
record(stringin, "$(PREFIX):inp:$(DEV_NAME):name")
15650
{
15751
field(DESC, "mirror: name")
@@ -168,67 +62,6 @@ record(stringin, "$(PREFIX):inp:$(DEV_NAME):name")
16862
field(PINI, "YES")
16963
}
17064

171-
# Now the records to push the info further to python
172-
record(fanout, "$(PREFIX):im:$(DEV_NAME):psh")
173-
{
174-
# should call to python ... python should start building the
175-
# internal data structure ... not a way yet to push directly
176-
# field(LNK0, "$(PREFIX):im:$(DEV_NAME):cnt")
177-
# field(LNK1, "$(PREFIX):im:$(DEV_NAME):x")
178-
# field(LNK2, "$(PREFIX):im:$(DEV_NAME):y")
179-
# field(LNK3, "$(PREFIX):im:$(DEV_NAME):ctl")
180-
field(LNK4, "$(PREFIX):im:$(DEV_NAME):mon:trg")
181-
}
182-
183-
record(longout, "$(PREFIX):im:$(DEV_NAME):x")
184-
{
185-
field(DESC, "push to py: x")
186-
field(DTYP, "pydev")
187-
field(DOL, "$(PREFIX):inp:$(DEV_NAME):x")
188-
field(OMSL, "closed_loop")
189-
field(OUT, "@update(dev_name='$(DEV_NAME)', x=%VAL%)")
190-
field(VAL, -1)
191-
# field(PINI, "YES")
192-
# field(TPRO, 1)
193-
}
194-
195-
record(longout, "$(PREFIX):im:$(DEV_NAME):y")
196-
{
197-
field(DESC, "push to py: y")
198-
field(DTYP, "pydev")
199-
field(DOL, "$(PREFIX):inp:$(DEV_NAME):y")
200-
field(OMSL, "closed_loop")
201-
field(OUT, "@update(dev_name='$(DEV_NAME)', y=%VAL%)")
202-
field(VAL, -1)
203-
# field(PINI, "YES")
204-
# field(TPRO, 1)
205-
}
206-
207-
record(longout, "$(PREFIX):im:$(DEV_NAME):cnt")
208-
{
209-
field(DESC, "push to py: cnt")
210-
field(DTYP, "pydev")
211-
field(DOL, "$(PREFIX):inp:$(DEV_NAME):cnt")
212-
field(OMSL, "closed_loop")
213-
field(OUT, "@update(dev_name='$(DEV_NAME)', cnt=%VAL%)")
214-
field(VAL, -1)
215-
# field(PINI, "YES")
216-
# field(TPRO, 1)
217-
}
218-
219-
# informs python side: a new measurement hand over finished
220-
record(longout, "$(PREFIX):im:$(DEV_NAME):ctl")
221-
{
222-
field(DESC, "push to py: ctl")
223-
field(DTYP, "pydev")
224-
field(DOL, "$(PREFIX):inp:$(DEV_NAME):cnt")
225-
field(OMSL, "closed_loop")
226-
field(OUT, "@update(dev_name='$(DEV_NAME)', ctl=%VAL%)")
227-
field(VAL, -1)
228-
# field(PINI, "YES")
229-
# field(TPRO, 1)
230-
}
231-
23265
# This is forwarded to python solely to be able to check that the
23366
# $(DEV_NAME) matches the name the device communicates.
23467
#

bpm_data_combiner_app/Db/bpm_names_mls.db

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ record(subArray, "$(PREFIX):mls:bpm:nams:sec:3:strt")
33
field(INP, "$(PREFIX):mls:bpm:nams:sec:3")
44
field(FTVL, "STRING")
55
field(INDX, 1)
6-
field(NELM, 6)
6+
field(NELM, 7)
77
field(MALM, 8)
88

99
}
@@ -24,7 +24,7 @@ record(concat, "$(PREFIX):mls:bpm:nams:all")
2424
field(FTVL, "STRING")
2525

2626
field(IN00, "$(PREFIX):mls:bpm:nams:sec:3:strt PP")
27-
field(ME00, "6")
27+
field(ME00, "7")
2828
field(IN01, "$(PREFIX):mls:bpm:nams:sec:4")
2929
field(ME01, "8")
3030
field(IN02, "$(PREFIX):mls:bpm:nams:sec:1")

bpm_data_combiner_app/Db/bpm_names_mls_rec.db

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
record(waveform, "$(PREFIX):mls:bpm:nams:sec:$(SEC_NUM)")
22
{
33
field(DESC, "create bpm names that mls knows about")
4-
field(INP, "['BPMZ1$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ2$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ3$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ4$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ5$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ6$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ7$(SEC_TYP)$(SEC_NUM)RP']")
4+
field(INP, "['BPMZ1$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ2$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ3$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ4$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ5$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ6$(SEC_TYP)$(SEC_NUM)RP', 'BPMZ7$(SEC_TYP)$(SEC_NUM)RP', 'unused_$(SEC_TYP)$(SEC_NUM)RP']")
55
field(FTVL, "STRING")
66
field(NELM, 8)
77
field(PINI, "YES")

bpm_dev_sim_app/Db/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include $(TOP)/configure/CONFIG
66
# Install databases, templates & substitutions like this
77
DB += bpm_dev_sim.db
88
DB += bpm_dev_sim.rec
9+
DB += bpm_sector_names_all.db
910

1011
# If <anyname>.db template is not named <anyname>*.template add
1112
# <anyname>_TEMPLATE = <templatename>

iocBoot/iocbpm_data_combiner/st.cmd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ bpm_data_combiner_registerRecordDeviceDriver pdbbase
2222
## dbLoadRecords("db/iocAdminSoft.db", "IOC=$(IOC_NAME)")
2323
## dbLoadRecords("db/iocRelease.db", "IOC=$(IOC_NAME)")
2424

25+
# names of the bpms ... mls version
26+
dbLoadTemplate("db/bpm_names_mls_gen.substitutions", "PREFIX=$(PREFIX)")
27+
dbLoadRecords("db/bpm_names_mls.db", "PREFIX=$(PREFIX)")
28+
29+
dbLoadTemplate("db/bpm_dev_input.substitutions", "PREFIX=$(PREFIX)")
2530
## Load record instances
2631
dbLoadTemplate("db/bpm_dev_input.substitutions", "PREFIX=$(PREFIX)")
2732
# dbLoadRecords("db/bpm_dev_input_offbeat.db", "PREFIX=$(PREFIX)")
2833
dbLoadTemplate("db/bpm.substitutions", "PREFIX=$(PREFIX)")
2934
dbLoadRecords("db/bpm_monitor_overview.db", "PREFIX=$(PREFIX),VIEW=mon")
3035
dbLoadRecords("db/view.db", "PREFIX=$(PREFIX)")
3136
dbLoadRecords("db/bpm_periodic.db", "PREFIX=$(PREFIX)")
32-
dbLoadRecords("db/bpm_cfg.db", "PREFIX=$(PREFIX)")
37+
dbLoadRecords("db/bpm_cfg.db", "PREFIX=$(PREFIX),MACHINE=mls")
3338
dbLoadRecords("db/bpm_bdata.db", "PREFIX=$(PREFIX)")
3439

3540
pydev("from bpm_data_combiner.app import main ")

src/bpm_data_combiner/app/controller.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, *, prefix="OrbCol"):
3838
self.config = Config()
3939
self.accumulator = Accumulator()
4040

41-
self.views = Views(prefix="prefix")
41+
self.views = Views(prefix=prefix)
4242

4343
# These need to know which devices are available
4444
# initalise with empty
@@ -50,11 +50,15 @@ def __init__(self, *, prefix="OrbCol"):
5050
monitored_devices=self.monitor_devices
5151
)
5252

53-
self.collector = Collector(devices_names=self.monitor_devices.get_device_names())
53+
self.collector = Collector(devices_names=[])
5454

5555
def set_device_names(self, device_names=Sequence[str]):
5656
self.dev_name_index = {name: idx for idx, name in enumerate(device_names)}
5757
self.monitor_devices.set_device_names(device_names)
58+
self.collector.devices_names = device_names
59+
# that names etc. get published
60+
self._on_device_status_changed()
61+
return len(device_names)
5862

5963
def update(self, *, dev_name, tpro=False, **kwargs):
6064
"""
@@ -64,7 +68,7 @@ def update(self, *, dev_name, tpro=False, **kwargs):
6468
# extraction of command from kwargs should be the sole
6569
# code duplication to main.update
6670
cmd = next(iter(kwargs))
67-
self._update(cmd=cmd, dev_name=dev_name, tpro=tpro, **kwargs)
71+
return self._update(cmd=cmd, dev_name=dev_name, tpro=tpro, **kwargs)
6872

6973
def _update(self, *, cmd, dev_name, tpro, **kwargs):
7074
cmd = ValidCommands(cmd)
@@ -133,7 +137,8 @@ def periodic_trigger(self):
133137
stat_data = compute_mean_weights_for_planes(data)
134138
self.views.periodic_data.update(stat_data)
135139
logger.debug("pushing stat data to bdata_view")
136-
self.views.bdata.update(stat_data)
140+
#: todo ... need to get kwargs from config
141+
self.views.bdata.update(stat_data, n_bpms=32, scale_x_axis=1./1.4671)
137142
logger.debug("pushing stat data to bdata_view done")
138143

139144
def _on_new_collection_ready(self, col: CollectionItemInterface):
@@ -142,7 +147,6 @@ def _on_new_collection_ready(self, col: CollectionItemInterface):
142147
)
143148
self.accumulator.add(data)
144149
self.views.ready_data.update(data)
145-
# Todo: add preprocessor step
146150

147151
def _on_device_status_changed(self):
148152
# collector needs to know which devices are active

0 commit comments

Comments
 (0)