Skip to content

Commit

Permalink
Merge pull request #13 from Relm-Arrowny/12-create-ophy-device-for-pi…
Browse files Browse the repository at this point in the history
…mte-area-detector

12 create ophy device for pimte area detector
  • Loading branch information
Relm-Arrowny authored Apr 10, 2024
2 parents 0a27334 + c0eeccd commit 59301eb
Show file tree
Hide file tree
Showing 35 changed files with 3,577 additions and 32 deletions.
14 changes: 0 additions & 14 deletions .copier-answers.yml

This file was deleted.

13 changes: 7 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters"
]
"ryanluker.vscode-coverage-gutters",
"mms-python.mypy-type-checker"
],
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
}
}
},
// Make sure the files we are mapping into the container exist on the host
Expand All @@ -51,4 +52,4 @@
"workspaceFolder": "${localWorkspaceFolder}",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install -e '.[dev]'"
}
}
2 changes: 1 addition & 1 deletion .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
required: true
python_version:
description: Python version to install
default: "3.x"
default: "3.11"

runs:
using: composite
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.9", "3.10"]
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
- os: "ubuntu-latest"
python: "3.7"
python: "3.11"
install: ".[dev]"

runs-on: ${{ matrix.os }}
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ coverage.xml
cov.xml
.pytest_cache/
.mypy_cache/
.ipynb_checkpoints
i10-pimte*

# Translations
*.mo
Expand All @@ -69,3 +71,7 @@ lockfiles/

# ruff cache
.ruff_cache/


#copyer stuff
.copier-answers.yml
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"source.organizeImports.ruff": "explicit"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Accepted
Context
-------

We should use the following `pip-skeleton`_.
We should use the following `pip-skeleton <https://github.com/Relm-Arrowny/i10-bluesky>`_.
The skeleton will ensure consistency in developer
environments and package management.

Expand Down
4 changes: 2 additions & 2 deletions docs/user/how-to/run-container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Run in a container
==================

Pre-built containers with i10-bluesky and its dependencies already
installed are available on `Github Container Registry
installed are available on Github Container Registry

Starting the container
----------------------

To pull the container from github container registry and run::

$ docker run ghcr.io/DiamondLightSource/i22-bluesky:main --version
$ docker run ghcr.io/DiamondLightSource/i10-bluesky:main --version

To get a released version, use a numbered release instead of ``main``.
48 changes: 43 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,34 @@ name = "i10-bluesky"
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
description = ""
dependencies = [
"typing-extensions;python_version<'3.8'",

"pyqt5",
"setuptools",
"networkx>=2.0",
"numpy",
"packaging",
"pint",
"event-model",
"p4p",
"pyyaml",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
#version = "0.0.1" #need to make this non manual but dynamic version currently include local version seed and it not the statand for release.
license.file = "LICENSE"
readme = "README.rst"
requires-python = ">=3.7"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
"bluesky",
"ophyd-async",
"black",
"mypy",
"pipdeptree",
Expand All @@ -37,7 +48,32 @@ dev = [
"sphinx-design",
"tox-direct",
"types-mock",
"copier",
#"ophyd_async[pva]",
#"ophyd_async[ca]",
"flake8",
"flake8-isort",
"Flake8-pyproject",
"h5py",
"inflection",
"ipython",
"ipywidgets",
"matplotlib",
"myst-parser",
"numpydoc",
"ophyd",
"pickleshare",
"pyepics>=3.4.2",
"pyside6",
"pytest-asyncio",
"pytest-faulthandler",
"pytest-rerunfailures",
"pytest-timeout",
"types-pyyaml",
"jupyter",
"softioc",
"cothread",
"dls-dodal@git+https://github.com/DiamondLightSource/dodal.git",

]

[project.scripts]
Expand Down Expand Up @@ -67,6 +103,8 @@ filterwarnings = "error"
# Doctest python code in docs, python code in src docstrings, test functions in tests
testpaths = "docs src tests"

asyncio_mode = "auto"

[tool.coverage.run]
data_file = "/tmp/i10_bluesky.coverage"

Expand Down Expand Up @@ -102,7 +140,7 @@ commands =
[tool.ruff]
src = ["src", "tests"]
line-length = 88
select = [
lint.select = [
"C4", # flake8-comprehensions - https://beta.ruff.rs/docs/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://beta.ruff.rs/docs/rules/#error-e
"F", # pyflakes rules - https://beta.ruff.rs/docs/rules/#pyflakes-f
Expand Down
Empty file.
45 changes: 45 additions & 0 deletions src/i10_bluesky/devices/pimteAD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from typing import Sequence

from bluesky.protocols import Hints
from ophyd_async.core import DirectoryProvider, SignalR, StandardDetector
from ophyd_async.epics.areadetector.drivers import ADBaseShapeProvider
from ophyd_async.epics.areadetector.writers import HDFWriter, NDFileHDF, NDPluginStats

from i10_bluesky.epics.drivers.pimte1_driver import Pimte1Driver
from i10_bluesky.epics.pimte_controller import PimteController


class HDFStatsPimte(StandardDetector):
_controller: PimteController
_writer: HDFWriter

def __init__(
self,
prefix: str,
directory_provider: DirectoryProvider,
name: str,
config_sigs: Sequence[SignalR] = (),
**scalar_sigs: str,
):
self.drv = Pimte1Driver(prefix + "CAM:")
self.hdf = NDFileHDF(prefix + "HDF5:")
self.stats = NDPluginStats(prefix + "STAT:")
# taken from i22 but this does nothing atm

super().__init__(
PimteController(self.drv),
HDFWriter(
self.hdf,
directory_provider,
lambda: self.name,
ADBaseShapeProvider(self.drv),
sum="StatsTotal",
**scalar_sigs,
),
config_sigs=config_sigs,
name=name,
)

@property
def hints(self) -> Hints:
return self._writer.hints
Empty file.
10 changes: 10 additions & 0 deletions src/i10_bluesky/devices/rasor/detectorSlits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ophyd_async.core import Device
from ophyd_async.epics.motion.motor import Motor


class DetectorSlits(Device):

def __init__(self, prefix: str, name="") -> None:
self.dsu = Motor(prefix + "-01:TRANS")
self.dsd = Motor(prefix + "-02:TRANS")
super().__init__(name=name)
23 changes: 23 additions & 0 deletions src/i10_bluesky/devices/rasor/i10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dodal.beamlines.beamline_utils import device_instantiation, get_directory_provider
from dodal.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import get_beamline_name

from i10_bluesky.devices.pimteAD import HDFStatsPimte

BL = get_beamline_name("BL10I")
set_log_beamline(BL)
set_utils_beamline(BL)


def pimte(
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
) -> HDFStatsPimte:
return device_instantiation(
HDFStatsPimte,
"pimte",
"-EA-PILAT-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
)
22 changes: 22 additions & 0 deletions src/i10_bluesky/devices/scalerCard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from ophyd import Component, Device, EpicsSignal


class ScaleCard(Device):
for i in range(1, 2):
macr17 = Component(EpicsSignal, ":SCALER1.S' + str(i) + '")


"""
class Scaler(StandardReadable):
#basic slits class
def __init__(self, prefix: str, suffix: str, name:str ="") -> None:
# Define some signals
self.value = epics_signal_r(float, prefix + suffix)
# Set name and signals for read() and read_configuration()
self.set_readable_signals(
read=[self.value],
#config=[self.mode],
)
super().__init__(name=name)
"""
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions src/i10_bluesky/epics/drivers/pimte1_driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from enum import Enum

from ophyd_async.epics.areadetector.drivers.ad_base import ADBase
from ophyd_async.epics.areadetector.utils import ad_r, ad_rw
from ophyd_async.epics.signal import epics_signal_rw


class Pimte1Driver(ADBase):
def __init__(self, prefix: str) -> None:
self.trigger_mode = ad_rw(Pimte1Driver.TriggerMode, prefix + "TriggerMode")
self.initialize = ad_rw(int, prefix + "Initialize")
self.set_temperture = epics_signal_rw(float, prefix + "SetTemperature")
self.read_backtemperture = ad_r(float, prefix + "MeasuredTemperature")
self.speed = ad_rw(Pimte1Driver.SpeedMode, prefix + "SpeedSelection")
super().__init__(prefix)

class SpeedMode(str, Enum):
adc_50Khz = "0: 50 KHz - 20000 ns"
adc_100Khz = "1: 100 kHz - 10000 ns"
adc_200Khz = "2: 200 kHz - 5000 ns"
adc_500Khz = "3: 500 kHz - 2000 ns"
adc_1Mhz = "4: 1 MHz - 1000 ns"
adc_2Mhz = "5: 2 MHz - 500 ns"

class TriggerMode(str, Enum):
internal = "Free Run"
ext_trigger = "Ext Trigger"
bulb_mode = "Bulb Mode"
Loading

0 comments on commit 59301eb

Please sign in to comment.