Esempio n. 1
0
def set_soft_lock_off():
    retValue = 0
    try:
        print "Set laser soft lock on"
        iDevIdx,iModuleType,iSlotID = sepiaUser.initialiseSCMModule()
        time.sleep(1.0)
        sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)
        time.sleep(1.0)
        sepiaUser.close(iDevIdx)
    except errorCode, Argument:
        retValue = "Error: " + str(errorCode) + "  " + str(Argument)
Esempio n. 2
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 
Esempio n. 3
0
import pysepiaUser as sepiaUser
import time

iDevIdx,iModuleType,iSlotID = sepiaUser.initialiseSCMModule()
#print iDevIdx
#print sepiaUser.laser_soft_lock_off(iDevIdx, iSlotID)
#sepiaUser.close(iDevIdx)

time.sleep(1)

#iDevIdx,iModuleType,iSlotID = sepiaUser.initialise()
#print sepiaUser.get_laser_lock_status(iDevIdx, iSlotID)
sepiaUser.close(iDevIdx)