Skip to content

Commit c3c7159

Browse files
Merged in Python3_PhaseMatrixQuickSyn (pull request #36)
Python3 PhaseMatrixQuickSyn
2 parents 1c756ed + ad63d75 commit c3c7159

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

PhaseMatrixQuickSyn.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
# the project for the full license. #
1111
# #
1212
#####################################################################
13+
from __future__ import division, unicode_literals, print_function, absolute_import
14+
from labscript_utils import PY2
15+
if PY2:
16+
str = unicode
1317

1418
import numpy as np
1519
from labscript_devices import BLACS_tab, runviewer_parser
@@ -92,7 +96,7 @@ def generate_code(self, hdf5_file):
9296
dds.frequency.raw_output, dds.frequency.scale_factor = self.quantise_freq(dds.frequency.raw_output, dds)
9397
static_dtypes = [('freq0', np.uint64)] + \
9498
[('gate0', np.uint16)]
95-
static_table = np.zeros(1, dtype=static_dtypes)
99+
static_table = np.zeros(1, dtype=static_dtypes)
96100
static_table['freq0'].fill(1)
97101
static_table['freq0'] = dds.frequency.raw_output[0]
98102
static_table['gate0'] = dds.gate.raw_output[0]
@@ -195,7 +199,6 @@ def update_blanking(self):
195199
@define_state(MODE_MANUAL|MODE_BUFFERED|MODE_TRANSITION_TO_BUFFERED|MODE_TRANSITION_TO_MANUAL,True,True)
196200
def update_lock_recovery(self):
197201
value = self.status_ui.lock_recovery_button.isChecked()
198-
print value
199202
yield(self.queue_work(self._primary_worker,'update_lock_recovery',value))
200203

201204

@@ -211,11 +214,11 @@ def init(self):
211214
self.connection.readlines()
212215

213216
#check to see if the reference is set to external. If not, make it so! (should we ask the user about this?)
214-
self.connection.write('ROSC:SOUR?\r')
215-
response = self.connection.readline()
217+
self.connection.write(b'ROSC:SOUR?\r')
218+
response = self.connection.readline().decode('utf8')
216219
if response == 'INT\n':
217220
#ref was set to internal, let's change it to ext
218-
self.connection.write('ROSC:SOUR EXT\r')
221+
self.connection.write(b'ROSC:SOUR EXT\r')
219222

220223
def check_remote_values(self):
221224
# Get the currently output values:
@@ -225,12 +228,12 @@ def check_remote_values(self):
225228
count = 0
226229

227230

228-
self.connection.write('FREQ?\r')
229-
line = self.connection.readline()
231+
self.connection.write(b'FREQ?\r')
232+
line = self.connection.readline().decode('utf8')
230233

231234
if line == '':
232235
#try again
233-
line = self.connection.readline()
236+
line = self.connection.readline().decode('utf8')
234237
if line == '':
235238
raise Exception("Device didn't say what its frequncy was :(")
236239

@@ -239,8 +242,8 @@ def check_remote_values(self):
239242

240243
# wait a little while first, it doesn't like being asked things too quickly!
241244
time.sleep(0.05)
242-
self.connection.write('OUTP:STAT?\r')
243-
line = self.connection.readline()
245+
self.connection.write(b'OUTP:STAT?\r')
246+
line = self.connection.readline().decode('utf8')
244247
if line == '':
245248
raise Exception("Device didn't say what its status was :(")
246249
time.sleep(0.05)
@@ -255,8 +258,8 @@ def check_remote_values(self):
255258
def check_status(self):
256259
results = {}
257260
line = ''
258-
self.connection.write('STAT?\r')
259-
line = self.connection.readline()
261+
self.connection.write(b'STAT?\r')
262+
line = self.connection.readline().decode('utf8')
260263
if line == '':
261264
raise Exception("Device didn't say what its status was :(")
262265
time.sleep(0.05)
@@ -290,8 +293,8 @@ def check_status(self):
290293
results['lock_recovery'] = int(status[-8])
291294

292295
# now let's check it's temperature!
293-
self.connection.write('DIAG:MEAS? 21\r')
294-
results['temperature'] = float(self.connection.readline())
296+
self.connection.write(b'DIAG:MEAS? 21\r')
297+
results['temperature'] = float(self.connection.readline().decode('utf8'))
295298

296299
# check if the temperature is bad, if it is, raise an exception. Hopefully one day this will be sent to syslog,
297300
#at which point we'll add some extra magic to segregate into warning and critical temperatures.
@@ -307,15 +310,15 @@ def program_manual(self,front_panel_values):
307310
#program in millihertz:
308311
freq*=1e3
309312
command = 'FREQ %i\r'%freq
310-
self.connection.write(command)
313+
self.connection.write(command.encode('utf8'))
311314

312315
# add some sleep time here since the phasematrix gets grumpy
313316
time.sleep(0.05)
314317

315318

316319
gate = front_panel_values['dds 0']['gate']
317320
command = 'OUTP:STAT %i\r'%gate
318-
self.connection.write(command)
321+
self.connection.write(command.encode('utf8'))
319322

320323
return self.check_remote_values()
321324

@@ -340,9 +343,9 @@ def transition_to_buffered(self,device_name,h5file,initial_values,fresh):
340343
if 'STATIC_DATA' in group:
341344
data = group['STATIC_DATA'][:][0]
342345

343-
self.connection.write('FREQ %i\r'%(data['freq0']))
346+
self.connection.write(b'FREQ %i\r'%(data['freq0']))
344347
time.sleep(0.05)
345-
self.connection.write('OUTP:STAT 1')#%i'%(data['gate0']))
348+
self.connection.write(b'OUTP:STAT 1')#%i'%(data['gate0']))
346349

347350

348351
# Save these values into final_values so the GUI can

0 commit comments

Comments
 (0)