Skip to content

Commit

Permalink
committing before my pc explodes
Browse files Browse the repository at this point in the history
  • Loading branch information
rerpha committed Aug 17, 2024
1 parent 11f9385 commit 9fcaf5d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ibex_bluesky_core/devices/dae.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, prefix: str, name: str = "DAE") -> None:
int, f"{dae_prefix}NUMTIMECHANNELS"
)
self.num_spectra: SignalR[int] = epics_signal_r(int, f"{dae_prefix}NUMSPECTRA")

self.period = DaePeriod(dae_prefix)
self.period_num: SignalRW = isis_epics_signal_rw(int, f"{dae_prefix}PERIOD")
self.number_of_periods: SignalRW = isis_epics_signal_rw(int, f"{dae_prefix}NUMPERIODS")
Expand Down
23 changes: 23 additions & 0 deletions src/ibex_bluesky_core/devices/dae_period_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dataclasses import dataclass

from ophyd_async.core import SignalR, StandardReadable
from ophyd_async.epics.signal import epics_signal_r


@dataclass
class DaePeriodSettingsData:

periods_soft_num = None
periods_type = None
periods_src = None
periods_file = None
periods_seq = None
periods_delay = None
periods_settings = []


class DaePeriodSettings(StandardReadable):
def __init__(self, dae_prefix, name=""):


super().__init__(name=name)
31 changes: 31 additions & 0 deletions src/ibex_bluesky_core/devices/dae_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from dataclasses import dataclass

from ophyd_async.core import SignalR, StandardReadable
from ophyd_async.epics.signal import epics_signal_r

@dataclass
class DaeSettingsData:
wiring = None
detector = None
spectra = None
mon_spect = None
mon_from = None
mon_to = None
dae_sync = None
smp_veto = None
ts2_veto = None
hz50_veto = None
ext0_veto = None
ext1_veto = None
ext2_veto = None
ext3_veto = None
fermi_veto = None
fermi_delay = None
fermi_width = None


class DaeSettings(StandardReadable):
def __init__(self, dae_prefix, name=""):


super().__init__(name=name)
16 changes: 16 additions & 0 deletions src/ibex_bluesky_core/devices/dae_tcb_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dataclasses import dataclass

from ophyd_async.core import SignalR, StandardReadable
from ophyd_async.epics.signal import epics_signal_r


@dataclass
class DaeTCBSettingsData:
tcb_file = None
tcb_tables = []
tcb_calculation_method = None


class DaeTCBSettings(StandardReadable):
def __init__(self, dae_prefix, name=""):
super().__init__(name=name)
13 changes: 13 additions & 0 deletions src/ibex_bluesky_core/utils/dehex_and_decompress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import zlib
import binascii


def dehex_and_decompress(value: bytes) -> bytes:
"""Decompresses the inputted string, assuming it is in hex encoding.
Args:
value: The string to be decompressed, encoded in hex
Returns A decompressed version of the inputted string
"""
return zlib.decompress(binascii.unhexlify(value))
9 changes: 9 additions & 0 deletions tests/devices/test_dehex_and_decompress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from ibex_bluesky_core.utils.dehex_and_decompress import dehex_and_decompress


def test_can_dehex_and_decompress():
expected = b"test123"
hexed_and_compressed = b"789c2b492d2e31343206000aca0257"
result = dehex_and_decompress(hexed_and_compressed)
assert result == expected

0 comments on commit 9fcaf5d

Please sign in to comment.