Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhang234 committed Oct 16, 2024
1 parent 635bc54 commit 210b431
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 59 deletions.
3 changes: 2 additions & 1 deletion src/instrument/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from .meascomp_usb_ctr import mcs
from .qnw_device import qnw_env1, qnw_env2, qnw_env3
from .slit_base import sl4_base, sl5_base, sl7_base, sl8_base, sl9_base
from .slit import sl5, sl9 #, sl7, sl8,sl4,
from .slit import sl5, sl9
#, sl7, sl8,sl4,
from .tetramm_picoammeter import tetramm1, tetramm2, tetramm3, tetramm4
from .transfocator_8idd import rl1
from .transfocator_8ide import rl2
Expand Down
114 changes: 56 additions & 58 deletions src/instrument/devices/slit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"""

__all__ = """
sl4
sl5
sl7
sl8
sl9
""".split()

Expand All @@ -15,6 +12,7 @@
from apstools.devices.positioner_soft_done import PVPositionerSoftDone
from ophyd import EpicsMotor
from ophyd import FormattedComponent as FCpt
from ophyd import Component as Cpt
from apstools.synApps.db_2slit import Optics2Slit1D
from apstools.synApps.db_2slit import Optics2Slit2D_HV
from ophyd import Component as cpt
Expand All @@ -25,7 +23,7 @@


class ID8Optics2Slit1D(Optics2Slit1D):

# Define formatted components at the class level using placeholders
def __init__(
self,
prefix: str,
Expand All @@ -35,6 +33,13 @@ def __init__(
*args,
**kwargs,
):
# Store motor names and secondary prefix as instance variables
self.secondary_prefix = secondary_prefix
self.positive_motor = positive_motor
self.negative_motor = negative_motor

# Call the parent constructor
super().__init__(prefix, *args, **kwargs)

xn = cpt(
PVPositionerSoftDone,
Expand Down Expand Up @@ -65,34 +70,28 @@ def __init__(
tolerance=8e-4,
)
sync = cpt(EpicsSignal, "doSync", put_complete=True, kind="omitted")
p = FCpt(EpicsMotor, "{secondary_prefix}:{positive_motor}", labels={"motors"})
n = FCpt(EpicsMotor, "{secondary_prefix}:{negative_motor}", labels={"motors"})

p = FCpt(EpicsMotor, "{secondary_motor_prefix}:{positive_motor}", labels={"motors"})
n = FCpt(EpicsMotor, "{secondary_motor_prefix}:{negative_motor}", labels={"motors"})



# class ID8Optics2Slit2D_HV(Optics2Slit2D_HV):
# def __init__(
# self,
# prefix: str,
# secondary_prefix: str,
# h_positive_motor: str,
# h_negative_motor: str,
# v_positive_motor: str,
# v_negative_motor: str,
# *args,
# **kwargs,
# ):
# print("help me I'm stuck \n\n\n\n")
# h = FCpt(
# ID8Optics2Slit1D,
# prefix,
# secondary_prefix="{secondary_prefix}",
# positive_motor="{h_positive_motor}",
# negative_motor="{h_negative_motor}"
# )

class ID8Optics2Slit2D_HV(Optics2Slit2D_HV):
# Define horizontal and vertical slit components
h = Cpt(
ID8Optics2Slit1D,
"H",
secondary_prefix="{_secondary_prefix}",
positive_motor="{_h_positive_motor}",
negative_motor="{_h_negative_motor}",
)

v = Cpt(
ID8Optics2Slit1D,
"V",
secondary_prefix="{_secondary_prefix}",
positive_motor="{_v_positive_motor}",
negative_motor="{_v_negative_motor}",
)

def __init__(
self,
prefix: str,
Expand All @@ -104,35 +103,34 @@ def __init__(
*args,
**kwargs,
):
# Store the motor names and secondary prefix as instance variables
self._h_positive_motor = h_positive_motor
self._h_negative_motor = h_negative_motor
self._v_positive_motor = v_positive_motor
self._v_negative_motor = v_negative_motor
self._secondary_prefix = secondary_prefix

# Call the parent constructor
super().__init__(prefix, *args, **kwargs)

# Initialize class with provided motor arguments
self.h_positive_motor = h_positive_motor
self.h_negative_motor = h_negative_motor
self.v_positive_motor = v_positive_motor
self.v_negative_motor = v_negative_motor

# Horizontal and vertical slits components, passing motor names dynamically
h = FCpt(
ID8Optics2Slit1D,
"{prefix}",
secondary_prefix="{secondary_prefix}",
positive_motor="{h_positive_motor}",
negative_motor="{h_negative_motor}"
)

v = FCpt(
ID8Optics2Slit1D,
"{prefix}",
secondary_prefix="{secondary_prefix}",
positive_motor="{v_positive_motor}",
negative_motor="{v_negative_motor}"
)



# sl4 = ID8Optics2Slit2D_HV("8iddSoft:Slit1", name="sl4")
sl5 = ID8Optics2Slit2D_HV(prefix = "8ideSoft:Slit1", secondary_prefix = "8idiSoft:CR8-E2", h_positive_motor = "m4", h_negative_motor = "m3", v_positive_motor = "m2", v_negative_motor = "m1", ,name="sl5")
# sl7 = ID8Optics2Slit2D_HV("8ideSoft:Slit2", name="sl7")
# sl8 = ID8Optics2Slit2D_HV("8idiSoft:Slit1", name="sl8")
sl9 = ID8Optics2Slit2D_HV(prefix = "8idiSoft:Slit2", secondary_prefix = "8ideSoft:CR8-I2", h_positive_motor = "m12", h_negative_motor = "m11", v_positive_motor = "m10", v_negative_motor = "m9", name="sl9")
# Instantiate slits
sl5 = ID8Optics2Slit2D_HV(
prefix="8ideSoft:Slit1",
secondary_prefix="8idiSoft:CR8-E2:",
h_positive_motor="m4",
h_negative_motor="m3",
v_positive_motor="m2",
v_negative_motor="m1",
name="sl5",
)

sl9 = ID8Optics2Slit2D_HV(
prefix="8idiSoft:Slit2",
secondary_prefix="8ideSoft:CR8-I2:",
h_positive_motor="m12",
h_negative_motor="m11",
v_positive_motor="m10",
v_negative_motor="m9",
name="sl9",
)

0 comments on commit 210b431

Please sign in to comment.