mirror of
https://github.com/bec-project/bec.git
synced 2026-06-02 08:18:31 +02:00
fix: add async monitor to config and fix dap tests due to API changes in ophyd
This commit is contained in:
@@ -118,12 +118,12 @@ def test_dap_fit(bec_client_lib):
|
||||
dev = bec.device_manager.devices
|
||||
scans = bec.scans
|
||||
|
||||
dev.bpm4i.sim.sim_select_model("GaussianModel")
|
||||
params = dev.bpm4i.sim.sim_params
|
||||
dev.bpm4i.sim.select_model("GaussianModel")
|
||||
params = dev.bpm4i.sim.params
|
||||
params.update(
|
||||
{"noise": "uniform", "noise_multiplier": 10, "center": 5, "sigma": 1, "amplitude": 200}
|
||||
)
|
||||
dev.bpm4i.sim.sim_params = params
|
||||
dev.bpm4i.sim.params = params
|
||||
time.sleep(1)
|
||||
|
||||
res = scans.line_scan(dev.samx, 0, 8, steps=50, relative=False)
|
||||
|
||||
@@ -14,7 +14,6 @@ eiger:
|
||||
softwareTrigger: true
|
||||
|
||||
############## Cameras and detectors end here ##############
|
||||
|
||||
dyn_signals:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.sim.sim.SynDynamicComponents
|
||||
@@ -2114,3 +2113,18 @@ ring_current_sim:
|
||||
readOnly: false
|
||||
################ Read-only signals end here ################
|
||||
|
||||
monitor_async:
|
||||
readoutPriority: async
|
||||
deviceClass: ophyd_devices.sim.sim_monitor.SimMonitorAsync
|
||||
deviceConfig:
|
||||
sim_init:
|
||||
model: GaussianModel
|
||||
params:
|
||||
amplitude: 500
|
||||
center: 0
|
||||
sigma: 1
|
||||
deviceTags:
|
||||
- beamline
|
||||
enabled: true
|
||||
readOnly: false
|
||||
softwareTrigger: true
|
||||
|
||||
@@ -26,7 +26,7 @@ pseudo_signal1:
|
||||
deviceClass: ophyd_devices.ComputedSignal
|
||||
deviceConfig:
|
||||
compute_method: "def compute_signals(signal1, signal2):\n return signal1.get()*signal2.get()\n"
|
||||
input_signals:
|
||||
input_signals:
|
||||
- "bpm4i_readback"
|
||||
- "bpm5i_readback"
|
||||
enabled: true
|
||||
@@ -50,7 +50,7 @@ eyefoc:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -78,7 +78,7 @@ eyey:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -92,7 +92,7 @@ flyer_sim:
|
||||
readoutPriority: on_request
|
||||
deviceClass: ophyd_devices.SynFlyer
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
device_access: true
|
||||
update_frequency: 400
|
||||
deviceTags:
|
||||
@@ -103,7 +103,7 @@ hrox:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -117,7 +117,7 @@ hroy:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -131,7 +131,7 @@ hroz:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -145,7 +145,7 @@ hx:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -173,7 +173,7 @@ hz:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -187,7 +187,7 @@ mbsx:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -215,7 +215,7 @@ pinx:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -229,7 +229,7 @@ piny:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -243,7 +243,7 @@ pinz:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -257,7 +257,7 @@ samx:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -271,7 +271,7 @@ samy:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -285,7 +285,7 @@ samz:
|
||||
readoutPriority: baseline
|
||||
deviceClass: ophyd_devices.SimPositioner
|
||||
deviceConfig:
|
||||
delay: 1
|
||||
delay: 1
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
@@ -671,6 +671,22 @@ transd:
|
||||
enabled: true
|
||||
readOnly: false
|
||||
|
||||
monitor_async:
|
||||
readoutPriority: async
|
||||
deviceClass: ophyd_devices.sim.sim_monitor.SimMonitorAsync
|
||||
deviceConfig:
|
||||
sim_init:
|
||||
model: GaussianModel
|
||||
params:
|
||||
amplitude: 500
|
||||
center: 0
|
||||
sigma: 1
|
||||
deviceTags:
|
||||
- beamline
|
||||
enabled: true
|
||||
readOnly: false
|
||||
softwareTrigger: true
|
||||
|
||||
################ Beamline monitors end here ################
|
||||
|
||||
############################################################
|
||||
@@ -2114,7 +2130,6 @@ ring_current_sim:
|
||||
readOnly: false
|
||||
################ Read-only signals end here ################
|
||||
|
||||
|
||||
############################################################
|
||||
##################### Disabled devices #####################
|
||||
############################################################
|
||||
@@ -2126,13 +2141,13 @@ motor1_disabled:
|
||||
delay: 1
|
||||
labels: motor1_disabled
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
- -50
|
||||
- 50
|
||||
name: motor1_disabled
|
||||
tolerance: 0.01
|
||||
update_frequency: 400
|
||||
deviceTags:
|
||||
- user motors
|
||||
- user motors
|
||||
enabled: false
|
||||
readOnly: false
|
||||
motor1_disabled_set:
|
||||
@@ -2142,13 +2157,13 @@ motor1_disabled_set:
|
||||
delay: 1
|
||||
labels: motor1_disabled_set
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
- -50
|
||||
- 50
|
||||
name: motor1_disabled_set
|
||||
tolerance: 0.01
|
||||
update_frequency: 400
|
||||
deviceTags:
|
||||
- user motors
|
||||
- user motors
|
||||
enabled: true
|
||||
readOnly: true
|
||||
motor2_disabled:
|
||||
@@ -2158,13 +2173,13 @@ motor2_disabled:
|
||||
delay: 1
|
||||
labels: motor2_disabled
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
- -50
|
||||
- 50
|
||||
name: motor2_disabled
|
||||
tolerance: 0.01
|
||||
update_frequency: 400
|
||||
deviceTags:
|
||||
- user motors
|
||||
- user motors
|
||||
enabled: false
|
||||
readOnly: false
|
||||
motor2_disabled_set:
|
||||
@@ -2174,13 +2189,13 @@ motor2_disabled_set:
|
||||
delay: 1
|
||||
labels: motor2_disabled_set
|
||||
limits:
|
||||
- -50
|
||||
- 50
|
||||
- -50
|
||||
- 50
|
||||
name: motor2_disabled_set
|
||||
tolerance: 0.01
|
||||
update_frequency: 400
|
||||
deviceTags:
|
||||
- user motors
|
||||
- user motors
|
||||
enabled: true
|
||||
readOnly: true
|
||||
######### DeviceProxy and SimCamera for delayed init tests ##########
|
||||
|
||||
@@ -23,13 +23,13 @@ Proxies override the `_compute` method from the signal of the device they are co
|
||||
```
|
||||
## Usage
|
||||
|
||||
The simulation framework for each simulated device can be accessed through `dev.<devname>.sim`. We have implemented three methods and a property to facilitate easy access configuration and configuration of the simulation parameters. These are `dev.<devname>.sim.sim_get_models()`, `dev.<devname>.sim.sim_select_model()`, `dev.<devname>.sim.sim_show_all()`, and `dev.<devname>.sim.sim_params`. With these functions, you can configure the simulation of your device as needed.
|
||||
The simulation framework for each simulated device can be accessed through `dev.<devname>.sim`. We have implemented three methods and a property to facilitate easy access configuration and configuration of the simulation parameters. These are `dev.<devname>.sim.get_models()`, `dev.<devname>.sim.select_model()`, `dev.<devname>.sim.show_all()`, and `dev.<devname>.sim.params`. With these functions, you can configure the simulation of your device as needed.
|
||||
|
||||
### Configuration of simulated devices
|
||||
As mentioned earlier, `SimMonitor` and `SimCamera` offer different simulation types. To receive a list of strings with all available simulation types for `SimMonitor`, you can use the code below:
|
||||
|
||||
```ipython
|
||||
• demo [11/171] ❯❯ dev.bpm4i.sim.sim_get_models()
|
||||
• demo [11/171] ❯❯ dev.bpm4i.sim.get_models()
|
||||
Out[11]:
|
||||
['BreitWignerModel',
|
||||
'ConstantModel',
|
||||
@@ -62,7 +62,7 @@ Out[11]:
|
||||
```
|
||||
By default, monitors are initialized with the *ConstantModel* and a uniform noise pattern. To change this for the device `dev.bpm4i` to first simulate a *Gaussian* function and then use *Poisson* noise, follow the steps below:
|
||||
```ipython
|
||||
• demo [12/171] ❯❯ dev.bpm4i.sim.sim_select_model("GaussianModel")
|
||||
• demo [12/171] ❯❯ dev.bpm4i.sim.select_model("GaussianModel")
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Currently active model: <lmfit.Model: Model(gaussian)> |
|
||||
+----------------------------------------------------------+-------------------+-----------------------------------------------------------+
|
||||
@@ -77,8 +77,8 @@ By default, monitors are initialized with the *ConstantModel* and a uniform nois
|
||||
| noise_multiplier | 10 | <class 'int'> |
|
||||
| ref_motor | samx | <class 'str'> |
|
||||
+----------------------------------------------------------+-------------------+-----------------------------------------------------------+
|
||||
• demo [13/171] ❯❯ dev.bpm4i.sim.sim_params = {"noise" : "poisson"}
|
||||
• demo [14/171] ❯❯ dev.bpm4i.sim.sim_params
|
||||
• demo [13/171] ❯❯ dev.bpm4i.sim.params = {"noise" : "poisson"}
|
||||
• demo [14/171] ❯❯ dev.bpm4i.sim.params
|
||||
Out[14]:
|
||||
{'amplitude': 100,
|
||||
'center': 0,
|
||||
@@ -90,11 +90,11 @@ Out[14]:
|
||||
'ref_motor': 'samx'}
|
||||
```
|
||||
```{note}
|
||||
`dev.<devname>.sim.sim_params` is a property and by assigning a new dictionary to it, you will not override all parameters but update the current set of parameters stored in the property. It will raise if you are trying to set a key to an irregular value, e.g. non existing model, or in case of a key does not exist in sim_params.
|
||||
`dev.<devname>.sim.params` is a property and by assigning a new dictionary to it, you will not override all parameters but update the current set of parameters stored in the property. It will raise if you are trying to set a key to an irregular value, e.g. non existing model, or in case of a key does not exist in params.
|
||||
```
|
||||
Finally, you can use `dev.bpm4i.sim.sim_show_all()` to obtain a comprehensive printout of the currently active model, all available methods, and the available models for this device. Similarly, you may configure the `SimCamera`, which implements only a limited scope of simulation models, as shown below:
|
||||
Finally, you can use `dev.bpm4i.sim.show_all()` to obtain a comprehensive printout of the currently active model, all available methods, and the available models for this device. Similarly, you may configure the `SimCamera`, which implements only a limited scope of simulation models, as shown below:
|
||||
```ipython
|
||||
• demo [15/171] ❯❯ dev.eiger.sim.sim_get_models()
|
||||
• demo [15/171] ❯❯ dev.eiger.sim.get_models()
|
||||
Out[15]: ['constant', 'gaussian']
|
||||
```
|
||||
### Simulation scenarios
|
||||
|
||||
Reference in New Issue
Block a user