ophyd-async 0.3rc2__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/PKG-INFO +2 -2
  2. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/README.md +1 -1
  3. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/_version.py +2 -2
  4. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/detector.py +15 -10
  5. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/device_save_loader.py +1 -23
  6. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/mock_signal_utils.py +16 -2
  7. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/signal.py +34 -13
  8. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/standard_readable.py +2 -0
  9. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/_backend/_aioca.py +93 -18
  10. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/_backend/_p4p.py +81 -16
  11. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/_backend/common.py +24 -1
  12. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/pilatus_controller.py +18 -5
  13. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/pilatus_driver.py +2 -2
  14. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/pilatus.py +21 -4
  15. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/pvi/pvi.py +26 -6
  16. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_hdf_panda.py +0 -1
  17. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/plan_stubs/fly.py +4 -0
  18. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/sim_pattern_generator.py +0 -2
  19. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/PKG-INFO +2 -2
  20. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/SOURCES.txt +2 -1
  21. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_device_save_loader.py +99 -1
  22. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_flyer.py +0 -2
  23. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_signal.py +31 -0
  24. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_standard_readable.py +12 -1
  25. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_controllers.py +26 -16
  26. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_pilatus.py +48 -6
  27. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_scans.py +5 -3
  28. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/test_pvi.py +58 -0
  29. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/test_records.db +28 -0
  30. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/test_signals.py +330 -82
  31. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/plan_stubs/test_fly.py +45 -5
  32. ophyd_async-0.3.1/tests/test_data/test_yaml_save.yml +22 -0
  33. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.codecov.yml +0 -0
  34. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.copier-answers.yml +0 -0
  35. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.devcontainer/devcontainer.json +0 -0
  36. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.git-blame-ignore-revs +0 -0
  37. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/CONTRIBUTING.md +0 -0
  38. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/actions/install_requirements/action.yml +0 -0
  39. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/dependabot.yml +0 -0
  40. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/pages/index.html +0 -0
  41. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/pages/make_switcher.py +0 -0
  42. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_check.yml +0 -0
  43. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_dist.yml +0 -0
  44. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_docs.yml +0 -0
  45. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_pypi.yml +0 -0
  46. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_release.yml +0 -0
  47. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_test.yml +0 -0
  48. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/_tox.yml +0 -0
  49. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/ci.yml +0 -0
  50. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.github/workflows/periodic.yml +0 -0
  51. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.gitignore +0 -0
  52. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.mailmap +0 -0
  53. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/.pre-commit-config.yaml +0 -0
  54. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/Dockerfile +0 -0
  55. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/LICENSE +0 -0
  56. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/_templates/README +0 -0
  57. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/_templates/custom-class-template.rst +0 -0
  58. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/_templates/custom-module-template.rst +0 -0
  59. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/conf.py +0 -0
  60. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/examples/epics_demo.py +0 -0
  61. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/examples/foo_detector.py +0 -0
  62. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0001-record-architecture-decisions.md +0 -0
  63. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0002-switched-to-python-copier-template.md +0 -0
  64. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0003-ophyd-async-migration.rst +0 -0
  65. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0004-repository-structure.rst +0 -0
  66. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0005-respect-black-line-length.rst +0 -0
  67. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/0006-procedural-device-definitions.rst +0 -0
  68. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions/COPYME +0 -0
  69. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/decisions.md +0 -0
  70. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/design-goals.rst +0 -0
  71. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/event-loop-choice.rst +0 -0
  72. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations/flyscanning.rst +0 -0
  73. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/explanations.md +0 -0
  74. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/genindex.rst +0 -0
  75. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/choose-interfaces-for-devices.md +0 -0
  76. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/compound-devices.rst +0 -0
  77. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/contribute.md +0 -0
  78. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/make-a-simple-device.rst +0 -0
  79. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/make-a-standard-detector.rst +0 -0
  80. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to/write-tests-for-devices.rst +0 -0
  81. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/how-to.md +0 -0
  82. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/images/bluesky_ophyd_epics_devices_logo.svg +0 -0
  83. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/images/bluesky_ophyd_logo.svg +0 -0
  84. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/images/ophyd_favicon.svg +0 -0
  85. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/index.md +0 -0
  86. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/reference/api.rst +0 -0
  87. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/reference.md +0 -0
  88. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/tutorials/installation.md +0 -0
  89. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/tutorials/using-existing-devices.rst +0 -0
  90. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/docs/tutorials.md +0 -0
  91. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/pyproject.toml +0 -0
  92. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/setup.cfg +0 -0
  93. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/__init__.py +0 -0
  94. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/__main__.py +0 -0
  95. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/__init__.py +0 -0
  96. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/_providers.py +0 -0
  97. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/async_status.py +0 -0
  98. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/device.py +0 -0
  99. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/flyer.py +0 -0
  100. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/mock_signal_backend.py +0 -0
  101. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/signal_backend.py +0 -0
  102. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/soft_signal_backend.py +0 -0
  103. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/core/utils.py +0 -0
  104. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/__init__.py +0 -0
  105. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/_backend/__init__.py +0 -0
  106. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/__init__.py +0 -0
  107. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/aravis.py +0 -0
  108. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/__init__.py +0 -0
  109. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/ad_sim_controller.py +0 -0
  110. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/aravis_controller.py +0 -0
  111. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/kinetix_controller.py +0 -0
  112. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/controllers/vimba_controller.py +0 -0
  113. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/__init__.py +0 -0
  114. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/ad_base.py +0 -0
  115. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/aravis_driver.py +0 -0
  116. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/kinetix_driver.py +0 -0
  117. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/drivers/vimba_driver.py +0 -0
  118. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/kinetix.py +0 -0
  119. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/single_trigger_det.py +0 -0
  120. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/utils.py +0 -0
  121. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/vimba.py +0 -0
  122. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/__init__.py +0 -0
  123. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/_hdfdataset.py +0 -0
  124. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/_hdffile.py +0 -0
  125. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/hdf_writer.py +0 -0
  126. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/nd_file_hdf.py +0 -0
  127. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/areadetector/writers/nd_plugin.py +0 -0
  128. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/demo/__init__.py +0 -0
  129. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/demo/demo_ad_sim_detector.py +0 -0
  130. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/demo/mover.db +0 -0
  131. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/demo/sensor.db +0 -0
  132. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/motion/__init__.py +0 -0
  133. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/motion/motor.py +0 -0
  134. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/pvi/__init__.py +0 -0
  135. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/signal/__init__.py +0 -0
  136. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/signal/_epics_transport.py +0 -0
  137. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/epics/signal/signal.py +0 -0
  138. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/log.py +0 -0
  139. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/__init__.py +0 -0
  140. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_common_blocks.py +0 -0
  141. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_panda_controller.py +0 -0
  142. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_table.py +0 -0
  143. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_trigger.py +0 -0
  144. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/_utils.py +0 -0
  145. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/writers/__init__.py +0 -0
  146. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/writers/_hdf_writer.py +0 -0
  147. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/panda/writers/_panda_hdf_file.py +0 -0
  148. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/plan_stubs/__init__.py +0 -0
  149. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/plan_stubs/ensure_connected.py +0 -0
  150. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/protocols.py +0 -0
  151. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/__init__.py +0 -0
  152. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/demo/__init__.py +0 -0
  153. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/demo/sim_motor.py +0 -0
  154. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/pattern_generator.py +0 -0
  155. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/sim_pattern_detector_control.py +0 -0
  156. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async/sim/sim_pattern_detector_writer.py +0 -0
  157. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/dependency_links.txt +0 -0
  158. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/entry_points.txt +0 -0
  159. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/requires.txt +0 -0
  160. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/src/ophyd_async.egg-info/top_level.txt +0 -0
  161. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/conftest.py +0 -0
  162. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_async_status.py +0 -0
  163. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_device.py +0 -0
  164. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_device_collector.py +0 -0
  165. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_mock_signal_backend.py +0 -0
  166. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_soft_signal_backend.py +0 -0
  167. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_utils.py +0 -0
  168. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/core/test_watchable_async_status.py +0 -0
  169. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/_backend/test_common.py +0 -0
  170. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/__init__.py +0 -0
  171. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_aravis.py +0 -0
  172. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_drivers.py +0 -0
  173. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_kinetix.py +0 -0
  174. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_single_trigger_det.py +0 -0
  175. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_utils.py +0 -0
  176. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_vimba.py +0 -0
  177. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/areadetector/test_writers.py +0 -0
  178. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/demo/test_demo.py +0 -0
  179. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/demo/test_demo_ad_sim_detector.py +0 -0
  180. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/motion/__init__.py +0 -0
  181. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/epics/motion/test_motor.py +0 -0
  182. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/db/panda.db +0 -0
  183. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_hdf_panda.py +0 -0
  184. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_panda_connect.py +0 -0
  185. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_panda_controller.py +0 -0
  186. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_panda_utils.py +0 -0
  187. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_table.py +0 -0
  188. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_trigger.py +0 -0
  189. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/panda/test_writer.py +0 -0
  190. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/protocols/test_protocols.py +0 -0
  191. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/__init__.py +0 -0
  192. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/conftest.py +0 -0
  193. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/demo/__init__.py +0 -0
  194. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/demo/test_sim_motor.py +0 -0
  195. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/test_pattern_generator.py +0 -0
  196. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/test_sim_detector.py +0 -0
  197. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/test_sim_writer.py +0 -0
  198. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/sim/test_streaming_plan.py +0 -0
  199. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/test_cli.py +0 -0
  200. {ophyd_async-0.3rc2 → ophyd_async-0.3.1}/tests/test_log.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ophyd-async
3
- Version: 0.3rc2
3
+ Version: 0.3.1
4
4
  Summary: Asynchronous Bluesky hardware abstraction code, compatible with control systems like EPICS and Tango
5
5
  Author-email: Tom Cobb <tom.cobb@diamond.ac.uk>
6
6
  License: BSD 3-Clause License
@@ -96,7 +96,7 @@ Requires-Dist: types-pyyaml; extra == "dev"
96
96
 
97
97
  # ophyd-async
98
98
 
99
- Asynchronous Bluesky hardware abstraction code, compatible with control systems like EPICS and Tango
99
+ Asynchronous Bluesky hardware abstraction code, compatible with control systems like EPICS and Tango.
100
100
 
101
101
  | Source | <https://github.com/bluesky/ophyd-async> |
102
102
  | :-----------: | :-----------------------------------------------: |
@@ -5,7 +5,7 @@
5
5
 
6
6
  # ophyd-async
7
7
 
8
- Asynchronous Bluesky hardware abstraction code, compatible with control systems like EPICS and Tango
8
+ Asynchronous Bluesky hardware abstraction code, compatible with control systems like EPICS and Tango.
9
9
 
10
10
  | Source | <https://github.com/bluesky/ophyd-async> |
11
11
  | :-----------: | :-----------------------------------------------: |
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3rc2'
16
- __version_tuple__ = version_tuple = (0, 3)
15
+ __version__ = version = '0.3.1'
16
+ __version_tuple__ = version_tuple = (0, 3, 1)
@@ -63,6 +63,8 @@ class TriggerInfo:
63
63
  deadtime: float
64
64
  #: What is the maximum high time of the triggers
65
65
  livetime: float
66
+ #: What is the maximum timeout on waiting for a frame
67
+ frame_timeout: float | None = None
66
68
 
67
69
 
68
70
  class DetectorControl(ABC):
@@ -162,7 +164,6 @@ class StandardDetector(
162
164
  writer: DetectorWriter,
163
165
  config_sigs: Sequence[AsyncReadable] = (),
164
166
  name: str = "",
165
- writer_timeout: float = DEFAULT_TIMEOUT,
166
167
  ) -> None:
167
168
  """
168
169
  Constructor
@@ -173,16 +174,11 @@ class StandardDetector(
173
174
  config_sigs: Signals to read when describe and read
174
175
  configuration are called. Defaults to ().
175
176
  name: Device name. Defaults to "".
176
- writer_timeout: Timeout for frame writing to start, if the
177
- timeout is reached, ophyd-async assumes the detector
178
- has a problem and raises an error.
179
- Defaults to DEFAULT_TIMEOUT.
180
177
  """
181
178
  self._controller = controller
182
179
  self._writer = writer
183
180
  self._describe: Dict[str, DataKey] = {}
184
181
  self._config_sigs = list(config_sigs)
185
- self._frame_writing_timeout = writer_timeout
186
182
  # For prepare
187
183
  self._arm_status: Optional[AsyncStatus] = None
188
184
  self._trigger_info: Optional[TriggerInfo] = None
@@ -245,17 +241,21 @@ class StandardDetector(
245
241
 
246
242
  @AsyncStatus.wrap
247
243
  async def trigger(self) -> None:
244
+ # set default trigger_info
245
+ self._trigger_info = TriggerInfo(
246
+ num=1, trigger=DetectorTrigger.internal, deadtime=0.0, livetime=0.0
247
+ )
248
248
  # Arm the detector and wait for it to finish.
249
249
  indices_written = await self.writer.get_indices_written()
250
250
  written_status = await self.controller.arm(
251
- num=1,
252
- trigger=DetectorTrigger.internal,
251
+ num=self._trigger_info.num,
252
+ trigger=self._trigger_info.trigger,
253
253
  )
254
254
  await written_status
255
255
  end_observation = indices_written + 1
256
256
 
257
257
  async for index in self.writer.observe_indices_written(
258
- self._frame_writing_timeout
258
+ DEFAULT_TIMEOUT + self._trigger_info.livetime + self._trigger_info.deadtime
259
259
  ):
260
260
  if index >= end_observation:
261
261
  break
@@ -309,7 +309,12 @@ class StandardDetector(
309
309
  assert self._arm_status, "Prepare not run"
310
310
  assert self._trigger_info
311
311
  async for index in self.writer.observe_indices_written(
312
- self._frame_writing_timeout
312
+ self._trigger_info.frame_timeout
313
+ or (
314
+ DEFAULT_TIMEOUT
315
+ + self._trigger_info.livetime
316
+ + self._trigger_info.deadtime
317
+ )
313
318
  ):
314
319
  yield WatcherUpdate(
315
320
  name=self.name,
@@ -1,6 +1,5 @@
1
1
  from enum import Enum
2
- from functools import partial
3
- from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Union
2
+ from typing import Any, Callable, Dict, Generator, List, Optional, Sequence
4
3
 
5
4
  import numpy as np
6
5
  import numpy.typing as npt
@@ -8,13 +7,10 @@ import yaml
8
7
  from bluesky.plan_stubs import abs_set, wait
9
8
  from bluesky.protocols import Location
10
9
  from bluesky.utils import Msg
11
- from epicscorelibs.ca.dbr import ca_array, ca_float, ca_int, ca_str
12
10
 
13
11
  from .device import Device
14
12
  from .signal import SignalRW
15
13
 
16
- CaType = Union[ca_float, ca_int, ca_str, ca_array]
17
-
18
14
 
19
15
  def ndarray_representer(dumper: yaml.Dumper, array: npt.NDArray[Any]) -> yaml.Node:
20
16
  return dumper.represent_sequence(
@@ -22,19 +18,6 @@ def ndarray_representer(dumper: yaml.Dumper, array: npt.NDArray[Any]) -> yaml.No
22
18
  )
23
19
 
24
20
 
25
- def ca_dbr_representer(dumper: yaml.Dumper, value: CaType) -> yaml.Node:
26
- # if it's an array, just call ndarray_representer...
27
- represent_array = partial(ndarray_representer, dumper)
28
-
29
- representers: Dict[CaType, Callable[[CaType], yaml.Node]] = {
30
- ca_float: dumper.represent_float,
31
- ca_int: dumper.represent_int,
32
- ca_str: dumper.represent_str,
33
- ca_array: represent_array,
34
- }
35
- return representers[type(value)](value)
36
-
37
-
38
21
  class OphydDumper(yaml.Dumper):
39
22
  def represent_data(self, data: Any) -> Any:
40
23
  if isinstance(data, Enum):
@@ -152,11 +135,6 @@ def save_to_yaml(phases: Sequence[Dict[str, Any]], save_path: str) -> None:
152
135
 
153
136
  yaml.add_representer(np.ndarray, ndarray_representer, Dumper=yaml.Dumper)
154
137
 
155
- yaml.add_representer(ca_float, ca_dbr_representer, Dumper=yaml.Dumper)
156
- yaml.add_representer(ca_int, ca_dbr_representer, Dumper=yaml.Dumper)
157
- yaml.add_representer(ca_str, ca_dbr_representer, Dumper=yaml.Dumper)
158
- yaml.add_representer(ca_array, ca_dbr_representer, Dumper=yaml.Dumper)
159
-
160
138
  with open(save_path, "w") as file:
161
139
  yaml.dump(phases, file, Dumper=OphydDumper, default_flow_style=False)
162
140
 
@@ -79,8 +79,22 @@ class _SetValuesIterator:
79
79
  return next_value
80
80
 
81
81
  def __del__(self):
82
- if self.require_all_consumed and self.index != len(list(self.values)):
83
- raise AssertionError("Not all values have been consumed.")
82
+ if self.require_all_consumed:
83
+ # Values is cast to a list here because the user has supplied
84
+ # require_all_consumed=True, we can therefore assume they
85
+ # supplied a finite list.
86
+ # In the case of require_all_consumed=False, an infinite
87
+ # iterble is permitted
88
+ values = list(self.values)
89
+ if self.index != len(values):
90
+ # Report the values consumed and the values yet to be
91
+ # consumed
92
+ consumed = values[0 : self.index]
93
+ to_be_consumed = values[self.index :]
94
+ raise AssertionError(
95
+ f"{self.signal.name}: {consumed} were consumed "
96
+ f"but {to_be_consumed} were not consumed"
97
+ )
84
98
 
85
99
 
86
100
  def set_mock_values(
@@ -57,7 +57,7 @@ class Signal(Device, Generic[T]):
57
57
 
58
58
  def __init__(
59
59
  self,
60
- backend: SignalBackend[T],
60
+ backend: Optional[SignalBackend[T]] = None,
61
61
  timeout: Optional[float] = DEFAULT_TIMEOUT,
62
62
  name: str = "",
63
63
  ) -> None:
@@ -66,13 +66,24 @@ class Signal(Device, Generic[T]):
66
66
  super().__init__(name)
67
67
 
68
68
  async def connect(
69
- self, mock=False, timeout=DEFAULT_TIMEOUT, force_reconnect: bool = False
69
+ self,
70
+ mock=False,
71
+ timeout=DEFAULT_TIMEOUT,
72
+ force_reconnect: bool = False,
73
+ backend: Optional[SignalBackend[T]] = None,
70
74
  ):
75
+ if backend:
76
+ if self._initial_backend and backend is not self._initial_backend:
77
+ raise ValueError(
78
+ "Backend at connection different from initialised one."
79
+ )
80
+ self._backend = backend
71
81
  if mock and not isinstance(self._backend, MockSignalBackend):
72
82
  # Using a soft backend, look to the initial value
73
- self._backend = MockSignalBackend(
74
- initial_backend=self._initial_backend,
75
- )
83
+ self._backend = MockSignalBackend(initial_backend=self._backend)
84
+
85
+ if self._backend is None:
86
+ raise RuntimeError("`connect` called on signal without backend")
76
87
  self.log.debug(f"Connecting to {self.source}")
77
88
  await self._backend.connect(timeout=timeout)
78
89
 
@@ -283,15 +294,15 @@ def soft_signal_r_and_setter(
283
294
 
284
295
 
285
296
  def _generate_assert_error_msg(
286
- name: str, expected_result: str, actuall_result: str
297
+ name: str, expected_result: str, actual_result: str
287
298
  ) -> str:
288
299
  WARNING = "\033[93m"
289
300
  FAIL = "\033[91m"
290
301
  ENDC = "\033[0m"
291
302
  return (
292
303
  f"Expected {WARNING}{name}{ENDC} to produce"
293
- + f"\n{FAIL}{actuall_result}{ENDC}"
294
- + f"\nbut actually got \n{FAIL}{expected_result}{ENDC}"
304
+ + f"\n{FAIL}{expected_result}{ENDC}"
305
+ + f"\nbut actually got \n{FAIL}{actual_result}{ENDC}"
295
306
  )
296
307
 
297
308
 
@@ -313,7 +324,9 @@ async def assert_value(signal: SignalR[T], value: Any) -> None:
313
324
  """
314
325
  actual_value = await signal.get_value()
315
326
  assert actual_value == value, _generate_assert_error_msg(
316
- signal.name, value, actual_value
327
+ name=signal.name,
328
+ expected_result=value,
329
+ actual_result=actual_value,
317
330
  )
318
331
 
319
332
 
@@ -338,7 +351,9 @@ async def assert_reading(
338
351
  """
339
352
  actual_reading = await readable.read()
340
353
  assert expected_reading == actual_reading, _generate_assert_error_msg(
341
- readable.name, expected_reading, actual_reading
354
+ name=readable.name,
355
+ expected_result=expected_reading,
356
+ actual_result=actual_reading,
342
357
  )
343
358
 
344
359
 
@@ -364,7 +379,9 @@ async def assert_configuration(
364
379
  """
365
380
  actual_configurable = await configurable.read_configuration()
366
381
  assert configuration == actual_configurable, _generate_assert_error_msg(
367
- configurable.name, configuration, actual_configurable
382
+ name=configurable.name,
383
+ expected_result=configuration,
384
+ actual_result=actual_configurable,
368
385
  )
369
386
 
370
387
 
@@ -386,11 +403,15 @@ def assert_emitted(docs: Mapping[str, list[dict]], **numbers: int):
386
403
  resource=1, datum=1, event=1, stop=1)
387
404
  """
388
405
  assert list(docs) == list(numbers), _generate_assert_error_msg(
389
- "documents", list(numbers), list(docs)
406
+ name="documents",
407
+ expected_result=list(numbers),
408
+ actual_result=list(docs),
390
409
  )
391
410
  actual_numbers = {name: len(d) for name, d in docs.items()}
392
411
  assert actual_numbers == numbers, _generate_assert_error_msg(
393
- "emitted", numbers, actual_numbers
412
+ name="emitted",
413
+ expected_result=numbers,
414
+ actual_result=actual_numbers,
394
415
  )
395
416
 
396
417
 
@@ -254,6 +254,8 @@ class HintedSignal(HasHints, AsyncReadable):
254
254
 
255
255
  @property
256
256
  def hints(self) -> Hints:
257
+ if self.signal.name == "":
258
+ return {"fields": []}
257
259
  return {"fields": [self.signal.name]}
258
260
 
259
261
  @classmethod
@@ -2,8 +2,10 @@ import logging
2
2
  import sys
3
3
  from dataclasses import dataclass
4
4
  from enum import Enum
5
- from typing import Any, Dict, Optional, Sequence, Type, Union
5
+ from math import isnan, nan
6
+ from typing import Any, Dict, List, Optional, Type, Union
6
7
 
8
+ import numpy as np
7
9
  from aioca import (
8
10
  FORMAT_CTRL,
9
11
  FORMAT_RAW,
@@ -28,7 +30,7 @@ from ophyd_async.core import (
28
30
  )
29
31
  from ophyd_async.core.utils import DEFAULT_TIMEOUT, NotConnected
30
32
 
31
- from .common import get_supported_values
33
+ from .common import LimitPair, Limits, common_meta, get_supported_values
32
34
 
33
35
  dbr_to_dtype: Dict[Dbr, Dtype] = {
34
36
  dbr.DBR_STRING: "string",
@@ -40,6 +42,64 @@ dbr_to_dtype: Dict[Dbr, Dtype] = {
40
42
  }
41
43
 
42
44
 
45
+ def _data_key_from_augmented_value(
46
+ value: AugmentedValue,
47
+ *,
48
+ choices: Optional[List[str]] = None,
49
+ dtype: Optional[str] = None,
50
+ ) -> DataKey:
51
+ """Use the return value of get with FORMAT_CTRL to construct a DataKey
52
+ describing the signal. See docstring of AugmentedValue for expected
53
+ value fields by DBR type.
54
+
55
+ Args:
56
+ value (AugmentedValue): Description of the the return type of a DB record
57
+ choices: Optional list of enum choices to pass as metadata in the datakey
58
+ dtype: Optional override dtype when AugmentedValue is ambiguous, e.g. booleans
59
+
60
+ Returns:
61
+ DataKey: A rich DataKey describing the DB record
62
+ """
63
+ source = f"ca://{value.name}"
64
+ assert value.ok, f"Error reading {source}: {value}"
65
+
66
+ scalar = value.element_count == 1
67
+ dtype = dtype or dbr_to_dtype[value.datatype]
68
+
69
+ d = DataKey(
70
+ source=source,
71
+ dtype=dtype if scalar else "array",
72
+ # strictly value.element_count >= len(value)
73
+ shape=[] if scalar else [len(value)],
74
+ )
75
+ for key in common_meta:
76
+ attr = getattr(value, key, nan)
77
+ if isinstance(attr, str) or not isnan(attr):
78
+ d[key] = attr
79
+
80
+ if choices is not None:
81
+ d["choices"] = choices
82
+
83
+ if limits := _limits_from_augmented_value(value):
84
+ d["limits"] = limits
85
+
86
+ return d
87
+
88
+
89
+ def _limits_from_augmented_value(value: AugmentedValue) -> Limits:
90
+ def get_limits(limit: str) -> LimitPair:
91
+ low = getattr(value, f"lower_{limit}_limit", None)
92
+ high = getattr(value, f"upper_{limit}_limit", None)
93
+ return LimitPair(low=low, high=high)
94
+
95
+ return Limits(
96
+ alarm=get_limits("alarm"),
97
+ control=get_limits("ctrl"),
98
+ display=get_limits("disp"),
99
+ warning=get_limits("warning"),
100
+ )
101
+
102
+
43
103
  @dataclass
44
104
  class CaConverter:
45
105
  read_dbr: Optional[Dbr]
@@ -49,7 +109,10 @@ class CaConverter:
49
109
  return value
50
110
 
51
111
  def value(self, value: AugmentedValue):
52
- return value
112
+ # for channel access ca_xxx classes, this
113
+ # invokes __pos__ operator to return an instance of
114
+ # the builtin base class
115
+ return +value
53
116
 
54
117
  def reading(self, value: AugmentedValue):
55
118
  return {
@@ -58,8 +121,8 @@ class CaConverter:
58
121
  "alarm_severity": -1 if value.severity > 2 else value.severity,
59
122
  }
60
123
 
61
- def get_datakey(self, source: str, value: AugmentedValue) -> DataKey:
62
- return {"source": source, "dtype": dbr_to_dtype[value.datatype], "shape": []}
124
+ def get_datakey(self, value: AugmentedValue) -> DataKey:
125
+ return _data_key_from_augmented_value(value)
63
126
 
64
127
 
65
128
  class CaLongStrConverter(CaConverter):
@@ -73,12 +136,17 @@ class CaLongStrConverter(CaConverter):
73
136
 
74
137
 
75
138
  class CaArrayConverter(CaConverter):
76
- def get_datakey(self, source: str, value: AugmentedValue) -> DataKey:
77
- return {"source": source, "dtype": "array", "shape": [len(value)]}
139
+ def value(self, value: AugmentedValue):
140
+ return np.array(value, copy=False)
78
141
 
79
142
 
80
143
  @dataclass
81
144
  class CaEnumConverter(CaConverter):
145
+ """To prevent issues when a signal is restarted and returns with different enum
146
+ values or orders, we put treat an Enum signal as a string, and cache the
147
+ choices on this class.
148
+ """
149
+
82
150
  choices: dict[str, str]
83
151
 
84
152
  def write_value(self, value: Union[Enum, str]):
@@ -90,13 +158,18 @@ class CaEnumConverter(CaConverter):
90
158
  def value(self, value: AugmentedValue):
91
159
  return self.choices[value]
92
160
 
93
- def get_datakey(self, source: str, value: AugmentedValue) -> DataKey:
94
- return {
95
- "source": source,
96
- "dtype": "string",
97
- "shape": [],
98
- "choices": list(self.choices),
99
- }
161
+ def get_datakey(self, value: AugmentedValue) -> DataKey:
162
+ # Sometimes DBR_TYPE returns as String, must pass choices still
163
+ return _data_key_from_augmented_value(value, choices=list(self.choices.keys()))
164
+
165
+
166
+ @dataclass
167
+ class CaBoolConverter(CaConverter):
168
+ def value(self, value: AugmentedValue) -> bool:
169
+ return bool(value)
170
+
171
+ def get_datakey(self, value: AugmentedValue) -> DataKey:
172
+ return _data_key_from_augmented_value(value, dtype="bool")
100
173
 
101
174
 
102
175
  class DisconnectedCaConverter(CaConverter):
@@ -115,8 +188,10 @@ def make_converter(
115
188
  return CaLongStrConverter()
116
189
  elif is_array and pv_dbr == dbr.DBR_STRING:
117
190
  # Waveform of strings, check we wanted this
118
- if datatype and datatype != Sequence[str]:
119
- raise TypeError(f"{pv} has type [str] not {datatype.__name__}")
191
+ if datatype:
192
+ datatype_dtype = get_dtype(datatype)
193
+ if not datatype_dtype or not np.can_cast(datatype_dtype, np.str_):
194
+ raise TypeError(f"{pv} has type [str] not {datatype.__name__}")
120
195
  return CaArrayConverter(pv_dbr, None)
121
196
  elif is_array:
122
197
  pv_dtype = get_unique({k: v.dtype for k, v in values.items()}, "dtypes")
@@ -136,7 +211,7 @@ def make_converter(
136
211
  )
137
212
  if pv_choices_len != 2:
138
213
  raise TypeError(f"{pv} has {pv_choices_len} choices, can't map to bool")
139
- return CaConverter(dbr.DBR_SHORT, dbr.DBR_SHORT)
214
+ return CaBoolConverter(dbr.DBR_SHORT, dbr.DBR_SHORT)
140
215
  elif pv_dbr == dbr.DBR_ENUM:
141
216
  # This is an Enum
142
217
  pv_choices = get_unique(
@@ -224,7 +299,7 @@ class CaSignalBackend(SignalBackend[T]):
224
299
 
225
300
  async def get_datakey(self, source: str) -> DataKey:
226
301
  value = await self._caget(FORMAT_CTRL)
227
- return self.converter.get_datakey(source, value)
302
+ return self.converter.get_datakey(value)
228
303
 
229
304
  async def get_reading(self) -> Reading:
230
305
  value = await self._caget(FORMAT_TIME)
@@ -4,6 +4,7 @@ import logging
4
4
  import time
5
5
  from dataclasses import dataclass
6
6
  from enum import Enum
7
+ from math import isnan, nan
7
8
  from typing import Any, Dict, List, Optional, Sequence, Type, Union
8
9
 
9
10
  from bluesky.protocols import DataKey, Dtype, Reading
@@ -20,7 +21,7 @@ from ophyd_async.core import (
20
21
  )
21
22
  from ophyd_async.core.utils import DEFAULT_TIMEOUT, NotConnected
22
23
 
23
- from .common import get_supported_values
24
+ from .common import LimitPair, Limits, common_meta, get_supported_values
24
25
 
25
26
  # https://mdavidsaver.github.io/p4p/values.html
26
27
  specifier_to_dtype: Dict[str, Dtype] = {
@@ -39,6 +40,67 @@ specifier_to_dtype: Dict[str, Dtype] = {
39
40
  }
40
41
 
41
42
 
43
+ def _data_key_from_value(
44
+ source: str,
45
+ value: Value,
46
+ *,
47
+ shape: Optional[list[int]] = None,
48
+ choices: Optional[list[str]] = None,
49
+ dtype: Optional[str] = None,
50
+ ) -> DataKey:
51
+ """
52
+ Args:
53
+ value (Value): Description of the the return type of a DB record
54
+ shape: Optional override shape when len(shape) > 1
55
+ choices: Optional list of enum choices to pass as metadata in the datakey
56
+ dtype: Optional override dtype when AugmentedValue is ambiguous, e.g. booleans
57
+
58
+ Returns:
59
+ DataKey: A rich DataKey describing the DB record
60
+ """
61
+ shape = shape or []
62
+ dtype = dtype or specifier_to_dtype[value.type().aspy("value")]
63
+ display_data = getattr(value, "display", None)
64
+
65
+ d = DataKey(
66
+ source=source,
67
+ dtype=dtype,
68
+ shape=shape,
69
+ )
70
+ if display_data is not None:
71
+ for key in common_meta:
72
+ attr = getattr(display_data, key, nan)
73
+ if isinstance(attr, str) or not isnan(attr):
74
+ d[key] = attr
75
+
76
+ if choices is not None:
77
+ d["choices"] = choices
78
+
79
+ if limits := _limits_from_value(value):
80
+ d["limits"] = limits
81
+
82
+ return d
83
+
84
+
85
+ def _limits_from_value(value: Value) -> Limits:
86
+ def get_limits(
87
+ substucture_name: str, low_name: str = "limitLow", high_name: str = "limitHigh"
88
+ ) -> LimitPair:
89
+ substructure = getattr(value, substucture_name, None)
90
+ low = getattr(substructure, low_name, nan)
91
+ high = getattr(substructure, high_name, nan)
92
+ return LimitPair(
93
+ low=None if isnan(low) else low, high=None if isnan(high) else high
94
+ )
95
+
96
+ return Limits(
97
+ alarm=get_limits("valueAlarm", "lowAlarmLimit", "highAlarmLimit"),
98
+ control=get_limits("control"),
99
+ display=get_limits("display"),
100
+ warning=get_limits("valueAlarm", "lowWarningLimit", "highWarningLimit"),
101
+ )
102
+
103
+
42
104
  class PvaConverter:
43
105
  def write_value(self, value):
44
106
  return value
@@ -56,8 +118,7 @@ class PvaConverter:
56
118
  }
57
119
 
58
120
  def get_datakey(self, source: str, value) -> DataKey:
59
- dtype = specifier_to_dtype[value.type().aspy("value")]
60
- return {"source": source, "dtype": dtype, "shape": []}
121
+ return _data_key_from_value(source, value)
61
122
 
62
123
  def metadata_fields(self) -> List[str]:
63
124
  """
@@ -74,7 +135,9 @@ class PvaConverter:
74
135
 
75
136
  class PvaArrayConverter(PvaConverter):
76
137
  def get_datakey(self, source: str, value) -> DataKey:
77
- return {"source": source, "dtype": "array", "shape": [len(value["value"])]}
138
+ return _data_key_from_value(
139
+ source, value, dtype="array", shape=[len(value["value"])]
140
+ )
78
141
 
79
142
 
80
143
  class PvaNDArrayConverter(PvaConverter):
@@ -98,7 +161,7 @@ class PvaNDArrayConverter(PvaConverter):
98
161
 
99
162
  def get_datakey(self, source: str, value) -> DataKey:
100
163
  dims = self._get_dimensions(value)
101
- return {"source": source, "dtype": "array", "shape": dims}
164
+ return _data_key_from_value(source, value, dtype="array", shape=dims)
102
165
 
103
166
  def write_value(self, value):
104
167
  # No clear use-case for writing directly to an NDArray, and some
@@ -109,6 +172,11 @@ class PvaNDArrayConverter(PvaConverter):
109
172
 
110
173
  @dataclass
111
174
  class PvaEnumConverter(PvaConverter):
175
+ """To prevent issues when a signal is restarted and returns with different enum
176
+ values or orders, we put treat an Enum signal as a string, and cache the
177
+ choices on this class.
178
+ """
179
+
112
180
  def __init__(self, choices: dict[str, str]):
113
181
  self.choices = tuple(choices.values())
114
182
 
@@ -122,20 +190,17 @@ class PvaEnumConverter(PvaConverter):
122
190
  return self.choices[value["value"]["index"]]
123
191
 
124
192
  def get_datakey(self, source: str, value) -> DataKey:
125
- return {
126
- "source": source,
127
- "dtype": "string",
128
- "shape": [],
129
- "choices": list(self.choices),
130
- }
193
+ return _data_key_from_value(
194
+ source, value, choices=list(self.choices), dtype="string"
195
+ )
131
196
 
132
197
 
133
- class PvaEnumBoolConverter(PvaConverter):
198
+ class PvaEmumBoolConverter(PvaConverter):
134
199
  def value(self, value):
135
- return value["value"]["index"]
200
+ return bool(value["value"]["index"])
136
201
 
137
202
  def get_datakey(self, source: str, value) -> DataKey:
138
- return {"source": source, "dtype": "integer", "shape": []}
203
+ return _data_key_from_value(source, value, dtype="bool")
139
204
 
140
205
 
141
206
  class PvaTableConverter(PvaConverter):
@@ -144,7 +209,7 @@ class PvaTableConverter(PvaConverter):
144
209
 
145
210
  def get_datakey(self, source: str, value) -> DataKey:
146
211
  # This is wrong, but defer until we know how to actually describe a table
147
- return {"source": source, "dtype": "object", "shape": []} # type: ignore
212
+ return _data_key_from_value(source, value, dtype="object")
148
213
 
149
214
 
150
215
  class PvaDictConverter(PvaConverter):
@@ -213,7 +278,7 @@ def make_converter(datatype: Optional[Type], values: Dict[str, Any]) -> PvaConve
213
278
  )
214
279
  if pv_choices_len != 2:
215
280
  raise TypeError(f"{pv} has {pv_choices_len} choices, can't map to bool")
216
- return PvaEnumBoolConverter()
281
+ return PvaEmumBoolConverter()
217
282
  elif "NTEnum" in typeid:
218
283
  # This is an Enum
219
284
  pv_choices = get_unique(
@@ -1,5 +1,28 @@
1
1
  from enum import Enum
2
- from typing import Dict, Optional, Tuple, Type
2
+ from typing import Dict, Optional, Tuple, Type, TypedDict
3
+
4
+ common_meta = {
5
+ "units",
6
+ "precision",
7
+ }
8
+
9
+
10
+ class LimitPair(TypedDict):
11
+ high: float | None
12
+ low: float | None
13
+
14
+ def __bool__(self) -> bool:
15
+ return self.low is None and self.high is None
16
+
17
+
18
+ class Limits(TypedDict):
19
+ alarm: LimitPair
20
+ control: LimitPair
21
+ display: LimitPair
22
+ warning: LimitPair
23
+
24
+ def __bool__(self) -> bool:
25
+ return any(self.alarm, self.control, self.display, self.warning)
3
26
 
4
27
 
5
28
  def get_supported_values(