3.9 KiB
AreaDetector simulator
This Docker image runs a local simDetector IOC at the BEC:SIM: PV prefix. It
provides two ROI/Stats chains, image transforms, ADZMQ preview and HDF5 capture.
Requirements
- A running local Docker engine or Docker Desktop with Linux containers. The
image uses
linux/amd64. On Apple Silicon, Docker Desktop must be able to run amd64 containers through emulation. - Network access during the first build to pull the base image and download Debian packages and ADZMQ.
- For BEC integration, a local BEC environment and Redis. Install this
ophyd_devicescheckout into the Python environment used by the device server and use a BEC version with the companion ROI and signal metadata interfaces.
Start the IOC
Run these commands from the repository root:
bash docker/adsim/setup.sh start
docker logs --tail 30 bec-adsim
docker inspect --format '{{.State.Health.Status}}' bec-adsim
Wait for the health status to become healthy. The default container is
bec-adsim and exposes Channel Access on localhost port 6064 (TCP and UDP)
and ZMQ on localhost port 5555. Acquisition starts idle and BEC can start live
acquisition when the camera connects.
To build separately, run bash docker/adsim/setup.sh build. To reuse an
already built image, run ADSIM_SKIP_BUILD=1 bash docker/adsim/setup.sh start.
The script refuses to replace a container with the same name.
Connect a local BEC session
-
To save HDF5 frames, set
ADSIM_DATA_DIRto the absolute host directory containing BEC's output paths before starting the IOC. Docker mounts that directory at/data. With no override, it mountsdocker/adsim/data. -
Copy the example camera config to a local YAML file, such as
adsim.local.yaml. Keep theBEC:SIM:prefix. For HDF5 output, setdeviceConfig.hdf5_path_mappingto map the same host directory from step 1 to/data, for example{"/absolute/bec/data": "/data"}. SetdeviceConfig.save_frame_data: falseto run without saving frame files. -
Start local Redis and the BEC services. Apply the simulator exports in the environment that runs
bec-device-server. For a local tmux setup, usebec-server start --interface tmuxand attach withbec-server attach. In the device server pane, stop the device server with Ctrl+C and change to theophyd_devicesrepository root. With the BEC environment active, restart it directly in that pane:adsim_env=$(bash docker/adsim/setup.sh env) && eval "$adsim_env" && bec-device-serverIf the original device server used a custom service configuration, pass the same
--configpath tobec-device-server. For a systemd-managed device server, apply the generated EPICS values in its service environment and restart the service. The exports add the IOC to the existing CA discovery lists of the shell where they are evaluated. -
Run
becfrom the repository root in a second terminal with the BEC environment active. At the BEC prompt, add the camera to your local session:bec.config.add_to_session("./adsim.local.yaml") dev.show_all()
If a default port is occupied, set ADSIM_CA_PORT or ADSIM_ZMQ_PORT in
the environment. Use distinct host ports and export the same overrides
in the device server pane before running setup.sh env there. The CA port
must be in the range 1–65534 and cannot be 5555, which the IOC reserves for
ZMQ even when the host ZMQ port changes.
For a custom ZMQ port, set
deviceConfig.preview_transports.preview[0].address in your local YAML to
the URL printed as ADSIM_ZMQ_ADDRESS.
Stop the IOC
bash docker/adsim/setup.sh stop
If you set ADSIM_CONTAINER to a custom name, use it again for stop.
The command removes the simulator container and keeps files in the mounted
host directory. Run bash docker/adsim/setup.sh --help for all options.