Skip to content
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies = [
"dls-dodal>=2.2.0",
"ophyd-async[sim]",
"scanspec",
"blueapi",
]
dynamic = ["version"]
license.file = "LICENSE"
Expand Down Expand Up @@ -52,7 +53,6 @@ dev = [
"matplotlib",
"numpy",
"pyepics",
"blueapi",
]

[project.scripts]
Expand Down Expand Up @@ -92,6 +92,10 @@ data_file = "/tmp/sm_bluesky.coverage"
# Tests are run from installed location, map back to the src directory
source = ["src", "**/site-packages/"]

[tool.coverage.report]
# Exclude blueapi client startup scripts from code coverage report
omit = ["*/sm_bluesky/scripts/clients/*"]

[tool.tox]
skipsdist = true
# envs to runs automatically with tox -p
Expand Down
Empty file.
Empty file.
49 changes: 49 additions & 0 deletions src/sm_bluesky/scripts/clients/blueapi_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Start this script by running:
$ python -i src/sm_bluesky/scripts/clients/blueapi_client.py
"""

from os import environ

from blueapi.client import BlueapiClient
from blueapi.config import ApplicationConfig, HttpUrl, RestConfig, StompConfig, TcpUrl
from blueapi.core.bluesky_types import DataEvent

if __name__ == "__main__":
BEAMLINE = environ.get("BEAMLINE")
if BEAMLINE is None:
raise RuntimeError("BEAMLINE environment variable not set.")

print(f"Starting BlueAPI client for {BEAMLINE}.")
bc = BlueapiClient.from_config(
ApplicationConfig(
api=RestConfig(url=HttpUrl(f"https://{BEAMLINE}-blueapi.diamond.ac.uk")),
stomp=StompConfig(
enabled=True,
url=TcpUrl(f"tcp://{BEAMLINE}-rabbitmq-daq.diamond.ac.uk:61613"),
),
)
)
print('Created BlueapiClient "bc" object.')
print("Logging in...")
bc.login()

def _feedback(evt):
match evt:
case DataEvent(name="start"):
print("Run started")
case DataEvent(name="stop", doc={"exit_status": status}):
print("Run complete: ", status)
case DataEvent(name="event", doc={"seq_num": point, "data": data}):
print(f" Point {point}: {data}")

feedback_id = bc.add_callback(_feedback)
print("Installed feedback.")

print("\nGetting devices and plans...")
devs = bc.devices
plans = bc.plans
print(devs)
print(plans)

print("Please remember to configure the correct instrument session for bc.")
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading