diff --git a/ophyd_devices/epics/devices/DelayGeneratorDG645.py b/ophyd_devices/epics/devices/DelayGeneratorDG645.py index ef78a6f..e5a1848 100644 --- a/ophyd_devices/epics/devices/DelayGeneratorDG645.py +++ b/ophyd_devices/epics/devices/DelayGeneratorDG645.py @@ -369,7 +369,7 @@ class DelayGeneratorDG645(Device): f"{name}_set_high_on_exposure": False, f"{name}_set_high_on_stage": False, f"{name}_set_trigger_source": "SINGLE_SHOT", - f"{name}_trigger_width": None, # This somehow duplicates the logic of fixed_ttl_width + f"{name}_trigger_width": None, # This somehow duplicates the logic of fixed_ttl_width } if ddg_config is not None: [self.ddg_config.update({f"{name}_{key}": value}) for key, value in ddg_config.items()] @@ -475,9 +475,7 @@ class DelayGeneratorDG645(Device): return status.set_finished() while True: self.trigger_burst_readout.put(1, use_complete=True) - if ( - self.burst_cycle_finished.read()[self.burst_cycle_finished.name]["value"] == 1 - ): + if self.burst_cycle_finished.read()[self.burst_cycle_finished.name]["value"] == 1: self._acquisition_done = True status.set_finished() return @@ -515,9 +513,9 @@ class DelayGeneratorDG645(Device): else: self.set_channels("width", self.trigger_width.get()) for value, channel in zip(self.fixed_ttl_width.get(), self._all_channels): - logger.info(f'{value}') - if value !=0: - logger.info(f'Setting {value}') + logger.info(f"{value}") + if value != 0: + logger.info(f"Setting {value}") self.set_channels("width", value, channels=[channel]) else: self._set_trigger(getattr(TriggerSource, self.set_trigger_source.get())) @@ -555,9 +553,9 @@ class DelayGeneratorDG645(Device): else: self.set_channels("width", self.trigger_width.get()) for value, channel in zip(self.fixed_ttl_width.get(), self._all_channels): - logger.info(f'{value}') - if value !=0: - logger.info(f'Setting {value}') + logger.info(f"{value}") + if value != 0: + logger.info(f"Setting {value}") self.set_channels("width", value, channels=[channel]) else: # define parameters diff --git a/ophyd_devices/epics/devices/eiger9m_csaxs.py b/ophyd_devices/epics/devices/eiger9m_csaxs.py index 071bc1e..8e7a896 100644 --- a/ophyd_devices/epics/devices/eiger9m_csaxs.py +++ b/ophyd_devices/epics/devices/eiger9m_csaxs.py @@ -104,9 +104,10 @@ class Eiger9mCsaxs(DetectorBase): prefix (str): PV prefix (X12SA-ES-EIGER9M:) """ + USER_ACCESS = [ "describe", - ] + ] cam = ADCpt(SlsDetectorCam, "cam1:") @@ -193,7 +194,7 @@ class Eiger9mCsaxs(DetectorBase): self.std_client = StdDaqClient(url_base=self.std_rest_server_url) self.std_client.stop_writer() timeout = 0 - #TODO put back change of e-account! + # TODO put back change of e-account! # self._update_std_cfg("writer_user_id", int(self.scaninfo.username.strip(" e"))) # time.sleep(5) while not self.std_client.get_status()["state"] == "READY": @@ -321,7 +322,7 @@ class Eiger9mCsaxs(DetectorBase): logger.info(f"Old scanID: {old_scanID}, ") if self.scaninfo.scanID != old_scanID: self._stopped = True - if self._stopped ==True: + if self._stopped == True: return super().unstage() self._eiger9M_finished() # Message to BEC diff --git a/ophyd_devices/epics/devices/epics_motor_ex.py b/ophyd_devices/epics/devices/epics_motor_ex.py index 5e085eb..f782c36 100644 --- a/ophyd_devices/epics/devices/epics_motor_ex.py +++ b/ophyd_devices/epics/devices/epics_motor_ex.py @@ -46,7 +46,7 @@ class EpicsMotorEx(EpicsMotor): # print out attributes that are being configured print("setting ", key, "=", value) getattr(self, key).put(value) - + # self.motor_done_move.subscribe(self._progress_update, run=False) # def kickoff(self) -> DeviceStatus: @@ -62,4 +62,4 @@ class EpicsMotorEx(EpicsMotor): # sub_type=self.SUB_PROGRESS, # value=value , # done= 1, - # ) \ No newline at end of file + # ) diff --git a/ophyd_devices/epics/devices/falcon_csaxs.py b/ophyd_devices/epics/devices/falcon_csaxs.py index fb4e6fd..b9d6662 100644 --- a/ophyd_devices/epics/devices/falcon_csaxs.py +++ b/ophyd_devices/epics/devices/falcon_csaxs.py @@ -238,7 +238,7 @@ class FalconCsaxs(Device): self.scaninfo.load_scan_metadata() logger.info(f"Old scanID: {old_scanID}, ") if self.scaninfo.scanID != old_scanID: - self._stopped = True + self._stopped = True if self._stopped: return super().unstage() self._falcon_finished() @@ -257,7 +257,7 @@ class FalconCsaxs(Device): """Function with 10s timeout""" timer = 0 while True: - det_ctrl = self.state.read()[self.state.name]['value'] + det_ctrl = self.state.read()[self.state.name]["value"] writer_ctrl = self.hdf5.capture.get() received_frames = self.dxp.current_pixel.get() total_frames = int(self.scaninfo.num_points * self.scaninfo.frames_per_trigger) diff --git a/ophyd_devices/epics/devices/mcs_csaxs.py b/ophyd_devices/epics/devices/mcs_csaxs.py index d5804b5..1dab29f 100644 --- a/ophyd_devices/epics/devices/mcs_csaxs.py +++ b/ophyd_devices/epics/devices/mcs_csaxs.py @@ -97,8 +97,7 @@ class SIS38XX(Device): class McsCsaxs(SIS38XX): - USER_ACCESS = [ - "_init_mcs"] + USER_ACCESS = ["_init_mcs"] SUB_PROGRESS = "progress" SUB_VALUE = "value" _default_sub = SUB_VALUE @@ -231,7 +230,7 @@ class McsCsaxs(SIS38XX): max_value = self.scaninfo.num_points self._run_subs( sub_type=self.SUB_PROGRESS, - value=self.counter * int(self.scaninfo.num_points / num_lines) + value , + value=self.counter * int(self.scaninfo.num_points / num_lines) + value, max_value=max_value, done=bool(max_value == self.counter), ) @@ -240,14 +239,14 @@ class McsCsaxs(SIS38XX): def _on_mca_data(self, *args, obj=None, **kwargs) -> None: if not isinstance(kwargs["value"], (list, np.ndarray)): return - #self.mca_data[obj.attr_name] = kwargs["value"][1:] + # self.mca_data[obj.attr_name] = kwargs["value"][1:] self.mca_data[obj.attr_name] = kwargs["value"] if len(self.mca_names) != len(self.mca_data): return - #logger.info("Entered _on_mca_data") + # logger.info("Entered _on_mca_data") # self._updated = True # self.counter += 1 - #logger.info(f'data from mca {self.mca_data["mca1"]} and {self.mca_data["mca4"]}') + # logger.info(f'data from mca {self.mca_data["mca1"]} and {self.mca_data["mca4"]}') # if (self.scaninfo.scan_type == "fly" and self.counter == self.num_lines.get()) or ( # self.scaninfo.scan_type == "step" and self.counter == self.scaninfo.num_points # ): @@ -298,7 +297,7 @@ class McsCsaxs(SIS38XX): if self.scaninfo.scan_type == "step": self.n_points = int(self.scaninfo.frames_per_trigger) elif self.scaninfo.scan_type == "fly": - self.n_points = int(self.scaninfo.num_points)# / int(self.num_lines.get())) + self.n_points = int(self.scaninfo.num_points) # / int(self.num_lines.get())) else: raise McsError(f"Scantype {self.scaninfo} not implemented for MCS card") if self.n_points > 10000: @@ -357,7 +356,7 @@ class McsCsaxs(SIS38XX): self.scaninfo.load_scan_metadata() logger.info(f"Old scanID: {old_scanID}, ") if self.scaninfo.scanID != old_scanID: - self._stopped = True + self._stopped = True if self._stopped is True: logger.info("Entered unstage _stopped =True") return super().unstage() diff --git a/ophyd_devices/epics/devices/pilatus_csaxs.py b/ophyd_devices/epics/devices/pilatus_csaxs.py index 93a3f26..df4be85 100644 --- a/ophyd_devices/epics/devices/pilatus_csaxs.py +++ b/ophyd_devices/epics/devices/pilatus_csaxs.py @@ -163,7 +163,7 @@ class PilatusCsaxs(DetectorBase): self.filewriter = FileWriterMixin(self.service_cfg) self.readout = 1e-3 # 3 ms - + # TODO maybe needed # self._close_file_writer() @@ -210,16 +210,16 @@ class PilatusCsaxs(DetectorBase): a zmq service is running on xbl-daq-34 that is waiting for a zmq message to start the writer for the pilatus_2 x12sa-pd-2 """ - #TODO worked reliable with time.sleep(2) + # TODO worked reliable with time.sleep(2) # self._close_file_writer() # time.sleep(2) # self._stop_file_writer() # time.sleep(2) self._close_file_writer() - time.sleep(.1) + time.sleep(0.1) self._stop_file_writer() - time.sleep(.1) - + time.sleep(0.1) + self.filepath_h5 = self.filewriter.compile_full_filename( self.scaninfo.scan_number, "pilatus_2.h5", 1000, 5, True ) @@ -369,7 +369,7 @@ class PilatusCsaxs(DetectorBase): self.scaninfo.load_scan_metadata() logger.info(f"Old scanID: {old_scanID}, ") if self.scaninfo.scanID != old_scanID: - self._stopped = True + self._stopped = True if self._stopped: return super().unstage() self._pilatus_finished() @@ -398,7 +398,7 @@ class PilatusCsaxs(DetectorBase): # while True: # # rtr = self.cam.status_message_camserver.get() # #if self.cam.acquire.get() == 0 and rtr == "Camserver returned OK": - # # if rtr == "Camserver returned OK": + # # if rtr == "Camserver returned OK": # # break # if self._stopped == True: # break @@ -411,7 +411,7 @@ class PilatusCsaxs(DetectorBase): # # raise PilatusTimeoutError( # # f"Pilatus timeout with detector state {self.cam.acquire.get()} and camserver return status: {rtr} " # # ) - + self._stop_file_writer() time.sleep(2) self._close_file_writer() diff --git a/ophyd_devices/epics/devices/sequencer_x12sa.py b/ophyd_devices/epics/devices/sequencer_x12sa.py index 5f0a531..3c8cd82 100644 --- a/ophyd_devices/epics/devices/sequencer_x12sa.py +++ b/ophyd_devices/epics/devices/sequencer_x12sa.py @@ -1,8 +1,8 @@ from ophyd import Component as Cpt, EpicsSignal, EpicsSignalRO, Device + class SequencerX12SA(Device): - """Sequencer for flyscans with epics motor controller and owis stages - """ + """Sequencer for flyscans with epics motor controller and owis stages""" desired_output_link_1 = Cpt(Signal, "DOL1") desired_output_value_1 = Cpt(EpicsSignal, "DO1") @@ -20,7 +20,6 @@ class SequencerX12SA(Device): status = Cpt(EpicsSignalRO, "STAT", string=True) processing_active = Cpt(EpicsSignalRO, "PACT") - # def __init__( # self, # prefix="", @@ -32,26 +31,26 @@ class SequencerX12SA(Device): # parent=None, # **kwargs # ): - # # get configuration attributes from kwargs and then remove them - # attrs = {} - # for key, value in kwargs.items(): - # if hasattr(EpicsMotorEx, key) and isinstance(getattr(EpicsMotorEx, key), Cpt): - # attrs[key] = value - # for key in attrs: - # kwargs.pop(key) + # # get configuration attributes from kwargs and then remove them + # attrs = {} + # for key, value in kwargs.items(): + # if hasattr(EpicsMotorEx, key) and isinstance(getattr(EpicsMotorEx, key), Cpt): + # attrs[key] = value + # for key in attrs: + # kwargs.pop(key) - # super().__init__( - # prefix, - # name=name, - # kind=kind, - # read_attrs=read_attrs, - # configuration_attrs=configuration_attrs, - # parent=parent, - # **kwargs - # ) + # super().__init__( + # prefix, + # name=name, + # kind=kind, + # read_attrs=read_attrs, + # configuration_attrs=configuration_attrs, + # parent=parent, + # **kwargs + # ) - # # set configuration attributes - # for key, value in attrs.items(): - # # print out attributes that are being configured - # print("setting ", key, "=", value) - # getattr(self, key).put(value) + # # set configuration attributes + # for key, value in attrs.items(): + # # print out attributes that are being configured + # print("setting ", key, "=", value) + # getattr(self, key).put(value) diff --git a/ophyd_devices/epics/devices/specMotors.py b/ophyd_devices/epics/devices/specMotors.py index 2643538..6151b0f 100644 --- a/ophyd_devices/epics/devices/specMotors.py +++ b/ophyd_devices/epics/devices/specMotors.py @@ -212,7 +212,7 @@ class EnergyKev(VirtualEpicsSignalRO): ) offs = np.interp(energy_keV, self._th2_offsets[:, 0], self._th2_offsets[:, 1]) - #print(offs) + # print(offs) return offs def calc(self, val): diff --git a/ophyd_devices/galil/sgalil_ophyd.py b/ophyd_devices/galil/sgalil_ophyd.py index 4766e6d..01c86f1 100644 --- a/ophyd_devices/galil/sgalil_ophyd.py +++ b/ophyd_devices/galil/sgalil_ophyd.py @@ -315,10 +315,10 @@ class GalilController(Controller): self.socket_put_and_receive("XQ#SCANG") # self._block_while_active(3) # time.sleep(0.1) - threading.Thread(target=self._block_while_active, args=(3,status), daemon=True).start() + threading.Thread(target=self._block_while_active, args=(3, status), daemon=True).start() # self._while_in_motion(3, n_samples) - def _block_while_active(self,thread_id:int, status) -> None: + def _block_while_active(self, thread_id: int, status) -> None: while self.is_thread_active(thread_id): time.sleep(1) time.sleep(1) @@ -691,10 +691,10 @@ class SGalilMotor(Device, PositionerBase): def stop(self, *, success=False): self.controller.stop_all_axes() - #last_speed = self.controller.socket_put_and_receive("MG") - rtr = self.controller.socket_put_and_receive(f'SPC={2*10000}') + # last_speed = self.controller.socket_put_and_receive("MG") + rtr = self.controller.socket_put_and_receive(f"SPC={2*10000}") logger.info(f"{rtr}") - #logger.info(f'Motor stopped, restored speed for samy from {last_speed}mm/s to 2mm/s') + # logger.info(f'Motor stopped, restored speed for samy from {last_speed}mm/s to 2mm/s') return super().stop(success=success) def kickoff(self) -> DeviceStatus: @@ -712,8 +712,6 @@ class SGalilMotor(Device, PositionerBase): ) return status - - def configure( self, parameter: dict, @@ -722,7 +720,6 @@ class SGalilMotor(Device, PositionerBase): self._kickoff_params = parameter - if __name__ == "__main__": mock = False if not mock: