Exemple #1
0
    def __init__(self,
        pvname_setvalue, pvname_readback=None, pvname_stop=None, pvname_done_moving=None, pvname_moving=None, 
        accuracy=None, active_move=False, process_time=0, wait_time=0.1, timeout=60, 
        ID=None, name=None, units=None, internal=False
    ):
        pv_setvalue = PV(pvname_setvalue)
        pv_readback = PV(pvname_readback) if pvname_readback else pv_setvalue

        ID = ID or pvname_readback or pvname_setvalue
        super().__init__(ID, name=name, units=units, internal=internal)

        self.accuracy = accuracy
        self.active_move = active_move
        self.process_time = process_time
        self.wait_time = wait_time
        self.timeout = timeout

        self.pvnames = SimpleNamespace(
            setvalue = pvname_setvalue,
            readback = pvname_readback
        )

        self.pvs = SimpleNamespace(
            setvalue = pv_setvalue,
            readback = pv_readback
        )

        #TODO: skip optional PVs or set them to None?

        if pvname_stop:
            pv_stop = PV(pvname_stop)
            self.pvnames.stop = pvname_stop
            self.pvs.stop = pv_stop

        self._pcm = make_pcm(pvname_done_moving, pvname_moving)
Exemple #2
0
    def __init__(self, ID, name=None):
        self.wait_time = 0.1

        pvname_setvalue = "SAROP11-ARAMIS:ENERGY_SP"
        pvname_readback = "SAROP11-ARAMIS:ENERGY"
        pvname_moving = "SAROP11-ODCM105:MOVING"
        pvname_stop = "SAROP11-ODCM105:STOP.PROC"

        pv_setvalue = PV(pvname_setvalue)
        pv_readback = PV(pvname_readback)
        pv_moving = PV(pvname_moving)
        pv_stop = PV(pvname_stop)

        units = pv_readback.units
        super().__init__(ID, name=name, units=units)

        self.pvnames = SimpleNamespace(setvalue=pvname_setvalue,
                                       readback=pvname_readback,
                                       moving=pvname_moving,
                                       stop=pvname_stop)

        self.pvs = SimpleNamespace(setvalue=pv_setvalue,
                                   readback=pv_readback,
                                   moving=pv_moving,
                                   stop=pv_stop)
Exemple #3
0
    def __init__(self, ID, name=None):
        self.wait_time = 0.1

        pvname_setvalue = "SAROP11-ARAMIS:ENERGY_SP"
        pvname_readback = "SAROP11-ARAMIS:ENERGY"
        #        pvname_moving   = "SGE-OP2E-ARAMIS:MOVING" #TODO: this seems broken?
        pvname_moving = "SAROP11-ODCM105:MOVING"
        pvname_coupling = "SGE-OP2E-ARAMIS:MODE_SP"

        pv_setvalue = PV(pvname_setvalue)
        pv_readback = PV(pvname_readback)
        pv_moving = PV(pvname_moving)
        pv_coupling = PV(pvname_coupling)

        units = pv_readback.units
        super().__init__(ID, name=name, units=units)

        self.pvnames = SimpleNamespace(setvalue=pvname_setvalue,
                                       readback=pvname_readback,
                                       moving=pvname_moving,
                                       coupling=pvname_coupling)

        self.pvs = SimpleNamespace(setvalue=pv_setvalue,
                                   readback=pv_readback,
                                   moving=pv_moving,
                                   coupling=pv_coupling)
Exemple #4
0
 def updateE(self, energy=None):
     while not energy:
         energy = PV("SARUN03-UIND030:FELPHOTENE").value
         energy = energy * 1000
         if energy < self.E_min:
             energy = None
             print(f"Machine photon energy is below {self.E_min} - waiting for the machine to recover")
             sleep(self._sleeptime)
     PV(self.ID + ":ENERGY").put(energy)
     print("Set energy to %s eV" % energy)
Exemple #5
0
    def __init__(self,
                 ID,
                 z_undulator=None,
                 description=None,
                 name="Attenuator Aramis"):
        self.sleeptime = 5

        super().__init__(ID, name=name, units=None)

        self._pv_status_str = PV(ID + ":MOT2TRANS.VALD")
        self._pv_status_int = PV(ID + ":IDX_RB")
Exemple #6
0
 def __init__(self,
              ID,
              val="SARCL02-MBND100:P-SET",
              rb="SARCL02-MBND100:P-READ",
              dmov="SFB_BEAM_ENERGY_ECOL:SUM-ERROR-OK"):
     self.ID = ID
     self.setter = PV(val)
     self.readback = PV(rb)
     self.dmov = PV(dmov)
     self.done = False
     self.wait_time = 0.01
     self.accuracy = 2
Exemple #7
0
 def set_calibration_values_position(self, xcalib, ycalib):
     channels = [
         "SLAAR21-LTIM01-EVR0:CALCX.INPJ", "SLAAR21-LTIM01-EVR0:CALCX.INPI"
     ]
     # txcalib = [-1*xcalib[0],-1*xcalib[1]]
     for tc, tv in zip(channels, xcalib):
         PV(tc).put(bytes(str(tv), "utf8"))
     channels = [
         "SLAAR21-LTIM01-EVR0:CALCY.INPJ", "SLAAR21-LTIM01-EVR0:CALCY.INPI"
     ]
     for tc, tv in zip(channels, ycalib):
         PV(tc).put(bytes(str(tv), "utf8"))
Exemple #8
0
    def __init__(self, pvname_readback, pvname_setvalue, pvname_offset, base_folder): #TODO make offset optional?
        self.pvname = pvname = pvname_readback
        super().__init__(base_folder, pvname)

        self.pvnames = SimpleNamespace(
            setvalue = pvname_setvalue,
            readback = pvname_readback,
            offset   = pvname_offset
        )

        self.pvs = SimpleNamespace(
            setvalue = PV(pvname_setvalue),
            readback = PV(pvname_readback),
            offset   = PV(pvname_offset)
        )
Exemple #9
0
    def __init__(self, ID, E_min=1500, sleeptime=1, name=None, limits=[-52, 2], pulse_picker=None):
        self.ID = ID
        self._pv_status_str = PV(ID + ":MOT2TRANS.VALD")
        self._pv_status_int = PV(ID + ":IDX_RB")
        self.E_min = E_min
        self._sleeptime = sleeptime
        self.name = name
        self.alias = Alias(name)
        self.pulse_picker = pulse_picker

        self.motors = [Motor(f"{self.ID}:MOTOR_{n+1}", name=f"motor{n+1}") for n in range(6)]
        for n, mot in enumerate(self.motors):
            self.__dict__[f"motor_{n+1}"] = mot
            self.alias.append(mot.alias)
            if limits:
                mot.set_epics_limits(*limits)
    def __init__(self, ID, z_undulator=None, description=None):
        self.ID = ID

        # Vacuum PVs for Prime chamber
        self.spectrometerP = PV(ID + "MFR125-600:PRESSURE")
        self.intermediateP = PV(ID + "MCP125-510:PRESSURE")
        self.sampleP = PV(ID + "MCP125-410:PRESSURE")
        self.pDiff = PV("SARES11-EVSP-010:DIFFERENT")
        self.regulationStatus = PV("SARES11-EVGA-STM010:ACTIV_MODE")
        self.spectrometerTurbo = PV(ID + "PTM125-600:HZ")
        self.intermediateTurbo = PV(ID + "PTM125-500:HZ")
        self.sampleTurbo = PV(ID + "PTM125-400:HZ")
        self.KBvalve = PV(ID + "VPG124-230:PLC_OPEN")
 def __init__(self, ID, elog=None):
     self.ID = ID
     self.gain = EnumWrapper(ID + "-WD-gain")
     self._bias = PV(ID + "-HV_SET")
     self.channels = [
         ID + "-BG-DATA", ID + "-BG-DRS_TC", ID + "-BG-PULSEID-valid",
         ID + "-DATA", ID + "-DRS_TC", ID + "-PULSEID-valid"
     ]
Exemple #12
0
 def set_calibration_values(self, norm_diodes):
     #this is now only for bernina when using the ioxos from sla
     channels = [
         "SLAAR21-LTIM01-EVR0:CALCI.INPG", "SLAAR21-LTIM01-EVR0:CALCI.INPH",
         "SLAAR21-LTIM01-EVR0:CALCI.INPF", "SLAAR21-LTIM01-EVR0:CALCI.INPE"
     ]
     for tc, tv in zip(channels, norm_diodes):
         PV(tc).put(bytes(str(tv), "utf8"))
     channels = [
         "SLAAR21-LTIM01-EVR0:CALCX.INPE", "SLAAR21-LTIM01-EVR0:CALCX.INPF"
     ]
     for tc, tv in zip(channels, norm_diodes[2:4]):
         PV(tc).put(bytes(str(tv), "utf8"))
     channels = [
         "SLAAR21-LTIM01-EVR0:CALCY.INPE", "SLAAR21-LTIM01-EVR0:CALCY.INPF"
     ]
     for tc, tv in zip(channels, norm_diodes[0:2]):
         PV(tc).put(bytes(str(tv), "utf8"))
Exemple #13
0
    def __init__(self, ID, name=None, units=None, internal=False):
        super().__init__(ID, name=name, units=units, internal=internal)

        self.wait_time = 0.1
        self.timeout = 60
        self._move_requested = False

        self.pvs = SimpleNamespace(
            drive    = PV(ID + ":DRIVE"),
            readback = PV(ID + ":MOTRBV"),
            hlm      = PV(ID + ":HLM"),
            llm      = PV(ID + ":LLM"),
            status   = PV(ID + ":STATUS"),
            set_pos  = PV(ID + ":SET_POS"),
            stop     = PV(ID + ":STOP.PROC"),
            hold     = PV(ID + ":HOLD"),
            twv      = PV(ID + ":TWV"),
            units    = PV(ID + ":DRIVE.EGU")
        )
    def __init__(self, pvname, inverted=False):
        self.pvname = pvname
        self.inverted = inverted

        self.is_changing = None
        self.state = None
        self._cb_index = None

        self.pv = PV(pvname)
        self._update()
Exemple #15
0
def epics_to_h5_polling(filename, channels, n_pulses=100, wait_time=0.5):
    pvs = [PV(ch) for ch in channels]

    arrays = make_arrays(pvs, n_pulses)

    for ivalue in range(n_pulses):
        #TODO: What is the overhead here? Minimal wait_time? Run read out in thread(s)?
        for ichannel, pv in enumerate(pvs):
            arrays[ichannel][ivalue] = pv.value
        sleep(wait_time)

    write_to_h5(filename, channels, arrays)
    def __init__(self,
                 ID,
                 alias_namespace=None,
                 z_undulator=None,
                 description=None):
        self.ID = ID

        ### ADC optical table ###
        self.x1 = Motor(ID + ":MOTOR_X1")
        self.y1 = Motor(ID + ":MOTOR_Y1")
        self.y2 = Motor(ID + ":MOTOR_Y2")
        self.y3 = Motor(ID + ":MOTOR_Y3")
        self.z1 = Motor(ID + ":MOTOR_Z1")
        self.z2 = Motor(ID + ":MOTOR_Z2")
        self.x = Motor(ID + ":W_X")
        self.y = Motor(ID + ":W_Y")
        self.z = Motor(ID + ":W_Z")
        self.pitch = Motor(ID + ":W_RX")
        self.yaw = Motor(ID + ":W_RY")
        self.roll = Motor(ID + ":W_RZ")
        self.modeSP = PV(ID + ":MODE_SP")
        self.status = PV(ID + ":SS_STATUS")
Exemple #17
0
    def __init__(self, pv_basename, base_folder, dial_max=14.0056e-9, tolerance=100e-15):
        self.pv_basename = pv_basename
        self.dial_max = dial_max
        self.tolerance = tolerance

        pvname = pv_basename + ":CURR_DELTA_T" #TODO: should this be the basename only? actually Storage stores the offset!
        super().__init__(base_folder, pvname)

        pvname_setvalue = pv_basename + ":NEW_DELTA_T"
        pvname_readback = pv_basename + ":CURR_DELTA_T"
        pvname_execute  = pv_basename + ":SET_NEW_PHASE.PROC"

        self.pvnames = SimpleNamespace(
            setvalue = pvname_setvalue,
            readback = pvname_readback,
            execute  = pvname_execute
        )

        self.pvs = SimpleNamespace(
            setvalue = PV(pvname_setvalue),
            readback = PV(pvname_readback),
            execute  = PV(pvname_execute)
        )
Exemple #18
0
    def __init__(
        self,
        ID,
        pvname_setvalue="SLAAR01-LTIM-PDLY:DELAY",
        pvname_readback="SLAAR-LGEN:DLY_OFFS1",
        pvname_waiting="SLAAR01-LTIM-PDLY:WAITING",
        name="Globi Laser Electronic Timing",
        units="ps"
    ):
        self.wait_time = 0.01

        super().__init__(ID, name=name, units=units)

        self.pvnames = SimpleNamespace(
            setvalue = pvname_setvalue,
            readback = pvname_readback,
            waiting  = pvname_waiting
        )

        self.pvs = SimpleNamespace(
            setvalue = PV(pvname_setvalue),
            readback = PV(pvname_readback),
            waiting  = PV(pvname_waiting)
        )
Exemple #19
0
def epics_to_h5_triggered(filename, channels, n_pulses=100, wait_time=0.5):
    pvs = [PV(ch) for ch in channels]

    n_channels = len(channels)
    counters = np.zeros(n_channels, dtype=int)

    arrays = make_arrays(pvs, n_pulses)

    def on_value_change(pv=None, ichannel=None, value=None, **kwargs):
        ivalue = counters[ichannel]
        arrays[ichannel][ivalue] = value

        counters[ichannel] += 1

        if counters[ichannel] == n_pulses:
            pv.clear_callbacks()

    for i, pv in enumerate(pvs):
        pv.add_callback(callback=on_value_change, pv=pv, ichannel=i)

    while not np.all(counters == n_pulses):
        sleep(wait_time)

    write_to_h5(filename, channels, arrays)
Exemple #20
0
    def __init__(self,
                 ID="CDCMEWTC",
                 name="Alvra DCM coupled to FEL energy with time correction",
                 limit_low=None,
                 limit_high=None):
        self.wait_time = 0.1

        self.limit_low = limit_low
        self.limit_high = limit_high

        pvname_setvalue = "SAROP11-ARAMIS:ENERGY_SP"  #_USER" #TODO: where did the _USER go?
        pvname_readback = "SAROP11-ARAMIS:ENERGY"
        #        pvname_moving   = "SGE-OP2E-ARAMIS:MOVING"
        pvname_moving = "SAROP11-ODCM105:MOVING"
        pvname_coupling = "SGE-OP2E-ARAMIS:MODE_SP"

        pv_setvalue = PV(pvname_setvalue)
        pv_readback = PV(pvname_readback)
        pv_moving = PV(pvname_moving)
        pv_coupling = PV(pvname_coupling)

        self.timing = Motor("SLAAR11-LMOT-M452:MOTOR_1")
        self.electron_energy_rb = PV("SARCL02-MBND100:P-READ")
        self.electron_energy_sv = PV("SGE-OP2E-ARAMIS:E_ENERGY_SP")

        units = pv_readback.units
        super().__init__(ID, name=name, units=units)

        self.pvnames = SimpleNamespace(setvalue=pvname_setvalue,
                                       readback=pvname_readback,
                                       moving=pvname_moving,
                                       coupling=pvname_coupling)

        self.pvs = SimpleNamespace(setvalue=pv_setvalue,
                                   readback=pv_readback,
                                   moving=pv_moving,
                                   coupling=pv_coupling)
 def __init__(self, ID, name=None):
     self.ID = ID
     self._pv = PV(ID)
     self.name = name
     self.alias = Alias(self.name, channel=self.ID, channeltype="CA")
Exemple #22
0
 def set_transmission(self, value, energy=None):
     self.updateE(energy)
     PV(self.ID + ":3RD_HARM_SP").put(0)
     PV(self.ID + ":TRANS_SP").put(value)
Exemple #23
0
 def __init__(self, channel, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.channel = channel
     self.pv = PV(channel)
Exemple #24
0
 def set_transmission_third_harmonic(self, value, energy=None):
     self.updateE(energy)
     PV(self.ID + ":3RD_HARM_SP").put(1)
     PV(self.ID + ":TRANS_SP").put(value)
Exemple #25
0
 def __init__(self, pvname, elog=None):
     self._elog = elog
     self._pv = PV(pvname)
 def _get_pv(self, pvname):
     if not pvname in self._pvs:
         self._pvs[pvname] = PV(pvname)
     return self._pvs[pvname]
Exemple #27
0
 def get_transmission(self, verbose=True):
     tFun = PV(self.ID + ":TRANS_RB").value
     tTHG = PV(self.ID + ":TRANS3EDHARM_RB").value
     if verbose:
         print("Transmission Fundamental: %s THG: %s" % (tFun, tTHG))
     return tFun, tTHG
 def __init__(self, ID, z_undulator=None, description=None):
     self.ID = ID
     self.targetY = Motor(ID + ":MOTOR_PROBE")
     self.cam = CameraCA(ID)
     self._led = PV(self.ID + ":LED")
     self.target = EnumWrapper(self.ID + ":PROBE_SP")
Exemple #29
0
 def __init__(self, pvname, name=None, elog=None):
     self.name = name
     self.pvname = pvname
     self._pv = PV(pvname)
     self._elog = elog
Exemple #30
0
 def updateE(self, energy=None):
     if energy == None:
         energy = PV("SARUN03-UIND030:FELPHOTENE").value
         energy = energy * 1000
     PV(self.ID + ":ENERGY").put(energy)
     print("Set energy to %s eV" % energy)