Example #1
0
def set_to_safe_state(iDevIdx, iSlotID):
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)	# turn the laser soft-lock on 
    sepiaUser.set_laser_intensity(0, iDevIdx)       # set the laser intensity to 0%
    sepiaUser.set_laser_frequency(6, iDevIdx) 		# set the laser to trigger on the rising edge of an external pulse
    rs.SetSelectedChannel(0)			            # set the laserSwitch to channel 0 (default channel)
    sepiaUser.close(iDevIdx)
    rs.Execute()                                    # execute the laserSwitch channel change
Example #2
0
def main():	
        print "\n"
        print "Simple TCP/IP Run (Main) - Starting SMELLIE RUN..."
        #Perform a clean open and close of the Sepia Laser Driver before talking to ORCA. 
        #iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
        #sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
        #rs.SetSelectedChannel(0)
        #sepiaUser.close(iDevIdx)

        myHost = ''                          # initialise the server machine ('' means: local host)
        myPort = 50006                                  # listen on a non-reserved port number

        conn.sockobj = conn.socket(conn.AF_INET, conn.SOCK_STREAM)       # make a TCP/IP socket object
        conn.sockobj.settimeout(None)                                    # No timeout on the socket
        conn.sockobj.setsockopt(conn.SOL_SOCKET,conn.SO_REUSEADDR,1)
        conn.sockobj.bind((myHost, myPort))                              # bind the socket object to the specified server and port number 
        conn.sockobj.listen(5)                                           # begin listening, and allow 5 pending connects

        # Check for connection confimation from ORCA
        print "Simple TCP/IP Run (Main) - Checking for connection confimation from ORCA ... "	
        while 1:                                                        # listen until process killed
                connection, address = conn.sockobj.accept()             # wait for next client connection
                print 'Connection made to:' + str(address)              # connection is a new socket
                if address : break		
        connection.send(check_connection_flag)                          # send signal to ORCA  to check connection


        print "Simple TCP/IP Run (Main) - Waiting for run parameters from ORCA ... "
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
        ORCA_set_ls_channel(connection, iDevIdx)
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()        # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of ORCA_set_ls_channel)
        #ORCA_set_laser_parameters(connection)
        #complete_self_test(connection, iDevIdx, iSlotID)
        sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
def test_run(ls_channel, fs_input_channel, logfile, iDevIdx, iModuleType, iSlotID):
    
    print "Installation Testing (Test Run) - Testing Laser Switch Channel: " + str(ls_channel)
    set_laser_switch_channel(ls_channel)
    sepiaUser.set_laser_intensity(100, iDevIdx) # set the intensity to 100%
    #sepiaUser.set_laser_frequency(4, iDevIdx) # this is the internal 5MHz trigger frequency ... use to check if Sepia is working properly
    
    for fs_output_channel in range(1, 15):

        channel_number = ((fs_input_channel - 1) * 14) + fs_output_channel
        fs.SetFSChannel(channel_number) # set the fibreSwitch channel
        sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID) # unlock the laser
        time.sleep(1)

        # this section of code is for generating a pulse via the NI Box, and reading the PMT value
        trigger_frequency = 10000
        number_of_pulses = 100000
        digi_trig = ni.GenerateDigitalTrigger(trigger_frequency, number_of_pulses)
        read_signal = ni.AcquireAnalogue()
        number_of_measurements = 1
        voltage_signal = str(read_signal.start(number_of_measurements))
        digi_trig.start()
        digi_trig.stop()
        read_signal = ni.AcquireAnalogue()
        a = raw_input("Generating pulse train ... press Enter to interrupt ...\n")
        read_signal.stop()

        logfile.write(str(ls_channel) + '\t' + str(channel_number) + '\t' + voltage_signal[1:-1] + '\n')
        
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
Example #4
0
def set_laser_switch_channel(channel):
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    rs.SetSelectedChannel(channel)
    sepiaUser.close(iDevIdx)
    rs.Execute()                                    
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
Example #5
0
def set_safe_states(iDevIdx, iSlotID):
	sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)   # turn the laser soft-lock on
	sepiaUser.set_laser_intensity(0, iDevIdx)        # set the laser intensity to 0%
	sepiaUser.set_laser_frequency(6, iDevIdx) 		 # set the laser frequency to external rising-edge trigger
	rs.SetSelectedChannel(0)			             # set the laserSwitch to channel 0 (default)
	sepiaUser.close(iDevIdx)
	rs.Execute()                                     # execute the laserSwitch channel change from above
Example #6
0
def set_laser_switch_channel(channel):
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    rs.SetSelectedChannel(channel)
    sepiaUser.close(iDevIdx)
    rs.Execute()                                    
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)	
Example #7
0
def set_to_safe_state(iDevIdx, iSlotID):
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)	# turn the laser soft-lock on 
    sepiaUser.set_laser_intensity(0, iDevIdx)       # set the laser intensity to 0%
    sepiaUser.set_laser_frequency(6, iDevIdx) 		# set the laser to trigger on the rising edge of an external pulse
    rs.SetSelectedChannel(0)			            # set the laserSwitch to channel 0 (default channel)
    sepiaUser.close(iDevIdx)
    rs.Execute()                                    # execute the laserSwitch channel change
Example #8
0
def set_safe_states(iDevIdx, iSlotID):
    sepiaUser.laser_soft_lock_on(iDevIdx,
                                 iSlotID)  # turn the laser soft-lock on
    sepiaUser.set_laser_intensity(0, iDevIdx)  # set the laser intensity to 0%
    sepiaUser.set_laser_frequency(
        6, iDevIdx)  # set the laser frequency to external rising-edge trigger
    rs.SetSelectedChannel(0)  # set the laserSwitch to channel 0 (default)
    sepiaUser.close(iDevIdx)
    rs.Execute()  # execute the laserSwitch channel change from above
Example #9
0
def perform_run(connection, number_of_pulses, trigger_frequency, iDevIdx, iSlotID):
# try/except statement didn't work here during testing with SNO+. Need to know why? 
	
	sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)
	digi_trig = ni.GenerateDigitalTrigger(trigger_frequency, number_of_pulses)
	digi_trig.start()
	digi_trig.stop()
	sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
	sepiaUser.close(iDevIdx)
	connection.send(continue_flag)
Example #10
0
def laserSwitchCheckTest():
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
    set_to_safe_state(iDevIdx, iSlotID)
    set_laser_switch_channel(0)
    set_laser_switch_channel(1)
    set_laser_switch_channel(2)
    set_laser_switch_channel(3)
    set_laser_switch_channel(4)
    set_to_safe_state(iDevIdx, iSlotID)
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    sepiaUser.close(iDevIdx)
Example #11
0
def set_soft_lock_on():
    retValue = 0
    try:
        print "Set laser soft lock on"
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialiseSCMModule()
        time.sleep(1.0)
        sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
        time.sleep(1.0)
        sepiaUser.close(iDevIdx)
    except errorCode, Argument:
        retValue = "Error: " + str(errorCode) + "  " + str(Argument)
Example #12
0
def perform_run(connection, number_of_pulses, trigger_frequency, iDevIdx,
                iSlotID):
    # try/except statement didn't work here during testing with SNO+. Need to know why?

    sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)
    digi_trig = ni.GenerateDigitalTrigger(trigger_frequency, number_of_pulses)
    digi_trig.start()
    digi_trig.stop()
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    sepiaUser.close(iDevIdx)
    connection.send(continue_flag)
Example #13
0
def test_run(ls_channel, fs_input_channel, iDevIdx, iModuleType, iSlotID):
    
    print "Installation Testing (Test Run) - Testing Laser Switch Channel: " + str(ls_channel)
    set_laser_switch_channel(ls_channel)
    sepiaUser.set_laser_intensity(100, iDevIdx) # set the intensity to 100%
    sepiaUser.set_laser_frequency(2, iDevIdx) # this is the internal 5MHz trigger frequency ... use to check if Sepia is working properly
    
    for fs_output_channel in range(1, 15):

        channel_number = ((fs_input_channel - 1) * 14) + fs_output_channel
        fs.SetFSChannel(channel_number) # set the fibreSwitch channel
        sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID) # unlock the laser
        time.sleep(10) 
        sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
Example #14
0
def set_safe_states(iDevIdx, iSlotID):
	sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)   # turn the laser soft-lock on
        #print "setting laser intensity safe state"
	sepiaUser.set_laser_intensity(0, iDevIdx)        # set the laser intensity to 0%
        #print "setting laser frequency safe state"
        sepiaUser.set_laser_frequency(6, iDevIdx)        # set the laser frequency to external rising-edge trigger 6 as default
        #print "switching channel safe state"
        rs.SetSelectedChannel(safeLaserSwitchOutput)	 # set the laserSwitch to channel 0 (default)
        #print "initialising laser into safestates"
	sepiaUser.close(iDevIdx)
	#sys.exit("forced exit for testing")
	#time.sleep(10)
	#print "execute and wait"
	rs.Execute()                                     # execute the laserSwitch channel change from above
Example #15
0
def fibreSwitchTesting():
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_to_safe_state(iDevIdx, iSlotID)                       # set all the laser parameters to safe values 	
    
    #timestamp = str(time.time())
    #timestamp = timestamp[0:10]

    
    # initiate test run across ALL laserSwitch channels and ALL fibreSwitch input/output channel combinations
    test_run(1, 1, iDevIdx, iModuleType, iSlotID)
    test_run(2, 2, iDevIdx, iModuleType, iSlotID)
    test_run(2, 3, iDevIdx, iModuleType, iSlotID)
    test_run(4, 4, iDevIdx, iModuleType, iSlotID)
    test_run(5, 5, iDevIdx, iModuleType, iSlotID)
    
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()          # re-initialise Sepia
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    sepiaUser.close(iDevIdx)
    
    time.sleep(1)
Example #16
0
def main():
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_to_safe_state(iDevIdx, iSlotID)                       # set all the laser parameters to safe values 	
    
    timestamp = str(time.time())
    timestamp = timestamp[0:10]

    filename = 'Testing_SMELLIE_at_5MHz_' + timestamp + '.txt' 
    f = open(filename, 'w')
    
    # initiate test run across ALL laserSwitch channels and ALL fibreSwitch input/output channel combinations
    test_run(1, 1, f, iDevIdx, iModuleType, iSlotID)
    test_run(2, 2, f, iDevIdx, iModuleType, iSlotID)
    test_run(3, 3, f, iDevIdx, iModuleType, iSlotID)
    test_run(4, 4, f, iDevIdx, iModuleType, iSlotID)
    test_run(5, 5, f, iDevIdx, iModuleType, iSlotID)
    
    iDevIdx,iModuleType,iSlotID = sepia.initialise()          # re-initialise Sepia
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    sepiaUser.close(iDevIdx)
    
	f.close()
Example #17
0
def setLaserAndFibreSwitch(ls_channel,fs_input_channel,fs_output_channel,time_in_minutes,operation_mode,intensity):
    
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_to_safe_state(iDevIdx, iSlotID)                                     # set all the laser parameters to safe values

    set_laser_switch_channel(ls_channel)
    sepiaUser.set_laser_intensity(intensity, iDevIdx) # set the intensity to 100%
    sepiaUser.set_laser_frequency(operation_mode, iDevIdx) 


    channel_number = ((fs_input_channel - 1) * 14) + fs_output_channel      # pick the correct channel number
    print(channel_number)
    fs.SetFSChannel(channel_number)                                         # set the fibreSwitch channel
    laserTime = time_in_minutes*60.0                                        # time for program to wait before locking the laser (i.e. laser operating time)
    sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)                         # unlock the laser
    time.sleep(laserTime)                                                   # make Python sleep while laser is working 

    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()                    # re-initialise Sepia 
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)                          # soft lock on
    sepiaUser.close(iDevIdx)                                                # close the Sepia box down...
    
    time.sleep(1)
Example #18
0
def check_safe_states(iDevIdx, iSlotID):
	# Get the current states of Sepia and the LaserSwitch
	intensity,frequency_number,pulse_mode,head_id = sepiaUser.get_laser_parameters(iDevIdx)
	ls_channel = rs.GetActiveChannel()
	if (intensity != 0):
		sepiaUser.set_laser_intensity(0, iDevIdx)
		sys.exit('Simple Run (Check Safe States) - The laser Intensity is not at SAFE value (0%)')
	if (frequency_number != 6):
		sepiaUser.set_laser_frequency(6, iDevIdx)
		sys.exit('Simple Run (Check Safe States) - The laser Frequency is not at SAFE value (6 - external rising edge)')
	if (pulse_mode != 1):
		sys.exit('Simple Run (Check Safe States) - The laser Pulse Mode is not set correctly (1 - pulse mode, NOT continuous)')
	if (ls_channel != 0):
		rs.SetSelectedChannel(0)
		rs.Execute()
		sepiaUser.close(iDevIdx)
		sys.exit('Simple Run (Check Safe States) - The Laser Switch safe-state is not correctly set ... aborting run!')
		# Check the laser soft-lock status 	
		lock_check = sepiaUser.get_laser_lock_status(iDevIdx, iSlotID)
		if (laser_lock_on_check != 1):
			sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
			sys.exit('Simple Run (Check Safe States) - Laser Soft-lock is not enabled ... aborting run!')
	return 	
Example #19
0
def cycleFibreSwitch(fs_input_channel,ls_channel):

    operation_mode = 6

    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_to_safe_state(iDevIdx, iSlotID)

    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_laser_switch_channel(ls_channel)

    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()                    # re-initialise Sepia 
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)                          # soft lock on

    sepiaUser.set_laser_frequency(operation_mode, iDevIdx)

    intensity_value = 0

    print "FibreSwitchInput:" + str(fs_input_channel)
    print "LaserChannel:" + str(ls_channel)

    for intensity_iterator in range(0,80):

        intensity_value = 100 - intensity_iterator

        sepiaUser.set_laser_intensity(intensity_value, iDevIdx)
                                                   
        for fs_output_channel in range(7, 13):

            channel_number = ((fs_input_channel - 1) * 14) + fs_output_channel
            print "Intensity Value:" + str(intensity_value) +" FibreSwitchOutput:" + str(fs_output_channel)
            fs.SetFSChannel(channel_number) # set the fibreSwitch channel
            
            sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID) # unlock the laser
            time.sleep(5) 
            sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
            time.sleep(1)
        
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)                          # soft lock on
    sepiaUser.close(iDevIdx)                                                # close the Sepia box down... 
    
    time.sleep(1)
Example #20
0
def main():
    print "\n"
    print "Simple TCP/IP Run (Main) - Starting SMELLIE RUN..."

    #Perform a clean open and close of the Sepia Laser Driver before talking to ORCA.
    iDevIdx, iModuleType, iSlotID = sepiaUser.initialise()
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    rs.SetSelectedChannel(0)
    sepiaUser.close(iDevIdx)

    myHost = ''  # initialise the server machine ('' means: local host)
    myPort = 50007  # listen on a non-reserved port number

    conn.sockobj = conn.socket(conn.AF_INET,
                               conn.SOCK_STREAM)  # make a TCP/IP socket object
    conn.sockobj.settimeout(None)  # No timeout on the socket
    conn.sockobj.bind(
        (myHost, myPort
         ))  # bind the socket object to the specified server and port number
    conn.sockobj.listen(5)  # begin listening, and allow 5 pending connects

    # Check for connection confimation from ORCA
    print "Simple TCP/IP Run (Main) - Checking for connection confimation from ORCA ... "
    while 1:  # listen until process killed
        connection, address = conn.sockobj.accept(
        )  # wait for next client connection
        print 'Connection made to:' + str(
            address)  # connection is a new socket
        if address: break
    connection.send(
        check_connection_flag)  # send signal to ORCA  to check connection

    # Check for SMELLIE initialisation commmand from ORCA
    print "Simple TCP/IP Run (Main) - Looking for SMELLIE initialisation commmand from ORCA ... "
    connection.settimeout(5)  # set a timeout of 5 seconds for receiving data
    try:
        while 1:
            start_init_data = connection.recv(1024)
            if (start_init_data == start_initialise_flag
                ):  # check if initialisation command has been given
                print "Simple TCP/IP Run (Main) - Start initialisation stage of the SMELLIE run"
                break
    except conn.timeout:
        connection.send(timeout_flag)
        main()

    connection.settimeout(None)  # remove timeout for receiving data

    # Initialisation stage
    iDevIdx, iModuleType, iSlotID = sepiaUser.initialise()  # initialise Sepia
    check_sepia_connection(
        iModuleType, connection)  # check that Sepia is working as expected
    check_ls_connection(
        connection)  # check that the laserSwitch is working as expected
    set_safe_states(
        iDevIdx,
        iSlotID)  # sets all the Sepia parameters to their safe state values
    iDevIdx, iModuleType, iSlotID = sepiaUser.initialise(
    )  # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of set_safe_states)
    check_safe_states(
        iDevIdx, iSlotID,
        connection)  # check that all devices are in their safe-states

    print "Simple TCP/IP Run (Main) - Looking for a Confirmation from ORCA to start the SMELLIE run ... "
    connection.settimeout(5)  # set a timeout for receiving data
    try:
        while 1:
            start_run = connection.recv(1024)
            if (start_init_data == start_initialise_flag
                ):  # check if initialisation command has been given
                print "Simple TCP/IP Run (Main) - Ready to start sending run parameters"
                break
    except conn.timeout:
        connection.send(timeout_flag)
        main()

    connection.settimeout(None)  # remove timeout for receiving data

    print "Simple TCP/IP Run (Main) - Waiting for run parameters from ORCA ... "
    ORCA_set_ls_channel(connection, iDevIdx)
    iDevIdx, iModuleType, iSlotID = sepiaUser.initialise(
    )  # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of ORCA_set_ls_channel)
    ORCA_set_laser_parameters(connection)
    complete_self_test(connection, iDevIdx, iSlotID)
    sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
    ORCA_set_fs_channel(connection)
    number_of_pulses = ORCA_ni_get_pulses(
        connection)  # get the number of pulses from the NI box
    trigger_frequency = ORCA_ni_get_trigger_frequency(
        connection)  # get the trigger frequency of the NI box
    perform_run(connection, number_of_pulses, trigger_frequency, iDevIdx,
                iSlotID)  # complete the SMELLIE run

    sys.exit("Simple TCP/IP Run (Main) - good exit")
def main():	
        print "\n"
        print "Simple TCP/IP Run (Main) - Starting SMELLIE RUN..."
        #Perform a clean open and close of the Sepia Laser Driver before talking to ORCA. 
        #iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
        #sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
        #rs.SetSelectedChannel(0)
        #sepiaUser.close(iDevIdx)

        myHost = ''                          # initialise the server machine ('' means: local host)
        myPort = 50007                                  # listen on a non-reserved port number

        conn.sockobj = conn.socket(conn.AF_INET, conn.SOCK_STREAM)       # make a TCP/IP socket object
        conn.sockobj.settimeout(None)                                    # No timeout on the socket
        conn.sockobj.setsockopt(conn.SOL_SOCKET,conn.SO_REUSEADDR,1)
        conn.sockobj.bind((myHost, myPort))                              # bind the socket object to the specified server and port number 
        conn.sockobj.listen(5)                                           # begin listening, and allow 5 pending connects

        # Check for connection confimation from ORCA
        print "Simple TCP/IP Run (Main) - Checking for connection confimation from ORCA ... "	
        while 1:                                                        # listen until process killed
                connection, address = conn.sockobj.accept()             # wait for next client connection
                print 'Connection made to:' + str(address)              # connection is a new socket
                if address : break		
        connection.send(check_connection_flag)                          # send signal to ORCA  to check connection

        # Check for SMELLIE initialisation commmand from ORCA
        print "Simple TCP/IP Run (Main) - Looking for SMELLIE initialisation commmand from ORCA ... "
        connection.settimeout(5)                                    # set a timeout of 5 seconds for receiving data
        try:
                while 1:
                        start_init_data = connection.recv(1024)
                        if (start_init_data == start_initialise_flag):      # check if initialisation command has been given
                                print "Simple TCP/IP Run (Main) - Start initialisation stage of the SMELLIE run"
                                break
        except conn.timeout:
                connection.send(timeout_flag)
                main()

        connection.settimeout(None)                                 # remove timeout for receiving data


        # Initialisation stage
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()        # initialise Sepia
        check_sepia_connection(iModuleType, connection)             # check that Sepia is working as expected
        check_ls_connection(connection)                             # check that the laserSwitch is working as expected
        set_safe_states(iDevIdx, iSlotID)	                    # sets all the Sepia parameters to their safe state values
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()        # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of set_safe_states)
        check_safe_states(iDevIdx, iSlotID, connection)		    # check that all devices are in their safe-states

        print "Simple TCP/IP Run (Main) - Looking for a Confirmation from ORCA to start the SMELLIE run ... "
        connection.settimeout(5)                                    # set a timeout for receiving data
        try:
                while 1:
                        start_run = connection.recv(1024)
                        if (start_init_data == start_initialise_flag):      # check if initialisation command has been given
                                print "Simple TCP/IP Run (Main) - Ready to start sending run parameters"
                                break
        except conn.timeout:
                connection.send(timeout_flag)
                main()
        
        connection.settimeout(None)                                 # remove timeout for receiving data

        main()

        print "Simple TCP/IP Run (Main) - Waiting for run parameters from ORCA ... "
        ORCA_set_ls_channel(connection, iDevIdx)
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()        # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of ORCA_set_ls_channel)
        ORCA_set_laser_parameters(connection)
        complete_self_test(connection, iDevIdx, iSlotID)
        sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
        ORCA_set_fs_channel(connection)
        number_of_pulses = ORCA_ni_get_pulses(connection)                                 # get the number of pulses from the NI box
        trigger_frequency = ORCA_ni_get_trigger_frequency(connection)                     # get the trigger frequency of the NI box
        perform_run(connection, number_of_pulses, trigger_frequency, iDevIdx, iSlotID)    # complete the SMELLIE run

        sys.exit("Simple TCP/IP Run (Main) - good exit")
Example #22
0
def check_current_states(iDevIdx, iSlotID, input_intensity, input_frequency):
	intensity,frequency_number,pulse_mode,head_id = sepiaUser.get_laser_parameters(iDevIdx)	
	if (intensity != input_intensity or frequency_number != input_frequency):
		sys.exit('Simple Run (Check Current States) - Laser States have not been correctly set to your specified values ... aborting run!')
	return 	



##### START OF THE MAIN PROGRAM ####################################################################################################

# Initialisation stage
iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()    # initialise Sepia
set_safe_states(iDevIdx, iSlotID)	                        # sets all the Sepia parameters to their safe state values
iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()        # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of set_safe_states)
sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
check_safe_states(iDevIdx, iSlotID, connection)		        # check that all devices are in their safe-states

rs.SetSelectedChannel(0)				              # set the laserSwitch channel to 1
sepiaUser.close(iDevIdx)
rs.Execute()                                          # execute the laserSwitch channel change
iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()  # need to reinitialise Sepia after turning off during the changing of the laserSwitch channel (part of SetSelectedChannel)
sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)

# Set all Parameters (all must be INTEGERS)
input_intensity = 100
input_frequency = 4
input_rs_channel = 1
input_fs_channel = 1  
sepiaUser.set_laser_intensity(input_intensity, iDevIdx)	  # set the laser intensity to 100%
sepiaUser.set_laser_frequency(input_frequency, iDevIdx)   # set the laser frequency to Internal 5MHz
Example #23
0
def main():	

        myHost = ''                                                     # initialise the server machine ('' means: local host)
        myPort = 50009                                                  # listen on a non-reserved port number

        conn.sockobj = conn.socket(conn.AF_INET, conn.SOCK_STREAM)       # make a TCP/IP socket object
        conn.sockobj.settimeout(None)                                    # No timeout on the socket
        conn.sockobj.setsockopt(conn.SOL_SOCKET,conn.SO_REUSEADDR,1)
        conn.sockobj.bind((myHost, myPort))                              # bind the socket object to the specified server and port number 
        conn.sockobj.listen(5)                                           # begin listening, and allow 5 pending connects

        # Check for connection confimation from ORCA
        print "Simple TCP/IP Run (Main) - Checking for connection confimation from ORCA ... "	
        while 1:                                                        # listen until process killed
                connection, address = conn.sockobj.accept()             # wait for next client connection
                print 'Connection made to:' + str(address)              # connection is a new socket
                if address : break		
        connection.send(str(check_connection_flag))                          # send signal to ORCA  to check connection

        controlFlag = '0'
        controlArgument = '0'
        master_mode_trigger_frequency = '0'
        master_mode_number_of_pulses = '0'

        # Get the control flag
        connection.settimeout(5) 
        try:
                while 1:
                        controlFlag = connection.recv(1024)
                        #print "ControlFlag = " + str(controlFlag)
                        break
                
        except conn.timeout:
                connection.send(timeout_flag)
                main()

        connection.send(str(check_connection_flag))         

        # Get the control argument
        connection.settimeout(5) 
        try:
                while 1:
                        controlArgument = connection.recv(1024)
                        break
                
        except conn.timeout:
                connection.send(timeout_flag)
                main()
                
        connection.send(str(check_connection_flag)) 
        #connection.send(str(check_connection_flag)) #send this to signify that this is finished
        #main()

        #print "ControlFlag = " + str(controlFlag)
        #controlFlag = 60
        
        try:
                #print 'controlFlag: ' + str(controlFlag)
                #print 'laser intensity flag' + str(set_laser_intensity_flag)
                # set the laser switch channel 
                if (int(controlFlag) == int(set_laser_switch_flag)):      
                        print "Set the Laser switch to state" + str(controlArgument)
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
                        rs.SetSelectedChannel(int(controlArgument))
                        sepiaUser.close(iDevIdx)
                        rs.Execute() 
                
                # set safe sates
                elif (int(controlFlag) == int(set_safe_states_flag)):
                        print "Setting to safe states"
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
                        set_safe_states(iDevIdx, iSlotID)
                        
                # set fibre switch channel 
                elif (int(controlFlag) == int(set_fibre_switch_channel_flag)):
                        print(controlArgument)
                        input_channel,output_channel = extractLaserFibreValues(controlArgument)
                        print "Set the Fibre Switch to input Channel:" + str(input_channel) +" and output channel:" + str(output_channel)
                        fs.SetIOChannels(int(input_channel), int(output_channel))
                        # fs.SetFSChannel(controlArgument)

                # set laser intensity 
                elif (int(controlFlag) == int(set_laser_intensity_flag)):
                        print "Set Laser Intensity to " + str(controlArgument) + "%"
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
                        time.sleep(1.0)
                        sepiaUser.set_laser_intensity(int(controlArgument), iDevIdx)
                        time.sleep(1.0)
                        sepiaUser.close(iDevIdx)

                # set soft lock on
                elif (int(controlFlag) == int(set_laser_soft_lock_on_flag)):
                        print "Set laser soft lock on"
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialiseSCMModule()
                        time.sleep(1.0)
                        sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)
                        time.sleep(1.0)
                        sepiaUser.close(iDevIdx)

                # start master mode run 
                elif (int(controlFlag) == int(master_mode_flag)):
                        master_mode_trigger_frequency,master_mode_number_of_pulses = extractMasterModeFromCode(controlArgument)
                        print "Starting a Master mode sub run with trig frequency: " + str(master_mode_trigger_frequency) + "Hz and num_of_pulses:" + str(master_mode_number_of_pulses)
                        #iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
                        #time.sleep(1.0)
                        #iDevIdx2,iModuleType2,iSlotID2 = sepiaUser.initialiseSCMModule()
                        #sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID2)
                        #time.sleep(1.0)
                        digi_trig = ni.GenerateDigitalTrigger(int(master_mode_trigger_frequency), int(master_mode_number_of_pulses))
                        digi_trig.start()
                        digi_trig.stop()
                        #sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID2)
                        #time.sleep(1.0)
                        #sepiaUser.close(iDevIdx)
                        #sepiaUser.close(iDevIdx2)

                # set soft lock off
                elif (int(controlFlag) == int(set_laser_soft_lock_off_flag)):
                        print "Set laser soft lock off"
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialiseSCMModule()
                        time.sleep(1.0)
                        print sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)
                        time.sleep(1.0)
                        sepiaUser.close(iDevIdx)
                # set the laser frequency to high enough to see visually 
                elif (int(controlFlag) == int(set_laser_testing_frequency_mode)):
                        print "Setting laser to 20MHz testing Mode"
                        iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
                        sepiaUser.set_laser_frequency(2, iDevIdx)        # set the laser frequency to 20Mhz
                        sepiaUser.close(iDevIdx)
                        
                else:
                        print "No command value recieved"
                        # put all the possible options in here

                        
        except:
                connection.send(timeout_flag)
                main()

        connection.send(str(check_connection_flag)) #send this to signify that this is finished

        print "Return to listening on the port"
        main()                                # return to listening on the port 
Example #24
0
        trigger_frequency = 10000
        number_of_pulses = 100000
        digi_trig = ni.GenerateDigitalTrigger(trigger_frequency, number_of_pulses)
        read_signal = ni.AcquireAnalogue()
        number_of_measurements = 1  
        voltage_signal = str(read_signal.start(number_of_measurements))
		digi_trig.start()
        
		digi_trig.stop()
        read_signal = ni.AcquireAnalogue()
        a = raw_input("Generating pulse train ... press Enter to interrupt ...\n")
        read_signal.stop()
        
		logfile.write(str(ls_channel) + '\t' + str(channel_number) + '\t' + voltage_signal[1:-1] + '\n')
        
		sepiaUser.laser_soft_lock_on(iDevIdx, iSlotID)


def main():
    iDevIdx,iModuleType,iSlotID = sepiaUser.initialise() 
    set_to_safe_state(iDevIdx, iSlotID)                       # set all the laser parameters to safe values 	
    
    timestamp = str(time.time())
    timestamp = timestamp[0:10]

    filename = 'Testing_SMELLIE_at_5MHz_' + timestamp + '.txt' 
    f = open(filename, 'w')
    
    # initiate test run across ALL laserSwitch channels and ALL fibreSwitch input/output channel combinations
    test_run(1, 1, f, iDevIdx, iModuleType, iSlotID)
    test_run(2, 2, f, iDevIdx, iModuleType, iSlotID)