Skip to content

Commit

Permalink
Attempted fix for the CI seg faults.
Browse files Browse the repository at this point in the history
  • Loading branch information
canismarko committed Nov 15, 2023
1 parent 0627544 commit 08f395a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
3 changes: 0 additions & 3 deletions src/firefly/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ def _prepare_device_windows(self, device_label: str, attr_name: str):
window_slots = []
setattr(self, f"{attr_name}_window_slots", window_slots)
setattr(self, f"{attr_name}_windows", {})
# if attr_name == "ion_chamber":
# breakpoint()
for device in devices:
# Check that we don't already have actions set
# Create the window action
action = QtWidgets.QAction(self)
action.setObjectName(f"actionShow_{attr_name}_{device.name}")
Expand Down
35 changes: 19 additions & 16 deletions src/firefly/tests/test_xrf_detector_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from firefly.xrf_roi import XRFROIDisplay


detectors = ['xspress',]


@pytest.fixture()
def xrf_display(ffapp, request):
"""Parameterized fixture for creating a display based on a specific
Expand All @@ -21,18 +24,18 @@ def xrf_display(ffapp, request):
# Create the display
display = XRFDetectorDisplay(macros={"DEV": det.name})
# Set sensible starting values
spectra = np.random.default_rng(seed=0).integers(
0, 65536, dtype=np.int_, size=(4, 1024)
)
plot_widget = display.mca_plot_widget
plot_widget.update_spectrum(0, spectra[0])
plot_widget.update_spectrum(1, spectra[1])
plot_widget.update_spectrum(2, spectra[2])
plot_widget.update_spectrum(3, spectra[3])
return display


@pytest.mark.parametrize("det_fixture", ["dxp", "xspress"])
# spectra = np.random.default_rng(seed=0).integers(
# 0, 65536, dtype=np.int_, size=(4, 1024)
# )
# plot_widget = display.mca_plot_widget
# plot_widget.update_spectrum(0, spectra[0])
# plot_widget.update_spectrum(1, spectra[1])
# plot_widget.update_spectrum(2, spectra[2])
# plot_widget.update_spectrum(3, spectra[3])
yield display


@pytest.mark.parametrize("det_fixture", detectors)
def test_open_xrf_detector_viewer_actions(ffapp, qtbot, det_fixture, request):
sim_det = request.getfixturevalue(det_fixture)
# Get the area detector parts ready
Expand All @@ -44,15 +47,15 @@ def test_open_xrf_detector_viewer_actions(ffapp, qtbot, det_fixture, request):
assert "FireflyMainWindow_xrf_detector_vortex_me4" in ffapp.windows.keys()


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_roi_widgets(xrf_display):
xrf_display.draw_roi_widgets(2)
# Check that the widgets were drawn
assert len(xrf_display.roi_displays) == xrf_display.device.num_rois
disp = xrf_display.roi_displays[0]


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_roi_element_comboboxes(ffapp, qtbot, xrf_display):
# Check that the comboboxes have the right number of entries
element_cb = xrf_display.ui.mca_combobox
Expand All @@ -61,7 +64,7 @@ def test_roi_element_comboboxes(ffapp, qtbot, xrf_display):
assert roi_cb.count() == xrf_display.device.num_rois


@pytest.mark.parametrize("det_fixture", ["dxp", "xspress"])
@pytest.mark.parametrize("det_fixture", detectors)
def test_roi_selection(ffapp, qtbot, det_fixture, request):
det = request.getfixturevalue(det_fixture)
display = XRFROIDisplay(macros={"DEV": det.name, "NUM": 2, "MCA": 2, "ROI": 2})
Expand All @@ -78,7 +81,7 @@ def test_roi_selection(ffapp, qtbot, det_fixture, request):
assert f"background: {display.selected_background}" not in display.styleSheet()


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_all_rois_selection(xrf_display):
"""Are all the other ROIs disabled when one is selected?"""
roi_display = xrf_display.roi_displays[0]
Expand Down
48 changes: 24 additions & 24 deletions src/haven/instrument/xspress.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,30 @@
class ChannelSignal(MultiDerivedSignal):
"""A high/low range limit channel for an ROI."""

def set(
self,
value: OphydDataType,
*,
timeout: Optional[float] = None,
settle_time: Optional[float] = None,
) -> StatusBase:
# Check for existing signals and, if necessary, wait them out
signals = [
self.parent.hi_chan,
self.parent.lo_chan,
self.parent.size,
self.parent._lo_chan,
]

def get_threads():
thds = [sig._set_thread for sig in signals if sig._set_thread]
return [th for th in thds if th is not None]

while len(threads := get_threads()) > 0:
for th in threads:
th.join()
# Set the signal like normal
return super().set(value, timeout=timeout, settle_time=settle_time)
# def set(
# self,
# value: OphydDataType,
# *,
# timeout: Optional[float] = None,
# settle_time: Optional[float] = None,
# ) -> StatusBase:
# # Check for existing signals and, if necessary, wait them out
# signals = [
# self.parent.hi_chan,
# self.parent.lo_chan,
# self.parent.size,
# self.parent._lo_chan,
# ]

# def get_threads():
# thds = [sig._set_thread for sig in signals if sig._set_thread]
# return [th for th in thds if th is not None]

# while len(threads := get_threads()) > 0:
# for th in threads:
# th.join()
# # Set the signal like normal
# return super().set(value, timeout=timeout, settle_time=settle_time)


class ROI(ROIMixin):
Expand Down

0 comments on commit 08f395a

Please sign in to comment.