Skip to content

Commit

Permalink
Write TDM sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Ristè committed Oct 11, 2019
1 parent 425d58d commit 59fa519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
3 changes: 1 addition & 2 deletions QGL/Compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ def compile_to_hardware(seqs,
aps2tdm_module = import_module('QGL.drivers.APS2Pattern') # this is redundant with above
tdm_instr = aps2tdm_module.tdm_instructions(seqs)
files['TDM'] = os.path.normpath(os.path.join(
config.AWGDir, fileName + '-' + 'TDM' + suffix + data[
'seqFileExt']))
config.AWGDir, fileName + '-' + 'TDM' + suffix + '.aps2'))
aps2tdm_module.write_tdm_seq(tdm_instr, files['TDM'])

if extra_meta:
Expand Down
22 changes: 8 additions & 14 deletions QGL/drivers/APS2Pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,23 +1431,17 @@ def tdm_instructions(seqs):
len(instructions))

def write_tdm_seq(seq, tdm_fileName):
#Open the HDF5 file
#Open the binary file
if os.path.isfile(tdm_fileName):
os.remove(tdm_fileName)
with h5py.File(tdm_fileName, 'w') as FID:
FID['/'].attrs['Version'] = 5.0
FID['/'].attrs['target hardware'] = 'APS2'
FID['/'].attrs['minimum firmware version'] = 5.0
FID['/'].attrs['channelDataFor'] = np.uint16([1, 2])

#Create the groups and datasets
for chanct in range(2):
chanStr = '/chan_{0}'.format(chanct + 1)
chanGroup = FID.create_group(chanStr)
FID.create_dataset(chanStr + '/waveforms', data=np.uint16([]))
#Write the instructions to channel 1
if np.mod(chanct, 2) == 0:
FID.create_dataset(chanStr + '/instructions', data=seq)
with open(tdm_fileName, 'wb') as FID:
FID.write(b'TDM') # target hardware
FID.write(np.float32(2.0).tobytes()) # Version
FID.write(np.float32(2.0).tobytes()) # minimum firmware version
FID.write(np.uint16(0).tobytes()) # number of channels
FID.write(np.uint64(seq.size).tobytes()) # instructions length
FID.write(seq.tobytes()) # instructions in uint64 form

# Utility Functions for displaying programs

Expand Down

0 comments on commit 59fa519

Please sign in to comment.