Beispiel #1
0
 def __init__(self, block, unit):
     blocks = g.get_blocks()
     if block not in blocks:
         new_name = [
             name for name in blocks
             if name and name.lower() == block.lower()
         ]
         if new_name:
             block = new_name[0]
         else:
             raise RuntimeError("Unknown block {}.".format(block))
     Motion.__init__(
         self,
         lambda: g.cget(block)["value"],
         lambda x: g.cset(block, x),
         block,
         unit=unit,
         # Workarounds until a better solution to get fields
         # from blocks is implemented in IBEX. Note that IBEX
         # blocks must point at AXIS:MTR rather than AXIS for
         # this to work.
         velocity_getter=lambda: g.get_pv("CS:SB:{}.VELO".format(block),
                                          is_local=True),
         velocity_setter=lambda vel: g.set_pv(
             "CS:SB:{}.VELO".format(block), vel, is_local=True),
         tolerance_getter=lambda: g.get_pv("CS:SB:{}.RDBD".format(block),
                                           is_local=True),
     )
Beispiel #2
0
def get_block(name):
    """
    A simple wrapper around g.cget to give a better exception message.
    """
    try:
        return g.cget(name)["value"]
    except AttributeError:
        raise ValueError("Could not get block '{}'".format(name))
Beispiel #3
0
 def run(self, temperature=1.0, field=1.0, mevents=10, magnet_device="N/A"):
     import inst
     # Don't set temp if the user has specified keep
     if temperature is not None:
         inst.settemp(temperature, wait=True)
     # Don't set field if the user has specified keep
     if field is not None:
         # Select a magnet to set the field with
         if g.cget("a_selected_magnet")["value"] != magnet_device:
             magnet_to_function_map = {"Active ZF": inst.f0, "Danfysik": inst.lf0, "T20 Coils": inst.tf0}
             magnet_to_function_map[magnet_device]()
         inst.setmag(field, wait=True)
     # Do the run for this action
     self.begin_waitfor_mevents_end(mevents)
    def set_magnet_device(self, magnet_device, inst):
        """
        Use the instrument scripts to set the magnet device, given a string.

        Parameters:
          magnet_device (str): The string representation of the magnet device to select.
          inst (module): The instrument scripts module to set the magnet device with.
        """
        magnet_to_function_map = {
            "Active ZF": inst.f0,
            "Danfysik": inst.lf0,
            "T20 Coils": inst.tf0
        }
        if g.cget("a_selected_magnet")["value"] != magnet_device:
            magnet_to_function_map[magnet_device]()