Skip to content

Sim Transfocator

sim_transfocator

Attributes

FakeTransfocator module-attribute

FakeTransfocator = make_fake_device(Transfocator)

Classes

SimLens

SimLens(prefix, **kwargs)

Bases: MFXLens

Source code in tfs/lens.py
def __init__(self, prefix, **kwargs):
    # Only assign X/Y motor PVs for true TFS lenses of the form ":TFS:##"
    # Prefocus lenses (":DIA:##") should not use the TFS X/Y motor map.
    m = re.search(r":(TFS|DIA):(\d+)$", prefix)
    if m and m.group(1) == 'TFS':
        lens_num = int(m.group(2))
        try:
            mapping = LENS_MOTOR_PVS[lens_num]
        except KeyError:
            raise ValueError(f"Unknown TFS lens number {lens_num} parsed from prefix {prefix}")
        self.x_pv = mapping['x']
        self.y_pv = mapping['y']
    else:
        # For DIA or any non-matching suffix, do not configure X/Y PVs
        self.x_pv = None
        self.y_pv = None
    super().__init__(prefix, **kwargs)

SimTransfocator

Bases: FakeTransfocator

Attributes
prefocus_bot class-attribute instance-attribute
prefocus_bot = Component(SimLens, ':DIA:01')
prefocus_mid class-attribute instance-attribute
prefocus_mid = Component(SimLens, ':DIA:02')
prefocus_top class-attribute instance-attribute
prefocus_top = Component(SimLens, ':DIA:03')
tfs_02 class-attribute instance-attribute
tfs_02 = Component(SimLens, ':TFS:02')
tfs_03 class-attribute instance-attribute
tfs_03 = Component(SimLens, ':TFS:03')
tfs_04 class-attribute instance-attribute
tfs_04 = Component(SimLens, ':TFS:04')
tfs_05 class-attribute instance-attribute
tfs_05 = Component(SimLens, ':TFS:05')
tfs_06 class-attribute instance-attribute
tfs_06 = Component(SimLens, ':TFS:06')
tfs_07 class-attribute instance-attribute
tfs_07 = Component(SimLens, ':TFS:07')
tfs_08 class-attribute instance-attribute
tfs_08 = Component(SimLens, ':TFS:08')
tfs_09 class-attribute instance-attribute
tfs_09 = Component(SimLens, ':TFS:09')
tfs_10 class-attribute instance-attribute
tfs_10 = Component(SimLens, ':TFS:10')

Stage

Bases: SynAxis

Functions
attach
attach(tfs_dev)
Source code in tfs/sim_transfocator.py
def attach(self, tfs_dev):
    self._lenses = [
        getattr(tfs_dev, nm)
        for nm in tfs_dev.component_names
        if isinstance(getattr(tfs_dev, nm), SimLens)
    ]
mv
mv(value)
Source code in tfs/sim_transfocator.py
def mv(self, value):
    delta = (value - self.position) / 1000 # lenses z are in m.
    st = self.set(value); st.wait()
    for l in getattr(self, "_lenses", []):
        l._sig_z.set(l._sig_z.get() + delta).wait()
    return st

Functions

make_tfs_sim

make_tfs_sim(tfs, prefix='SIM:', name='tfs_sim')
Source code in tfs/sim_transfocator.py
def make_tfs_sim(tfs, prefix="SIM:", name="tfs_sim"):
    stage = Stage(name="stage")
    stage.set(tfs.translation.position).wait()
    stage.high_limit = tfs.translation.high_limit
    stage.low_limit  = tfs.translation.low_limit

    def _translation(self):
        return stage
    SimTransfocator.translation = property(_translation)

    tfs_sim = SimTransfocator(prefix=prefix, name=name)
    stage.attach(tfs_sim)

    for i in range(2, 10):
        real, sim = getattr(tfs, f"tfs_0{i}"), getattr(tfs_sim, f"tfs_0{i}")
        sim._sig_z.set(float(real.z)).wait()
        sim._sig_radius.set(float(real.radius)).wait()

    real, sim = getattr(tfs, "tfs_10"), getattr(tfs_sim, "tfs_10")
    sim._sig_z.set(float(real.z)).wait()
    sim._sig_radius.set(float(real.radius)).wait()

    for nm in ("prefocus_bot", "prefocus_mid", "prefocus_top"):
        real, sim = getattr(tfs, nm), getattr(tfs_sim, nm)
        sim._sig_z.set(float(real.z)).wait()
        sim._sig_radius.set(float(real.radius)).wait()

    return tfs_sim