From 3db21319ffa830785d6cacafeeafed822db782fd Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Tue, 20 Aug 2024 09:35:25 -0700 Subject: [PATCH 1/8] added base class for hxr diffractometer --- pcdsdevices/gon.py | 28 +++++++++++- pcdsdevices/lakeshore.py | 98 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 pcdsdevices/lakeshore.py diff --git a/pcdsdevices/gon.py b/pcdsdevices/gon.py index 98cf1ba08ce..3103456f9a0 100644 --- a/pcdsdevices/gon.py +++ b/pcdsdevices/gon.py @@ -4,16 +4,17 @@ import logging import numpy as np -from ophyd import FormattedComponent as FCpt +from ophyd import FormattedComponent as FCpt, Device from ophyd.device import Component as Cpt from ophyd.status import DeviceStatus from prettytable import PrettyTable from .device import GroupDevice -from .epics_motor import IMS +from .epics_motor import (IMS, BeckhoffAxis) from .interface import BaseInterface from .pseudopos import (PseudoPositioner, PseudoSingleInterface, pseudo_position_argument, real_position_argument) +from .signal import PytmcSignal from .sim import FastMotor from .utils import get_status_float, get_status_value @@ -674,3 +675,26 @@ def __init__(self): super().__init__(name='SimKappa', prefix_x='X', prefix_y='Y', prefix_z='Z', prefix_eta='ETA', prefix_kappa='KAPPA', prefix_phi='PHI') + +class HxrDiffractometer(BaseInterface, Device): + """ + Class for diffractometer. + + Parameters + ---------- + name : str + A name to refer to the device + + prefix_base : str + The EPICS base PV of the diffractometer stages + """ + + base_h = Cpt(BeckhoffAxis, 'BASE_H', kind='normal') + base_v = Cpt(BeckhoffAxis, 'BASE_V', kind='normal') + th = Cpt(BeckhoffAxis, 'CHI', kind='normal') + two_th = Cpt(BeckhoffAxis, 'TH', kind='normal') + chi = Cpt(BeckhoffAxis, '2TH', kind='normal') + + tab_component_names = True + + \ No newline at end of file diff --git a/pcdsdevices/lakeshore.py b/pcdsdevices/lakeshore.py new file mode 100644 index 00000000000..db6889cf40d --- /dev/null +++ b/pcdsdevices/lakeshore.py @@ -0,0 +1,98 @@ +""" +Classes for lakeshore temperature controller +""" +import logging +import subprocess + +from ophyd import Component as Cpt +from ophyd import FormattedComponent as FCpt +from ophyd import Device, EpicsSignal, EpicsSignaRO, EpicsSignalWithRBV + +from .interface import BaseInterface + +logger = loggin.getLogger(__name__) + +class Lakeshore336(Device): + """ + two loops + 4 temperature sensors + also include device control mode + """ + + + # two loops + temp_loop_1 = Cpt(EpicsSignal, 'GET_SOLL_{self.channel}', write_pv = 'PUT_SOLL_{self.channel}', kind = 'normal') + temp_loop_2 = Cpt(EpicsSignal, 'GET_SOLL_{self.channel}', write_pv = 'PUT_SOLL_{self.channel}', kind = 'normal') + + # 4 temperature sensors + temp_A = Cpt(TemperatureSensor, channel = 'A', kind = 'normal') + temp_B = Cpt(TemperatureSensor, channel = 'B', kind = 'normal') + temp_C = Cpt(TemperatureSensor, channel = 'C', kind = 'normal') + temp_D = Cpt(TemperatureSensor, channel = 'D', kind = 'normal') + + # device control mode + device_control = Cpt(HeaterControlMode, kind = 'normal') + +class Loop(): + pass + +class Heater(Device): + # note: do not hardcode channel + # should take in channel input, hardcode kind to normal + + range = Cpt(HeaterState, channel = '1', kind = 'normal') + + +class HeaterState(StatePositioner): + """ + HeaterState Channel Object. + + Parameters + ---------- + channel_prefix : str + The EPICS base of the HeaterState Channel. E.g.: `` + card_prefix : str, optional + The EPICS base of the MPOD Module. `XPP:R39:MPD:MOD:10` + """ + range = Cpt(EpicsSignal, 'GET_RANGE_{self.channel}', + write_pv = 'PUT_RANGE_{self.channel}', kind = 'normal', doc = 'heater range') + state = Cpt(EpicsSignalRO, 'GET_HTRSTAT_{self.channel}', kind = 'normal') + + _unknown = False + states_list = ['Off', 'Low', 'Medium', 'High'] + # insert tab white list + + def __init__(self, prefix, channel, **kwargs): + self.channel = channel + super().__init__(prefix, **kwargs) + +class TemperatureSensor(BaseInterface, Device): + input_name = Cpt(EpicsSignalRO, 'GET_INAME_{self.channel}', kind = + 'config') + temp = Cpt(EpicsSignalRO, 'GET_TEMP_{self.channel}', kind = 'normal') + units = Cpt(EpicsSignal, 'GET_UNITS_{self.channel}', write_pv = + 'PUT_UNITS_{self.channel}', kind = 'normal') + sensor_type = Cpt(EpicsSignalRO, 'GET_SENSOR_{self.channel}', kind = + 'normal') + + def __init__(self, prefix, channel, **kwargs): + self.channel = channel + super().__init__(prefix, **kwargs) + + + +class HeaterControlMode(StatePositioner): + """ + Class for Heater control + """ + mode = Cpt(EpicsSignal, 'GET_MODE', write_pv = 'PUT_MODE', kind = 'normal', doc = 'control mode') + _unknown = False + states_list = ['Local, Remote, Rem/Lock'] + tab_component_name = True + + + + + + + From 21c664da233a2d349967ccf73b1de4f947769c8c Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Tue, 20 Aug 2024 09:40:04 -0700 Subject: [PATCH 2/8] running pre-commit --- pcdsdevices/gon.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/pcdsdevices/gon.py b/pcdsdevices/gon.py index 3103456f9a0..fc2f479f761 100644 --- a/pcdsdevices/gon.py +++ b/pcdsdevices/gon.py @@ -4,13 +4,14 @@ import logging import numpy as np -from ophyd import FormattedComponent as FCpt, Device +from ophyd import Device +from ophyd import FormattedComponent as FCpt from ophyd.device import Component as Cpt from ophyd.status import DeviceStatus from prettytable import PrettyTable from .device import GroupDevice -from .epics_motor import (IMS, BeckhoffAxis) +from .epics_motor import IMS, BeckhoffAxis from .interface import BaseInterface from .pseudopos import (PseudoPositioner, PseudoSingleInterface, pseudo_position_argument, real_position_argument) @@ -656,26 +657,6 @@ def format_status_info(self, status_info): e_eta, e_chi, e_phi: {e_eta}, {e_chi}, {e_phi} x, y, z: {x}, {y}, {z} [{units}] """ - - -class SimSampleStage(KappaXYZStage): - x = Cpt(FastMotor, limits=(-100, 100)) - y = Cpt(FastMotor, limits=(-100, 100)) - z = Cpt(FastMotor, limits=(-100, 100)) - - -class SimKappa(Kappa): - """Test version of the Kappa object.""" - sample_stage = Cpt(SimSampleStage, name='') - eta = Cpt(FastMotor, limits=(-180, 180)) - kappa = Cpt(FastMotor, limits=(-360, 360)) - phi = Cpt(FastMotor, limits=(-180, 180)) - - def __init__(self): - super().__init__(name='SimKappa', prefix_x='X', prefix_y='Y', - prefix_z='Z', prefix_eta='ETA', prefix_kappa='KAPPA', - prefix_phi='PHI') - class HxrDiffractometer(BaseInterface, Device): """ Class for diffractometer. @@ -697,4 +678,21 @@ class HxrDiffractometer(BaseInterface, Device): tab_component_names = True - \ No newline at end of file + +class SimSampleStage(KappaXYZStage): + x = Cpt(FastMotor, limits=(-100, 100)) + y = Cpt(FastMotor, limits=(-100, 100)) + z = Cpt(FastMotor, limits=(-100, 100)) + + +class SimKappa(Kappa): + """Test version of the Kappa object.""" + sample_stage = Cpt(SimSampleStage, name='') + eta = Cpt(FastMotor, limits=(-180, 180)) + kappa = Cpt(FastMotor, limits=(-360, 360)) + phi = Cpt(FastMotor, limits=(-180, 180)) + + def __init__(self): + super().__init__(name='SimKappa', prefix_x='X', prefix_y='Y', + prefix_z='Z', prefix_eta='ETA', prefix_kappa='KAPPA', + prefix_phi='PHI') From 4e2283541935b73dea7ad482e091fd71ac9db58e Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Thu, 22 Aug 2024 14:54:17 -0700 Subject: [PATCH 3/8] adding init and super init call --- pcdsdevices/gon.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pcdsdevices/gon.py b/pcdsdevices/gon.py index fc2f479f761..e7dafc1e0b0 100644 --- a/pcdsdevices/gon.py +++ b/pcdsdevices/gon.py @@ -677,6 +677,8 @@ class HxrDiffractometer(BaseInterface, Device): chi = Cpt(BeckhoffAxis, '2TH', kind='normal') tab_component_names = True + def __init__(self, prefix, name, **kwargs): + super().__init__(prefix, name = name, **kwargs) class SimSampleStage(KappaXYZStage): From cf6ad25f21ddfdf74439a3cd0e7b6130cdffe811 Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Wed, 18 Sep 2024 09:00:17 -0700 Subject: [PATCH 4/8] removing lakeshore class from PR --- pcdsdevices/lakeshore.py | 98 ---------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 pcdsdevices/lakeshore.py diff --git a/pcdsdevices/lakeshore.py b/pcdsdevices/lakeshore.py deleted file mode 100644 index db6889cf40d..00000000000 --- a/pcdsdevices/lakeshore.py +++ /dev/null @@ -1,98 +0,0 @@ -""" -Classes for lakeshore temperature controller -""" -import logging -import subprocess - -from ophyd import Component as Cpt -from ophyd import FormattedComponent as FCpt -from ophyd import Device, EpicsSignal, EpicsSignaRO, EpicsSignalWithRBV - -from .interface import BaseInterface - -logger = loggin.getLogger(__name__) - -class Lakeshore336(Device): - """ - two loops - 4 temperature sensors - also include device control mode - """ - - - # two loops - temp_loop_1 = Cpt(EpicsSignal, 'GET_SOLL_{self.channel}', write_pv = 'PUT_SOLL_{self.channel}', kind = 'normal') - temp_loop_2 = Cpt(EpicsSignal, 'GET_SOLL_{self.channel}', write_pv = 'PUT_SOLL_{self.channel}', kind = 'normal') - - # 4 temperature sensors - temp_A = Cpt(TemperatureSensor, channel = 'A', kind = 'normal') - temp_B = Cpt(TemperatureSensor, channel = 'B', kind = 'normal') - temp_C = Cpt(TemperatureSensor, channel = 'C', kind = 'normal') - temp_D = Cpt(TemperatureSensor, channel = 'D', kind = 'normal') - - # device control mode - device_control = Cpt(HeaterControlMode, kind = 'normal') - -class Loop(): - pass - -class Heater(Device): - # note: do not hardcode channel - # should take in channel input, hardcode kind to normal - - range = Cpt(HeaterState, channel = '1', kind = 'normal') - - -class HeaterState(StatePositioner): - """ - HeaterState Channel Object. - - Parameters - ---------- - channel_prefix : str - The EPICS base of the HeaterState Channel. E.g.: `` - card_prefix : str, optional - The EPICS base of the MPOD Module. `XPP:R39:MPD:MOD:10` - """ - range = Cpt(EpicsSignal, 'GET_RANGE_{self.channel}', - write_pv = 'PUT_RANGE_{self.channel}', kind = 'normal', doc = 'heater range') - state = Cpt(EpicsSignalRO, 'GET_HTRSTAT_{self.channel}', kind = 'normal') - - _unknown = False - states_list = ['Off', 'Low', 'Medium', 'High'] - # insert tab white list - - def __init__(self, prefix, channel, **kwargs): - self.channel = channel - super().__init__(prefix, **kwargs) - -class TemperatureSensor(BaseInterface, Device): - input_name = Cpt(EpicsSignalRO, 'GET_INAME_{self.channel}', kind = - 'config') - temp = Cpt(EpicsSignalRO, 'GET_TEMP_{self.channel}', kind = 'normal') - units = Cpt(EpicsSignal, 'GET_UNITS_{self.channel}', write_pv = - 'PUT_UNITS_{self.channel}', kind = 'normal') - sensor_type = Cpt(EpicsSignalRO, 'GET_SENSOR_{self.channel}', kind = - 'normal') - - def __init__(self, prefix, channel, **kwargs): - self.channel = channel - super().__init__(prefix, **kwargs) - - - -class HeaterControlMode(StatePositioner): - """ - Class for Heater control - """ - mode = Cpt(EpicsSignal, 'GET_MODE', write_pv = 'PUT_MODE', kind = 'normal', doc = 'control mode') - _unknown = False - states_list = ['Local, Remote, Rem/Lock'] - tab_component_name = True - - - - - - - From 0a4508e6853854a576135fdda594e78656c543b4 Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Fri, 20 Sep 2024 10:39:05 -0700 Subject: [PATCH 5/8] Fixing mapping and renaming of stage reference. Plus pre-commit fixes. --- pcdsdevices/gon.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pcdsdevices/gon.py b/pcdsdevices/gon.py index e7dafc1e0b0..bc4d22ec65c 100644 --- a/pcdsdevices/gon.py +++ b/pcdsdevices/gon.py @@ -15,7 +15,6 @@ from .interface import BaseInterface from .pseudopos import (PseudoPositioner, PseudoSingleInterface, pseudo_position_argument, real_position_argument) -from .signal import PytmcSignal from .sim import FastMotor from .utils import get_status_float, get_status_value @@ -657,6 +656,8 @@ def format_status_info(self, status_info): e_eta, e_chi, e_phi: {e_eta}, {e_chi}, {e_phi} x, y, z: {x}, {y}, {z} [{units}] """ + + class HxrDiffractometer(BaseInterface, Device): """ Class for diffractometer. @@ -672,13 +673,14 @@ class HxrDiffractometer(BaseInterface, Device): base_h = Cpt(BeckhoffAxis, 'BASE_H', kind='normal') base_v = Cpt(BeckhoffAxis, 'BASE_V', kind='normal') - th = Cpt(BeckhoffAxis, 'CHI', kind='normal') - two_th = Cpt(BeckhoffAxis, 'TH', kind='normal') - chi = Cpt(BeckhoffAxis, '2TH', kind='normal') + th = Cpt(BeckhoffAxis, 'TH', kind='normal') + tth = Cpt(BeckhoffAxis, 'TTH', kind='normal') + chi = Cpt(BeckhoffAxis, 'CHI', kind='normal') tab_component_names = True + def __init__(self, prefix, name, **kwargs): - super().__init__(prefix, name = name, **kwargs) + super().__init__(prefix, name=name, **kwargs) class SimSampleStage(KappaXYZStage): From b4946af333c866ddbf412f0b5e05c1668416c0e7 Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Tue, 1 Oct 2024 09:24:00 -0700 Subject: [PATCH 6/8] Adding pre-release notes for hxr diffractometer. --- ...ing_base_class_for_hxr_diffractometer..rst | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst diff --git a/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst new file mode 100644 index 00000000000..e27ce9fe5be --- /dev/null +++ b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst @@ -0,0 +1,30 @@ +1274 Adding base class for hxr diffractometer. +################# + +API Breaks +---------- +- N/A + +Features +-------- +- Adding base class for the hxr diffractometer, the class will ask user to input base PV e.g. HXR:GON:MMS as the prefix. All of the stages are hardcoded as suffixes. + +Device Updates +-------------- +- N/A + +New Devices +----------- +- N/A + +Bugfixes +-------- +- N/A + +Maintenance +----------- +- N/A + +Contributors +------------ +- N/A From b1a4a4f319367ae5c2ceff3d21b35637ff9e2a91 Mon Sep 17 00:00:00 2001 From: Christian Tsoi-A-Sue Date: Tue, 1 Oct 2024 09:31:49 -0700 Subject: [PATCH 7/8] updating pre-release notes --- .../1274-Adding_base_class_for_hxr_diffractometer..rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst index e27ce9fe5be..09aa9f1794a 100644 --- a/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst +++ b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst @@ -7,7 +7,7 @@ API Breaks Features -------- -- Adding base class for the hxr diffractometer, the class will ask user to input base PV e.g. HXR:GON:MMS as the prefix. All of the stages are hardcoded as suffixes. +- Adding base class for hxr diffractometer, this class needs the base prefix to be passed in e.g. HXR:GON:MMS. The stage suffixes are hardcoded. Device Updates -------------- From 5d34e8434ab1bbab51e9a7175ca0dfab3156f10d Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Tue, 1 Oct 2024 11:25:07 -0700 Subject: [PATCH 8/8] DOC: reorganize pre-release notes --- ...4-Adding_base_class_for_hxr_diffractometer..rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst index 09aa9f1794a..e5119abc72e 100644 --- a/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst +++ b/docs/source/upcoming_release_notes/1274-Adding_base_class_for_hxr_diffractometer..rst @@ -5,17 +5,17 @@ API Breaks ---------- - N/A -Features --------- -- Adding base class for hxr diffractometer, this class needs the base prefix to be passed in e.g. HXR:GON:MMS. The stage suffixes are hardcoded. +Library Features +---------------- +- N/A -Device Updates --------------- +Device Features +--------------- - N/A New Devices ----------- -- N/A +- Adding base class for hxr diffractometer, this class needs the base prefix to be passed in e.g. HXR:GON:MMS. The stage suffixes are hardcoded. Bugfixes -------- @@ -27,4 +27,4 @@ Maintenance Contributors ------------ -- N/A +- c-tsoi