Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects

Draft: NIDAQ Ophyd runner for X01DA

Open wakonig_k requested to merge revert-0767eb51 into main
9 unresolved threads

This reverts commit 0767eb51

@acerbo_a

Merge request reports

Merge request pipeline #21739 failed

Merge request pipeline failed for 55865d3f

Requires 1 approval from eligible users.
Merge blocked: 5 checks failed
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 """
2 Ophyd device classes for beamline X01DA "Debye"
3 """
4
5 print(f"Loading {__file__}...")
  • wakonig_k
  • 47
    48
    49 def kickoff(self):
    50 """
    51 Start the flyer
    52 """
    53 def callback(*, old_value, value, **kwargs):
    54 return (old_value == 1 and value == 0)
    55
    56 self._status = SubscriptionStatus(self.acquire, callback)
    57
    58 print(f"{time.asctime()}: scan started ...")
    59
    60 self._start_time = time.time()
    61 self.acquire.put(1)
    62 self._status.wait()
  • wakonig_k
  • 60 self._start_time = time.time()
    61 self.acquire.put(1)
    62 self._status.wait()
    63
    64 return self._status
    65
    66
    67 def complete(self):
    68 """
    69 Wait for the flyer to complete
    70 """
    71 def callback(value, old_value, **kwargs):
    72 return (old_value == 3 and value == 2)
    73
    74 self._status = SubscriptionStatus(self.nidaq_state, callback)
    75 self._status.wait()
  • wakonig_k
  • 78
    79
    80 def collect(self):
    81 """
    82 Retrieve data from the flyer
    83 """
    84 # data = {"time": self._start_time, "data": {}, "timestamps": {}}
    85 # for attr in ("rate_act", "rate_req"):
    86 # obj = getattr(self, attr)
    87 # data["data"][obj.name] = obj.get()
    88 # data["timestamps"][obj.name] = obj.timestamp
    89 #
    90 # print(data)
    91 # return data
    92
    93 return 0
  • wakonig_k
  • 93 return 0
    94
    95
    96 def describe_collect(self):
    97 """
    98 Schema and meta-data for collect()
    99 """
    100 # desc = OrderedDict()
    101 # for attr in ("rate_act", "rate_req"):
    102 # desc.update(getattr(self, attr).describe())
    103
    104 ret = {'dtype': 'number',
    105 'shape': [],
    106 'source': 'SCANSERVER'}
    107
    108 return {self.name: ret}
  • wakonig_k
  • 96 def describe_collect(self):
    97 """
    98 Schema and meta-data for collect()
    99 """
    100 # desc = OrderedDict()
    101 # for attr in ("rate_act", "rate_req"):
    102 # desc.update(getattr(self, attr).describe())
    103
    104 ret = {'dtype': 'number',
    105 'shape': [],
    106 'source': 'SCANSERVER'}
    107
    108 return {self.name: ret}
    109
    110
    111 def daq_flyer_RE(flyer, *, md=None):
  • wakonig_k
  • 124 def daq_flyer_simple(flyer, *, md=None):
    125 _md = {}
    126 _md.update(md or {})
    127 def single_scan(flyer):
    128 flyer.configure()
    129 flyer.kickoff()
    130 flyer.complete()
    131 flyer.describe_collect()
    132 flyer.collect()
    133
    134 return single_scan(flyer)
    135
    136
    137 flyer = NIDAQ_flyer("X01DA-PC-SCANSERVER:NIDAQ-", name="test")
    138
    139 RE = RunEngine()
  • wakonig_k
  • 5 print(f"Loading {__file__}...")
    6
    7 import time
    8 from datetime import datetime
    9
    10 from collections import OrderedDict
    11
    12 from ophyd import Kind, Device, DeviceStatus, EpicsSignal, EpicsSignalRO
    13 from ophyd.flyers import FlyerInterface
    14 from ophyd import Component as Cpt
    15 from ophyd.status import SubscriptionStatus
    16 import bluesky.plan_stubs as bps
    17 import bluesky.preprocessors as bpp
    18
    19 from bluesky import RunEngine
    20 from bluesky.callbacks.best_effort import BestEffortCallback
  • in particular, please have a look at point 3 and 4 (formatter and linter)

  • wakonig_k requested review from @acerbo_a and @appel_c

    requested review from @acerbo_a and @appel_c

  • appel_c
    appel_c @appel_c started a thread on the diff
  • 57
    58 print(f"{time.asctime()}: scan started ...")
    59
    60 self._start_time = time.time()
    61 self.acquire.put(1)
    62 self._status.wait()
    63
    64 return self._status
    65
    66
    67 def complete(self):
    68 """
    69 Wait for the flyer to complete
    70 """
    71 def callback(value, old_value, **kwargs):
    72 return (old_value == 3 and value == 2)
    • Maintainer

      I would recommend using here a little helper class to clearly indicate the different states of the NIDAQ. Comparing against 2 or 3 are not really informative. e.g

      class NIDAQState(enum.IntEnum): STOPPED = 0 BUSY = 1 READY = 2 ACQUIRING = 3

      Later this can then be access as return ( old_value == NIDAQState.ACQUIRING and value == NIDAQState.READY)

      Edited by appel_c
    • Please register or sign in to reply
  • wakonig_k changed target branch from master to main

    changed target branch from master to main

  • Please register or sign in to reply
    Loading