예제 #1
0
    def initiate_elogbook(self):
        """
        Initialisation of the elogbook module. 

        Note that due to a bug of elogbook, each time a check of its functionality is performed via logging to logbook "TESTS".
        
        """

        assert self.which_ebook in ['LINAC 3','TESTS'], 'Wrong choice of logbook. Choose between "LINAC 3" and "TESTS"'

        def elog_checker():
            
            elog_temp=pylogbook.eLogbook('TESTS')

            try:

                elog_temp.create_event('Testing elogbook functionality.')

            except:

                self.no_elog_write=True

                msg=('Cannot push events to '+self.which_ebook+' logbook. ' + 
                    ' Failed to initiate PyLogbook module. Reverting to local logging only.')
                self.write_L3_log(msg=msg,where='logfile',logfile_lvl='info')


        elog_checker()

        elog=pylogbook.eLogbook(self.which_ebook)

        self.elog=elog
예제 #2
0
        def elog_checker():
            
            elog_temp=pylogbook.eLogbook('TESTS')

            try:

                elog_temp.create_event('Testing elogbook functionality.')

            except:

                self.no_elog_write=True

                msg=('Cannot push events to '+self.which_ebook+' logbook. ' + 
                    ' Failed to initiate PyLogbook module. Reverting to local logging only.')
                self.write_L3_log(msg=msg,where='logfile',logfile_lvl='info')
def quadrupole_turn_on(current):
    """ 
    This function turns on the UCL AWAKE Spectrometer dipole to the settings 
    given by the input arguments.
    
    Arguments:
        
        - current           This is the value of the current that the quadrupole 
                            should be set to. It is measured in Amps [A].
                    
                            
    """

    # Check whether PC mode is off

    print("Turning on quadrupole to current {}A.\n".format(current))
    print("Checking PC state...")

    pc_status = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

    if pc_status['PC'] != 'OFF':

        japc.setParam('RPADA.BB4.RQNI.412432/MODE.PC', 'OFF')

        print("PC was in state: {}".format(pc_status['PC']))
        print("Turning PC off.")

        # Wait a few seconds to allow PC to switch off
        sleep(10)

        updated_status = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

        print("PC is now in state: {}\n".format(updated_status['PC']))
        print("Beginning quadrupole turn on procedure...\n")

    else:

        print("PC already in state: {}\n".format(pc_status['PC']))
        print("Beginning quadrupole turn on procedure...\n")

    # Update PC modes and check in correct state

    print("Updating PC modes...")

    japc.setParam('RPADA.BB4.RQNI.412432/MODE.PC', 'ON_STANDBY')
    sleep(10)
    japc.setParam('RPADA.BB4.RQNI.412432/MODE.PC', 'IDLE')

    pc_status = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

    print("PC in state: {}\n".format(pc_status['PC']))

    # Set the trim settings for duration and final according to the input
    # arguments specified.

    sleep(5)

    current_set = float(current)

    print("Setting magnet PLEP settings to:")
    print("Current = {}A\n".format(current_set))

    # This stores the variable somewhere the event builder can find it and prints to e-log
    var_vec = japc.getParam(
        'TSG41.AWAKE-GUI-SUPPORT/ValueAcquisition#floatValue')
    var_vec[67] = current_set
    japc.setParam('TSG41.AWAKE-GUI-SUPPORT/ValueSettings#floatValue', var_vec)
    elog = pylogbook.eLogbook("AWAKE")
    entry = elog.create_event("Spectrometer Qaudrupole set to " +
                              "{:0.2f}".format(current_set) + " Amps")

    japc.setParam('RPADA.BB4.RQNI.412432/REF.PLEP.FINAL', current_set)

    sleep(3)

    check_current = japc.getParam('RPADA.BB4.RQNI.412432/REF.PLEP.FINAL')

    print("Magnet settings have been set to:")
    print("Current = {}A".format(check_current))

    # Finding _non_multiplexed_sps context

    print("Setting function type...")

    japc.setParam('RPADA.BB4.RQNI.412432/REF.FUNC.TYPE', 'PLEP')
    sleep(1)
    func_type = japc.getParam('RPADA.BB4.RQNI.412432/REF.FUNC.TYPE')

    print("Function type set to: {}\n".format(func_type))

    # PC state should now be 'ARMED'.

    check_state = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

    print("PC State set to: {}\n".format(check_state['PC']))

    if check_state['PC'] == 'ARMED':

        print("Turning on quadrupole...\n")

        japc.setParam('RPADA.BB4.RQNI.412432/REF.RUN', 1.0)

        sleep(1)

        check_run_state = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

        print("PC State: {}".format(check_run_state['PC']))

    else:

        print("PC state not 'ARMED'. Breaking...")
        return 0

    # Wait for ramp duration to check what the current is.

    sleep(3)

    current_test = japc.getParam('RPADA.BB4.RQNI.412432/MEAS.I')

    print("Current is at {}A".format(current_test))
def change_current(current):

    # Change the current without turning on.

    current_set = float(current)

    print("Setting magnet PLEP settings to:")
    print("Current = {}A\n".format(current_set))

    # This stores the variable somewhere the event builder can find it and prints to e-log
    var_vec = japc.getParam(
        'TSG41.AWAKE-GUI-SUPPORT/ValueAcquisition#floatValue')
    var_vec[67] = current_set
    japc.setParam('TSG41.AWAKE-GUI-SUPPORT/ValueSettings#floatValue', var_vec)
    elog = pylogbook.eLogbook("AWAKE")
    entry = elog.create_event("Spectrometer Qaudrupole set to " +
                              "{:0.2f}".format(current_set) + " Amps")

    japc.setParam('RPADA.BB4.RQNI.412432/REF.PLEP.FINAL', current_set)

    sleep(3)

    check_current = japc.getParam('RPADA.BB4.RQNI.412432/REF.PLEP.FINAL')

    print("Magnet settings have been set to:")
    print("Current = {}A".format(check_current))

    # Finding _non_multiplexed_sps context

    print("Setting function type...")

    japc.setParam('RPADA.BB4.RQNI.412432/REF.FUNC.TYPE', 'PLEP')
    sleep(1)
    func_type = japc.getParam('RPADA.BB4.RQNI.412432/REF.FUNC.TYPE')

    print("Function type set to: {}\n".format(func_type))

    # PC state should now be 'ARMED'.

    check_state = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

    print("PC State set to: {}\n".format(check_state['PC']))

    if check_state['PC'] == 'ARMED':

        print("Turning on quadrupole...\n")

        japc.setParam('RPADA.BB4.RQNI.412432/REF.RUN', 1.0)

        sleep(1)

        check_run_state = japc.getParam('RPADA.BB4.RQNI.412432/STATE')

        print("PC State: {}".format(check_run_state['PC']))

    else:

        print("PC state not 'ARMED'. Breaking...")
        return 0

    # Wait for ramp duration to check what the current is.

    sleep(3)

    current_test = japc.getParam('RPADA.BB4.RQNI.412432/MEAS.I')

    print("Current is at {}A".format(current_test))
예제 #5
0
def change_current(current):

    pc_status = japc.getParam('RPPEF.BB4.RBIH.412435/STATE')

    print("PC in state: {}\n".format(pc_status['PC']))

    # Finding _non_multiplexed_sps context

    print("Setting function type...")

    japc.setParam('RPPEF.BB4.RBIH.412435/REF.FUNC.TYPE', 'CTRIM')
    sleep(1)
    func_type = japc.getParam('RPPEF.BB4.RBIH.412435/REF.FUNC.TYPE')

    print("Function type set to: {}\n".format(func_type))

    # Set the trim settings for duration and final according to the input
    # arguments specified.

    current_set = float(current)
    ramp_duration_set = float(ramp_duration)

    print("Setting magnet trim settings to:")
    print("Current = {}A".format(current_set))
    print("Ramp Duration = {}s\n".format(ramp_duration_set))

    # This stores the variable somewhere the event builder can find it and prints to e-log
    var_vec = japc.getParam(
        'TSG41.AWAKE-GUI-SUPPORT/ValueAcquisition#floatValue')
    var_vec[68] = current_set
    japc.setParam('TSG41.AWAKE-GUI-SUPPORT/ValueSettings#floatValue', var_vec)
    elog = pylogbook.eLogbook("AWAKE")
    entry = elog.create_event("Spectrometer Dipole set to " +
                              "{:0.2f}".format(current_set) + " Amps")

    japc.setParam('RPPEF.BB4.RBIH.412435/REF.TRIM.DURATION', ramp_duration_set)
    japc.setParam('RPPEF.BB4.RBIH.412435/REF.TRIM.FINAL', current_set)

    sleep(3)

    check_current = japc.getParam('RPPEF.BB4.RBIH.412435/REF.TRIM.FINAL')
    check_ramp = japc.getParam('RPPEF.BB4.RBIH.412435/REF.TRIM.DURATION')

    print("Magnet settings have been set to:")
    print("Current = {}A".format(check_current))
    print("Ramp Duration = {}s\n".format(check_ramp))

    # PC state should now be 'ARMED'.

    check_state = japc.getParam('RPPEF.BB4.RBIH.412435/STATE')

    print("PC State set to: {}\n".format(check_state['PC']))

    if check_state['PC'] == 'ARMED':

        print("Turning on dipole...\n")

        japc.setParam('RPPEF.BB4.RBIH.412435/REF.RUN', 1.0)

        sleep(1)

        check_run_state = japc.getParam('RPPEF.BB4.RBIH.412435/STATE')

        print("PC State: {}".format(check_run_state['PC']))

    else:

        print("PC state not 'ARMED'. Breaking...")
        return 0

    # Wait for ramp duration to check what the current is.

    sleep(ramp_duration_set)

    current_test = japc.getParam('RPPEF.BB4.RBIH.412435/MEAS.I')

    print("Current is at {}A".format(current_test))