コード例 #1
0
ファイル: DE_optimise.py プロジェクト: ssquantum/PyDex
    def __init__(self,
                 f0=135,
                 f1=185,
                 nfreqs=50,
                 fset=166,
                 pwr=1,
                 tol=1e-3,
                 sleep=0.5):
        self.status = 'checking'
        # parameters
        self.f0 = f0  # lower bound
        self.f1 = f1  # upper bound
        self.nfreqs = nfreqs  # number of frequencies
        self.fset = fset  # setpoint
        self.pwr = pwr  # amplitude
        self.tol = tol  # tolerance
        self.sleep = sleep  # sleep duration

        #
        self.fs = np.linspace(f0, f1, nfreqs)  # frequencies to test
        self.vs = np.ones(nfreqs) * 200  # amplitude mV at those freqs
        self.v = 200  # current amplitude being tried
        self.i = 0  # current index being set
        self.setpoint = 1  # DAQ measurement to match to
        self.n = 0  # counter for number of measurements

        # setup
        self.s = PyServer(host='', port=8622)  # server for DAQ
        self.s.textin.connect(self.respond)
        self.s.start()
        self.dxs = PyServer(host='', port=8620)  # server for DExTer
        # self.dxs.textin.connect(self.respond)
        self.dxs.start()

        self.t = AWG([0, 1])
        self.t.setNumSegments(128)
        self.t.setTrigger(0)  # software trigger
        self.t.setSegDur(0.002)

        # segment, action, duration, freqs, numTraps, separation, freqAdjust, ampAdjust
        # self.t.setSegment(0, 1, 0.02, [fset], 1, 9, amp, [1], [0], False, False) # single trap
        # # step, segment, numLoops, nextStep, triggerCondition
        # self.t.setStep(0,0,1,0,1) # infinite loop
        # self.t.start()
        # self.t.setSegment(0, self.t.dataGen(0,0,'static',1,[fset],1,9, amp,[1],[0],False,False))
        # self.t.setStep(0,0,1,0,1)
        self.t.load(
            r'Z:\Tweezer\Code\Python 3.5\PyDex\awg\AWG template sequences\2channel_swap_static.txt'
        )
コード例 #2
0
ファイル: runid.py プロジェクト: JonathanMortlock/PyDex
    def __init__(self, camra, saver, saiaw, check, seq, n=0, m=1, k=0):
        super().__init__()
        self._n = n  # the run number
        self._m = m  # # images per run
        self._k = k  # # images received
        self.multirun = False  # status of whether in multirun or not
        self.cam = camra  # Andor camera control
        self.cam.AcquireEnd.connect(
            self.receive)  # receive the most recent image
        self.sv = saver  # image saver
        self.im_save.connect(
            self.sv.add_item
        )  # separate signal to avoid risk of the slot being disconnected elsewhere
        self.sv.start(
        )  # constantly checks queue, when an image to save is added to the queue, it saves it to a file.
        self.sw = saiaw  # image analysis settings gui
        self.sw.m_changed.connect(self.set_m)
        self.sw.CCD_stat_edit(self.cam.emg, self.cam.pag, self.cam.Nr,
                              True)  # give image analysis the camera settings
        self.cam.SettingsChanged.connect(self.sw.CCD_stat_edit)
        self.cam.ROIChanged.connect(
            self.sw.cam_pic_size_changed)  # triggers pic_size_text_edit()
        self.check = check  # atom checker for ROIs, trigger experiment
        self.check.rh.shape = (self.sw.stats['pic_width'],
                               self.sw.stats['pic_height'])
        self.check.nrois_edit.setText(str(len(self.sw.stats['ROIs'])))
        self.cam.ROIChanged.connect(self.check.rh.cam_pic_size_changed)
        self.check.rh.resize_rois(self.sw.stats['ROIs'])
        self.sw.bias_changed.connect(self.check.rh.set_bias)
        self.check.roi_values.connect(self.sw.set_rois)
        self.seq = seq  # sequence editor

        self.server = PyServer(
            host='', port=8620)  # server will run continuously on a thread
        self.server.dxnum.connect(self.set_n)  # signal gives run number
        self.server.start()
        if self.server.isRunning():
            self.server.add_message(TCPENUM['TCP read'],
                                    'Sync DExTer run number\n' + '0' * 2000)

        self.trigger = PyServer(host='',
                                port=8621)  # software trigger using TCP
        self.trigger.start()
        self.monitor = PyServer(host='',
                                port=8622)  # monitor program runs separately
        self.monitor.start()
        self.monitor.add_message(self._n, 'resync run number')
コード例 #3
0
 def __init__(self, ):
     super().__init__()
     self.daq_tcp = PyServer(host='', port=8622) # server for DAQ
     self.daq_tcp.textin.connect(self.respond)
     self.daq_tcp.start()
     self.dds_tcp = PyServer(host='', port=8624) # server for DDS
     self.dds_tcp.start()
     
     layout = QBoxLayout(QBoxLayout.TopToBottom, self)
     self.maxamp = QLineEdit('0.5', self)
     layout.addWidget(self.maxamp)
     self.comport = QLineEdit('COM11', self)
     layout.addWidget(self.comport)
     self.profile = QLineEdit('P7', self)
     layout.addWidget(self.profile)
     self.status = QLabel('n = 0, amp = 0, power = 0')
     layout.addWidget(self.status)
     self.lastval = QLabel('')
     layout.addWidget(self.lastval)
     reset = QPushButton('Reset')
     reset.clicked.connect(self.reset)
     layout.addWidget(reset)
     programme = QPushButton('Programme DDS')
     programme.clicked.connect(self.programme)
     layout.addWidget(programme)
     measure = QPushButton('DAQ Measure')
     measure.clicked.connect(self.measure)
     layout.addWidget(measure)
     store = QPushButton('Store Result')
     store.clicked.connect(self.store)
     layout.addWidget(store)
     save = QPushButton('Save Results')
     save.clicked.connect(self.save)
     layout.addWidget(save)
     
     self.amps = np.linspace(0,float(self.maxamp.text()),15)
     # np.random.shuffle(self.amps)
     self.power = np.zeros(len(self.amps))
     self.n = 0 # index for counting
コード例 #4
0
import time
sys.path.append(r'Z:\Tweezer\Code\Python 3.5\PyDex\networking')
from networker import PyServer, TCPENUM
# from awgHandler import AWG
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication

from PIL import Image
os.environ['PATH'] = r'Z:\Tweezer\Code\Python 3.5\thorcam control\dlls'
from thorlabs_tsi_sdk.tl_camera import TLCameraSDK

fdir = r'Z:\Tweezer\Experimental Results\2020\December\11\AWGcalibration5'
img_path = os.path.join(fdir, 'images')
os.makedirs(img_path, exist_ok=True)

daqs = PyServer(host='', port=8622)  # server for DAQ
daqs.start()
awgtcp = PyServer(host='', port=8623)  # AWG program runs separately
awgtcp.start()

# t = AWG([0,1])
# t.setNumSegments(8)
# t.setTrigger(0) # software trigger
# t.setSegDur(0.002)
# t.load(r'Z:\Tweezer\Code\Python 3.5\PyDex\awg\AWG template sequences\test amp_adjust\single_static.txt')
# t.start()

app = QApplication.instance()
standalone = app is None  # false if there is already an app instance
if standalone:  # if there isn't an instance, make one
    app = QApplication(sys.argv)
コード例 #5
0
    def __init__(self, camra, saver, saiaw, check, seq, n=0, m=1, k=0):
        super().__init__()
        self._n = n  # the run number
        self._m = m  # # images per run
        self._k = k  # # images received
        self.next_mr = []  # queue of messages for the next multirun
        self.rearranging = False  # whether the first image is being used for rearrangement.
        self.mr_paused = False  # whether the current multirun has been paused
        self.cam = camra  # Andor camera control
        self.cam.AcquireEnd.connect(
            self.receive)  # receive the most recent image
        self.sv = saver  # image saver
        self.im_save.connect(
            self.sv.add_item
        )  # separate signal to avoid risk of the slot being disconnected elsewhere
        self.sv.start(
        )  # constantly checks queue, when an image to save is added to the queue, it saves it to a file.
        self.sw = saiaw  # image analysis settings gui
        self.sw.m_changed.connect(self.set_m)
        self.sw.CCD_stat_edit(self.cam.emg, self.cam.pag, self.cam.Nr,
                              True)  # give image analysis the camera settings
        self.sw.reset_analyses(
        )  # make sure the loaded config settings are applied
        self.cam.SettingsChanged.connect(self.sw.CCD_stat_edit)
        self.cam.ROIChanged.connect(
            self.sw.cam_pic_size_changed)  # triggers pic_size_text_edit()
        self.check = check  # atom checker for ROIs, trigger experiment
        self.check.recv_rois_action.triggered.connect(
            self.get_rois_from_analysis)
        # self.get_rois_from_analysis()
        for rh in self.check.rh.values():
            self.cam.ROIChanged.connect(rh.cam_pic_size_changed)
            self.sw.bias_changed.connect(rh.set_bias)
        self.check.roi_values.connect(self.sw.set_rois)
        self.seq = seq  # sequence editor

        self.server = PyServer(
            host='', port=8620, name='DExTer',
            verbosity=1)  # server will run continuously on a thread
        self.server.dxnum.connect(self.set_n)  # signal gives run number
        self.server.start()
        if self.server.isRunning():
            self.server.add_message(TCPENUM['TCP read'],
                                    'Sync DExTer run number\n' + '0' * 2000)

        self.trigger = PyServer(
            host='', port=8621,
            name='Dx SFTWR TRIGGER')  # software trigger using TCP
        self.trigger.start()
        self.monitor = PyServer(host='', port=8622,
                                name='DAQ')  # monitor program runs separately
        self.monitor.start()
        self.monitor.add_message(self._n, 'resync run number')
        self.awgtcp1 = PyServer(host='', port=8623,
                                name='AWG1')  # AWG program runs separately
        self.awgtcp1.start()
        self.ddstcp1 = PyServer(host='', port=8624,
                                name='DDS1')  # DDS program runs separately
        self.ddstcp1.start()
        self.seqtcp = PyServer(
            host='', port=8625, name='BareDExTer'
        )  # Sequence viewer in seperate instance of LabVIEW
        self.seqtcp.start()
        self.slmtcp = PyServer(host='', port=8627,
                               name='SLM')  # SLM program runs separately
        self.slmtcp.start()
        self.client = PyClient(host='129.234.190.235',
                               port=8626,
                               name='AWG1 recv')  # incoming from AWG
        self.client.start()
        self.client.textin.connect(
            self.add_mr_msgs)  # msg from AWG starts next multirun step
        self.awgtcp2 = PyServer(host='', port=8628,
                                name='AWG2')  # AWG program runs separately
        self.awgtcp2.start()
        self.clien2 = PyClient(host='129.234.190.233',
                               port=8629,
                               name='AWG2 recv')  # incoming from AWG
        self.clien2.start()
        self.clien2.textin.connect(
            self.add_mr_msgs)  # msg from AWG starts next multirun step
        self.ddstcp2 = PyServer(host='', port=8630,
                                name='DDS2')  # DDS program runs separately
        self.ddstcp2.start()