APS-USAXS / bluesky

USAXS Bluesky instrument for APS-U era
0 stars 0 forks source link

Fixing tuning code #9

Open jilavsky opened 3 weeks ago

jilavsky commented 3 weeks ago

We recasted the tuning a lot and now I am running in issues. I am testing without beam for now. RE(tune_mr()) results in error:

... run engine error discarded:
  File "/home/beams/USAXS/bluesky/instrument/plans/axis_tuning.py", line 96, in tune_mr
    yield from _tune_base_(m_stage.r, md=md)
  File "/home/beams/USAXS/bluesky/instrument/plans/axis_tuning.py", line 72, in _tune_base_
    uuids = yield from axis.tune(md=md)     #note: the tune method comes from usaxs_motor_devices, TunableEpicsMotor, which uses lineup2
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/beams/USAXS/bluesky/instrument/devices/usaxs_motor_devices.py", line 109, in tune
    return (yield from _inner())
            ^^^^^^^^^^^^^^^^^^^
  File "/home/beams/USAXS/bluesky/instrument/devices/usaxs_motor_devices.py", line 107, in _inner
    yield from self.post_tune_hook()
TypeError: 'NoneType' object is not iterable

lines 106 and 107 are:

            if self.post_tune_hook is not None:
                yield from self.post_tune_hook()

which object is NoneType here?

Same "if" passes in lines 74/75 in pre_tune_hook, which si defined equivalent way in stages.py :

            if self.pre_tune_hook is not None:
                yield from self.pre_tune_hook()

While the post_tune_hook code for mr (in stages.py) is:

   def mr_posttune_hook():
    msg = "Tuning axis {}, final position is {}"
    logger.info(msg.format(m_stage.r.name, m_stage.r.position))
    # need to plot data in plans 
    scaler0.select_channels(None)

this code in mr_pretune_hook() works fine:

    stage = m_stage.r
    logger.info(f"Tuning axis {stage.name}, current position is {stage.position}")

so m_stage.r.name and m_stage.r.position should exist.

jilavsky commented 3 weeks ago

I commented out some of the lines and got other errors, I think this code has not been finished when we were converting to use lineup2. usaxs_motor_devices.py has TODO in TunableEpicsMotor2 code which we did not finish that we need to engineer return back of various results from lineup2. We need value which previously was called .tuner.PeakDetected and pass back position, FWHM, etc. Unluckily, this is slightly beyond my league for now.