aps-8id-dys / ipython-8idiuser

8-ID-I ipython configuration for bluesky (and other)
1 stars 1 forks source link

support new ADRigaku #251

Closed prjemian closed 3 years ago

prjemian commented 3 years ago

2021-02-02 ADRigaku

Needs ophyd classes for RigakuDetectorCam & RigakuDetector

See the above screen:

snow% cd $RIGAKUIOC/
/xorApps/epics/synApps_6_1/ioc/8idRigaku/iocBoot/ioc8idRigaku/softioc
snow% ./8idRigaku.sh caqtdm
prjemian commented 3 years ago

reference:

prjemian commented 3 years ago

tests with adrigaku.cam.summary() and adrigaku.cam.describe_configuration():

```python In [1]: from instrument.devices.ad_rigaku_detector import adrigaku In [2]: adrigaku.cam.summary() data keys (* hints) ------------------- read attrs ---------- config keys ----------- adrigaku_cam_acquire_period adrigaku_cam_acquire_time adrigaku_cam_image_mode adrigaku_cam_manufacturer adrigaku_cam_model adrigaku_cam_num_exposures adrigaku_cam_num_images adrigaku_cam_trigger_mode configuration attrs ------------------- acquire_period EpicsSignalWithRBV ('adrigaku_cam_acquire_period') acquire_time EpicsSignalWithRBV ('adrigaku_cam_acquire_time') image_mode EpicsSignalWithRBV ('adrigaku_cam_image_mode') manufacturer EpicsSignalRO ('adrigaku_cam_manufacturer') model EpicsSignalRO ('adrigaku_cam_model') num_exposures EpicsSignalWithRBV ('adrigaku_cam_num_exposures') num_images EpicsSignalWithRBV ('adrigaku_cam_num_images') trigger_mode EpicsSignalWithRBV ('adrigaku_cam_trigger_mode') unused attrs ------------ configuration_names ArrayAttributeSignal('adrigaku_cam_configuration_names') array_counter EpicsSignalWithRBV ('adrigaku_cam_array_counter') array_rate EpicsSignalRO ('adrigaku_cam_array_rate') asyn_io EpicsSignal ('adrigaku_cam_asyn_io') nd_attributes_file EpicsSignal ('adrigaku_cam_nd_attributes_file') pool_alloc_buffers EpicsSignalRO ('adrigaku_cam_pool_alloc_buffers') pool_free_buffers EpicsSignalRO ('adrigaku_cam_pool_free_buffers') pool_max_mem EpicsSignalRO ('adrigaku_cam_pool_max_mem') pool_used_buffers EpicsSignalRO ('adrigaku_cam_pool_used_buffers') pool_used_mem EpicsSignalRO ('adrigaku_cam_pool_used_mem') port_name EpicsSignalRO ('adrigaku_cam_port_name') acquire EpicsSignalWithRBV ('adrigaku_cam_acquire') array_callbacks EpicsSignalWithRBV ('adrigaku_cam_array_callbacks') array_size ArraySize ('adrigaku_cam_array_size') array_size_bytes EpicsSignalRO ('adrigaku_cam_array_size_bytes') bin_x EpicsSignalWithRBV ('adrigaku_cam_bin_x') bin_y EpicsSignalWithRBV ('adrigaku_cam_bin_y') color_mode EpicsSignalWithRBV ('adrigaku_cam_color_mode') data_type EpicsSignalWithRBV ('adrigaku_cam_data_type') detector_state EpicsSignalRO ('adrigaku_cam_detector_state') frame_type EpicsSignalWithRBV ('adrigaku_cam_frame_type') gain EpicsSignalWithRBV ('adrigaku_cam_gain') max_size MaxSize ('adrigaku_cam_max_size') min_x EpicsSignalWithRBV ('adrigaku_cam_min_x') min_y EpicsSignalWithRBV ('adrigaku_cam_min_y') num_exposures_counter EpicsSignalRO ('adrigaku_cam_num_exposures_counter') num_images_counter EpicsSignalRO ('adrigaku_cam_num_images_counter') read_status EpicsSignal ('adrigaku_cam_read_status') reverse Reverse ('adrigaku_cam_reverse') shutter_close_delay EpicsSignalWithRBV ('adrigaku_cam_shutter_close_delay') shutter_close_epics EpicsSignal ('adrigaku_cam_shutter_close_epics') shutter_control EpicsSignalWithRBV ('adrigaku_cam_shutter_control') shutter_control_epics EpicsSignal ('adrigaku_cam_shutter_control_epics') shutter_fanout EpicsSignal ('adrigaku_cam_shutter_fanout') shutter_mode EpicsSignalWithRBV ('adrigaku_cam_shutter_mode') shutter_open_delay EpicsSignalWithRBV ('adrigaku_cam_shutter_open_delay') shutter_open_epics EpicsSignal ('adrigaku_cam_shutter_open_epics') shutter_status_epics EpicsSignalRO ('adrigaku_cam_shutter_status_epics') shutter_status EpicsSignalRO ('adrigaku_cam_shutter_status') size Size ('adrigaku_cam_size') status_message EpicsSignalRO ('adrigaku_cam_status_message') string_from_server EpicsSignalRO ('adrigaku_cam_string_from_server') string_to_server EpicsSignalRO ('adrigaku_cam_string_to_server') temperature EpicsSignalWithRBV ('adrigaku_cam_temperature') temperature_actual EpicsSignal ('adrigaku_cam_temperature_actual') time_remaining EpicsSignalRO ('adrigaku_cam_time_remaining') acquisition_delay EpicsSignalWithRBV ('adrigaku_cam_acquisition_delay') calibration_label EpicsSignalWithRBV ('adrigaku_cam_calibration_label') exposure_delay EpicsSignalWithRBV ('adrigaku_cam_exposure_delay') file_name EpicsSignalWithRBV ('adrigaku_cam_file_name') file_path EpicsSignalWithRBV ('adrigaku_cam_file_path') lower_threshold EpicsSignalWithRBV ('adrigaku_cam_lower_threshold') upper_threshold EpicsSignalWithRBV ('adrigaku_cam_upper_threshold') In [3]: adrigaku.cam.describe() Out[3]: OrderedDict() In [4]: adrigaku.cam.describe_configuration() Out[4]: OrderedDict([('adrigaku_cam_acquire_period', {'source': 'PV:8idRigaku:cam1:AcquirePeriod_RBV', 'dtype': 'number', 'shape': [], 'units': '', 'lower_ctrl_limit': 0.0, 'upper_ctrl_limit': 0.0, 'precision': 3}), ('adrigaku_cam_acquire_time', {'source': 'PV:8idRigaku:cam1:AcquireTime_RBV', 'dtype': 'number', 'shape': [], 'units': '', 'lower_ctrl_limit': 0.0, 'upper_ctrl_limit': 0.0, 'precision': 6}), ('adrigaku_cam_image_mode', {'source': 'PV:8idRigaku:cam1:ImageMode_RBV', 'dtype': 'integer', 'shape': [], 'units': None, 'lower_ctrl_limit': None, 'upper_ctrl_limit': None, 'enum_strs': ('32 Bit Single', '16 Bit x 2', '16 Bit, Zero-Deadtime', '8 Bit, Zero-Deadtime', '4 Bit, Zero-Deadtime', '2 Bit, Zero-Deadtime', '8 Bit, 2S', '4 Bit, 2S', '2 Bit, 2S', '16 Bit, 1S', '8 Bit, 1S', '4 Bit, 1S', '2 Bit, 1S', '2 Bit, Burst Mode', '1 Bit, Burst Mode')}), ('adrigaku_cam_manufacturer', {'source': 'PV:8idRigaku:cam1:Manufacturer_RBV', 'dtype': 'string', 'shape': [], 'units': None, 'lower_ctrl_limit': None, 'upper_ctrl_limit': None}), ('adrigaku_cam_model', {'source': 'PV:8idRigaku:cam1:Model_RBV', 'dtype': 'string', 'shape': [], 'units': None, 'lower_ctrl_limit': None, 'upper_ctrl_limit': None}), ('adrigaku_cam_num_exposures', {'source': 'PV:8idRigaku:cam1:NumExposures_RBV', 'dtype': 'integer', 'shape': [], 'units': '', 'lower_ctrl_limit': 0, 'upper_ctrl_limit': 0}), ('adrigaku_cam_num_images', {'source': 'PV:8idRigaku:cam1:NumImages_RBV', 'dtype': 'integer', 'shape': [], 'units': '', 'lower_ctrl_limit': 0, 'upper_ctrl_limit': 0}), ('adrigaku_cam_trigger_mode', {'source': 'PV:8idRigaku:cam1:TriggerMode_RBV', 'dtype': 'integer', 'shape': [], 'units': None, 'lower_ctrl_limit': None, 'upper_ctrl_limit': None, 'enum_strs': ('Fixed Time', 'Continuous Exposure', 'Start with Trigger', 'Gated Trigger', 'ZDT Fixed Time', 'ZDT Continuous', 'ZDT Trigger Start', 'Fixed Time Trigger Start', 'ZDT Fixed Trigger Start', 'Burst Mode', 'Burst Mode Trigger Start', 'Burst Mode Gated Trigger', 'Trigger Sync', 'Pileup Trigger Start', 'Pileup Gated Trigger', 'Pileup Trigger Sync')})]) In [5]: ```

Also, match fields on the screen above:

In [5]: adrigaku.cam.file_path.get()
Out[5]: 'RigakuEpics/'

In [6]: adrigaku.cam.file_name.get()
Out[6]: 'Test_01_000010.bin'

In [7]: adrigaku.cam.image_mode.get()
Out[7]: 5

In [8]: adrigaku.cam.image_mode.get(as_string=True)
Out[8]: '2 Bit, Zero-Deadtime'

In [9]: adrigaku.cam.trigger_mode.get()
Out[9]: 4

In [10]: adrigaku.cam.trigger_mode.get(as_string=True)
Out[10]: 'ZDT Fixed Time'

In [11]: adrigaku.cam.upper_threshold.get()
Out[11]: 10.0

In [12]: adrigaku.cam.lower_threshold.get()
Out[12]: 6.0

In [13]: adrigaku.cam.calibration_label.get()
Out[13]: 'STD'
prjemian commented 3 years ago

What can ophyd tell us about the detector's asyn ports?

In [16]: adrigaku.get_asyn_port_dictionary()
Out[16]: {'TEST': RigakuUfxcDetectorCam(prefix='8idRigaku:cam1:', name='adrigaku_cam', parent='adrigaku', read_attrs=[], configuration_attrs=['acquire_period', 'acquire_time', 'image_mode', 'manufacturer', 'model', 'num_exposures', 'num_images', 'trigger_mode'])}

In [17]: adrigaku.get_asyn_digraph()
Out[17]:
(<networkx.classes.digraph.DiGraph at 0x7f835a3b9e20>,
 {'TEST': RigakuUfxcDetectorCam(prefix='8idRigaku:cam1:', name='adrigaku_cam', parent='adrigaku', read_attrs=[], configuration_attrs=['acquire_period', 'acquire_time', 'image_mode', 'manufacturer', 'model', 'num_exposures', 'num_images', 'trigger_mode'])})

In [18]: adrigaku.visualize_asyn_digraph()

digraph

TEST is the asyn port of the cam plugin. So far, it is not seeing the other ports in use (Sparse0 plugin and IMM plugin)

prjemian commented 3 years ago

Once ADRigaku is moved to the Area Detector repository, we can push this support to ophyd. Until then, it is support specific to the APS.

prjemian commented 3 years ago

Tested by counting using Bluesky standard count() plan; it worked the first time! (Well, after we removed the suspenders.)

adrigaku

@keenanlang: Thanks!

qzhang234 commented 3 years ago

@prjemian Attached please find portions of ad_rigaku_detector.py I wrote. How do I run the staging to see if the PVs have been implemented ccorrectly?

In addition, I have a few questions:

Thanks!

Screen Shot 2021-03-02 at 10 59 48 PM
Staging command in ad_rigaku_detector
``` class RigakuUfxcDetector(DetectorBase): _html_docs = ["RigakuUfxcDoc.html"] cam = ADCpt(RigakuUfxcDetectorCam, "cam1:") # TODO: other plugins: Sparse0, IMM def staging_setup_DM(self, *args, mode=None): """ setup the detector's stage_sigs for acquisition with the DM workflow from DM_DeviceMixinAreaDetector """ if (mode == 'fast'): yield from bps.mv(self.cam.acquire_time, 20e-6) yield from bps.mv(self.image_mode, 5) yield from bps.mv(self.cam.trigger_mode, 4) yield from bps.mv(self.cam.num_images, 100000) ## Need the equivalent of the lines below: ## epics_put("8idRigaku:cam1:Corrections","Enabled") ## epics_put("8idRigaku:cam1:DataType","UInt32") elif (mode == 'slow'): yield from bps.mv(self.cam.image_mode, "16 Bit, 1S") yield from bps.mv(self.cam.image_mode, "Fixed Time") yield from bps.mv(self.cam.acquire_time, 0.1) yield from bps.mv(self.cam.num_images, 10) ## Need the equivalent of the lines below: # epics_put("8idRigaku:cam1:DataType","UInt16") # epics_put("8idRigaku:cam1:Corrections","Disabled") # epics_put("8idRigaku:IMM1:AutoIncrement", "Yes") # epics_put("8idRigaku:IMM1:NumCapture",10) # epics_put("8idRigaku:IMM1:FileNumber",1) # epics_put("8idRigaku:IMM1:FilePath","/Rigaku/bin/destination/RigakuEpics/"); # epics_put("8idRigaku:IMM1:FileName","test"); self.batch_name.put(self._file_name) ```
prjemian commented 3 years ago

To check the staging of ophyd Device ad_rigaku:

  1. open the GUI screen(s) that observe the PV(s) to be staged
  2. in bluesky: ad_rigaku.stage()
  3. check the GUI screens for correct values
  4. in bluesky: ad_rigaku.unstage()
  5. check the GUI screens have reverted to previous (unstaged) values

The basic staging rules are:

qzhang234 commented 3 years ago

I just tried adrigaku.stage() and the PVs in the EPICS window did not change. Upon inspection, I noticed that I used lots of yield from bps.mv when adrigaku.stage() is called without the Run Engine. Is that what has caused problems?

Also what should I do if I want to add a if command durinng the staging to toggle between fast and slow mode? Or do you think it's better to stage both fast and slow mode and make the selection in AD_Acquire?

Thanks

prjemian commented 3 years ago

That's for sure the problem. Fundamentally, staging works by ophyd processing the .stage_sigs dictionary.

In [10]: adrigaku.stage_sigs
Out[10]: OrderedDict()

In [11]: adrigaku.cam.stage_sigs
Out[11]: OrderedDict()

Both dictionaries are empty right now. That's why nothing changed.

additional suggestions coming...

prjemian commented 3 years ago

Your code to set staging for either fast or slow should not be written as a bluesky plan. Rather, it should be modifying the adrigaku.stage_sigs dictionary.

In this class: https://github.com/aps-8id-dys/ipython-8idiuser/blob/2d679d1d2a4882ebb6fec6d5b2c4985eb89bc5b7/profile_bluesky/startup/instrument/devices/ad_rigaku_detector.py#L47-L50

change to this:

class RigakuUfxcDetector(DetectorBase):
    _html_docs = ["RigakuUfxcDoc.html"]
    cam = ADCpt(RigakuUfxcDetectorCam, "cam1:")
    # TODO: other plugins: Sparse0, IMM

    staging_mode = ADCpt(Signal, value="fast", kind="config")

    def staging_setup_DM(self, *args, mode=None):

        """
        setup the detector's stage_sigs for acquisition with the DM workflow
        from DM_DeviceMixinAreaDetector
        """

        # If staging stalls, it is because one or more of the signals
        # is being set by its string value instead of the enumeration
        # number.  This happens with EpicsSignalWithRBV when it was 
        # called without the string=True kwarg.
        #     In [13]: adrigaku.cam.image_mode.get()
        #     Out[13]: 9

        #     In [14]: adrigaku.cam.image_mode.get(as_string=True)
        #     Out[14]: '16 Bit, 1S'
        # The fix is to set by number, not string.
        if (mode == 'fast'):
            self.stage_sigs = {}
            self.stage_sigs["cam.acquire_time"] = 20e-6
            self.stage_sigs["cam.image_mode"] = 5
            self.stage_sigs["cam.trigger_mode"] = 4
            self.stage_sigs["cam.num_images"] = 100_000   # "_" is a visual separator
            self.stage_sigs["cam.corrections"] = "Enabled"
            self.stage_sigs["cam.data_type"] = "UInt32"
            # TODO: what else is needed?

        elif (mode == 'slow'):            self.stage_sigs = {}
            self.stage_sigs["cam.image_mode"] = 9  # "16 Bit, 1S"
            self.stage_sigs["cam.trigger_mode"] = 0  # "Fixed Time"
            self.stage_sigs["cam.acquire_time"] = 0.1
            self.stage_sigs["cam.num_images"] = 10
            self.stage_sigs["cam.data_type"] = "UInt16"
            self.stage_sigs["cam.corrections"] = "Disabled"
            # TODO: what else is needed?

            # TODO: Need the equivalent of the lines below:

            # epics_put("8idRigaku:IMM1:AutoIncrement", "Yes")
            # epics_put("8idRigaku:IMM1:NumCapture",10) 
            # epics_put("8idRigaku:IMM1:FileNumber",1)
            # epics_put("8idRigaku:IMM1:FilePath","/Rigaku/bin/destination/RigakuEpics/");
            # epics_put("8idRigaku:IMM1:FileName","test");            

        self.batch_name.put(self._file_name)
prjemian commented 3 years ago

Also, add this line to class RigakuUfxcDetectorCam(CamBase): (after upper_threshold line):

    corrections = ADCpt(EpicsSignal, "Corrections", kind="config", string=True)  # has no _RBV PV
prjemian commented 3 years ago

We can probably copy the IMM plugin parts from lambda_750k.py.

prjemian commented 3 years ago

BUT, rather than duplicate code, why don't I work this up on a branch and send a PR for you?

prjemian commented 3 years ago

Part of that branch should be to pull out the IMM plugin support to a separate file so any of your detectors can use it.

Also need a good base class for the additional code we need to support AD_Acquire().

prjemian commented 3 years ago

@qzhang234 : Where is the source code for the Sparse plugin? Or the source code of a screen file? I'm looking for the specific PVs to make an ophyd interface.

qzhang234 commented 3 years ago

@prjemian I believe Keenan knows the location for the imm plugin source code. He was the one who built it

prjemian commented 3 years ago

Not imm, sparse

On Wed, Mar 3, 2021, 5:18 PM Qingteng Zhang notifications@github.com wrote:

@prjemian https://github.com/prjemian I believe Keenan knows the location for the imm plugin source code. He was the one who built it

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aps-8id-dys/ipython-8idiuser/issues/251#issuecomment-790143212, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMCVUEX5HZNXFORNRJLTB27S5ANCNFSM4W7GGPJA .

qzhang234 commented 3 years ago

Sorry for the late reply. The sparse data (Rigaku-defined binary) was saved directly from detector to network drive and there is no plugin. Plugin is only used when running slow mode and saving into imm.

prjemian commented 3 years ago

So is there anything to do for the sparse "plugin"?

On Wed, Mar 3, 2021, 7:39 PM Qingteng Zhang notifications@github.com wrote:

Sorry for the late reply. The sparse data (Rigaku-defined binary) was saved directly from detector to network drive and there is no plugin. Plugin is only used when running slow mode and saving into imm.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aps-8id-dys/ipython-8idiuser/issues/251#issuecomment-790216195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMBFETSSP2SIOREXWSDTB3QG5ANCNFSM4W7GGPJA .

qzhang234 commented 3 years ago

I don't believe so.

Yeah that part could be confusing. I think Rigaku is probably one of the few area detectors that do that. The sparsification was done on the Rigaku server using their own code

keenanlang commented 3 years ago

@prjemian

Where is the source code for the Sparse plugin?

For the Rigaku detector, the source code is local to the server computer. There is an installed version also in /net/s8iddserv/xorApps/epics/synApps_6_1/support for the LAMBDA detectors. And I've just uploaded the source to a github repo: https://github.com/BCDA-APS/IMMPlugin

Not imm, sparse

Though implemented as separate plugins, the Sparse and the IMM plugins are both part of the same system. '

@qzhang234

The sparse data (Rigaku-defined binary) was saved directly from detector to network drive and there is no plugin. Plugin is only used when running slow mode and saving into imm.

Are you no longer using the Sparse plugin with the Rigaku slow mode? I know in testing we stopped using Scatter/Gather to try to run multiple instances of the sparse plugin, but I didn't think you got rid of sparsifying the slow data entirely.

The Sparse plugin is different from the sparsification that is done by the zero-deadtime mode. The plugin pipeline should be Rigaku -> Sparse0 -> IMM, The sparse plugin compresses the frame and then the IMM plugin writes out the compressed data. The old IMM plugin did all of this in one plugin, but I split up the two functions into separate plugins when I rewrote the code.

qzhang234 commented 3 years ago

Oh sorry @prjemian, @keenanlang is right about the sparse plugin in the slow mode. For the fast mode the Rigaku data is indeed sparsified without EPICS plugin though

prjemian commented 3 years ago

Thanks. I'll look through the new repository.

On Wed, Mar 3, 2021, 10:11 PM Qingteng Zhang notifications@github.com wrote:

Oh sorry @prjemian https://github.com/prjemian, @keenanlang https://github.com/keenanlang is right about the sparse plugin in the slow mode. For the fast mode the Rigaku data is indeed sparsified without EPICS plugin though

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aps-8id-dys/ipython-8idiuser/issues/251#issuecomment-790275183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMBYSL56XMEFSCKPTVTTB4CALANCNFSM4W7GGPJA .

qzhang234 commented 3 years ago

@prjemian The new code worked! Attached is the code. I did have to import Signal from Opyhd but not a big deal.

Per your suggestion, I can't stage the detector twice so I've been using this sequence (see screenshot attached):

Screen Shot 2021-03-03 at 11 38 56 PM
ad_rigaku_detector.py ``` """ ADRigaku UFXC area detector (EPICS) * detector name: -tba- * detector number: -tba- see: https://github.com/aps-8id-dys/ipython-8idiuser/issues/251 """ __all__ = [ "adrigaku", ] from bluesky import plans as bp from bluesky import plan_stubs as bps from instrument.session_logs import logger from ophyd import ADComponent as ADCpt from ophyd import EpicsSignal, Signal from ophyd import EpicsSignalRO from ophyd import EpicsSignalWithRBV from ophyd.areadetector import CamBase from ophyd.areadetector import DetectorBase logger.info(__file__) IOC_PREFIX = "8idRigaku:" class RigakuUfxcDetectorCam(CamBase): """ Customization for the additional fields of the ADRigaku detector. see: https://github.com/BCDA-APS/ADRigaku """ acquisition_delay = ADCpt(EpicsSignalWithRBV, "AcquisitionDelay", kind="config") calibration_label = ADCpt(EpicsSignalWithRBV, "CalibrationLabel", string=True, kind="config") exposure_delay = ADCpt(EpicsSignalWithRBV, "ExposureDelay", kind="config") file_name = ADCpt(EpicsSignalWithRBV, "FileName", string=True, kind="config") file_path = ADCpt(EpicsSignalWithRBV, "FilePath", string=True, kind="config") lower_threshold = ADCpt(EpicsSignalWithRBV, "LowerThreshold", kind="config") upper_threshold = ADCpt(EpicsSignalWithRBV, "UpperThreshold", kind="config") corrections = ADCpt(EpicsSignal, "Corrections", kind="config", string=True) # has no _RBV PV # remove these attributes from CamBase pool_max_buffers = None def setup_modes(self, num_triggers): # TODO: yield from bps.null() def setTime(self, *args): # TODO: yield from bps.null() class RigakuUfxcDetector(DetectorBase): _html_docs = ["RigakuUfxcDoc.html"] cam = ADCpt(RigakuUfxcDetectorCam, "cam1:") # TODO: other plugins: Sparse0, IMM staging_mode = ADCpt(Signal, value="fast", kind="config") def staging_setup_DM(self, *args, mode=None): """ setup the detector's stage_sigs for acquisition with the DM workflow from DM_DeviceMixinAreaDetector """ if (mode == 'fast'): self.stage_sigs = {} self.stage_sigs["cam.acquire_time"] = 20e-6 self.stage_sigs["cam.image_mode"] = 5 self.stage_sigs["cam.trigger_mode"] = 4 self.stage_sigs["cam.num_images"] = 100_000 # "_" is a visual separator self.stage_sigs["cam.corrections"] = "Enabled" self.stage_sigs["cam.data_type"] = "UInt32" # TODO: what else is needed? elif (mode == 'slow'): self.stage_sigs = {} self.stage_sigs["cam.image_mode"] = 9 # "16 Bit, 1S" self.stage_sigs["cam.trigger_mode"] = 0 # "Fixed Time" self.stage_sigs["cam.acquire_time"] = 0.1 self.stage_sigs["cam.num_images"] = 10 self.stage_sigs["cam.data_type"] = "UInt16" self.stage_sigs["cam.corrections"] = "Disabled" # self.batch_name.put(self._file_name) adrigaku = RigakuUfxcDetector(IOC_PREFIX, name="adrigaku") ```
qzhang234 commented 3 years ago

One bug I would like to report though: I found that if you don't uncomment the line in ad_rigaku_detector.py that reads: self.batch_name.put(self._file_name), it gives you an error (see pulldown tab). Why does staging detectors require filename/batchname?

Also do I need to always restart Bluesky for the from instrument.devices.ad_rigaku_detector import adrigaku to work?

Error from terminal ``` In [1]: from instrument.devices.ad_rigaku_detector import adrigaku In [2]: adrigaku.staging_setup_DM(mode='fast') --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 adrigaku.staging_setup_DM(mode='fast') ~/.ipython-bluesky/profile_bluesky/startup/instrument/devices/ad_rigaku_detector.py in staging_setup_DM(self, mode, *args) 89 self.stage_sigs["cam.corrections"] = "Disabled" 90 ---> 91 self.batch_name.put(self._file_name) 92 93 adrigaku = RigakuUfxcDetector(IOC_PREFIX, name="adrigaku") ~/.conda/envs/bluesky_2021_1/lib/python3.8/site-packages/ophyd/device.py in __getattr__(self, name) 1195 # Components will be instantiated through the descriptor mechanism in 1196 # the Component class, so anything reaching this point is an error. -> 1197 raise AttributeError(name) 1198 1199 def _instantiate_component(self, attr): AttributeError: batch_name In [3]: ```
prjemian commented 3 years ago

Hmmm... Did we miss defining batch_name somewhere (perhaps in the base class)? The error says it is not defined. Confirm this by examining dir(adrigaku) for the text batch_name.

prjemian commented 3 years ago

I see it defined here: https://github.com/aps-8id-dys/ipython-8idiuser/blob/5d8c30f82da1112a1316d46b9df887239faa250d/profile_bluesky/startup/instrument/devices/rigaku_ufxc.py#L167

Since batch name is associated with the data management workflow, it should be defined in the DM base class for area detector support. My recommendation is here, just after detector_number: https://github.com/aps-8id-dys/ipython-8idiuser/blob/6441425b2fda10b4357ec7ddb58d32eca6c1bc43/profile_bluesky/startup/instrument/devices/data_management.py#L147-L151

prjemian commented 3 years ago

On 2nd thought, batch_name is only used by the non-EPICS rigaku ufxc support, right? If that's the case, then no need to keep the failing lin in the ad_rigaku_detector.py file.

@qzhang234 : Which way?

qzhang234 commented 3 years ago

@prjemian It seems like batch_name is used with the nc web command, which is something designed only for LabView PC and has become obsolete (The LabView PC is actually in a crate right now ready to be shipped back to Rigaku). So yes, you are right and there is no need to keep batch_name in ad_rigaku_detector.py.

Thanks for bringing it up

prjemian commented 3 years ago

closed too early, there is still an open PR (#253) to be considered and merged...

prjemian commented 3 years ago

Commit 4a04198 remove the call to batch_name from ad_rigaku_detector.py