qcodes/instrument_drivers/tektronix/AWGFileParser.py
def _parser1(
        awgfilepath: str
) -> Tuple[Dict[str, Union[str, int, Tuple[Any, ...]]], List[List[Any]], List[List[Any]]]:
    """
    Helper function doing the heavy lifting of reading and understanding the
    binary .awg file format.

    Args:
        awgfilepath: The absolute path of the awg file to read

    Returns:
        Tuple of instrument settings (a dict), waveforms (list of lists), sequencer settings (list of lists)
    """

    instdict = {}
    waveformlist: List[List[Any]] = [[], []]
    sequencelist: List[List[Any]] = [[], []]
    wfmlen: int

    with open(awgfilepath, 'rb') as fid:

        while True:
            chunk = fid.read(8)
            if not chunk:
                break

            (namelen, valuelen) = struct.unpack('<II', chunk)

            rawname = fid.read(namelen)
            rawvalue = fid.read(valuelen)

            name = rawname[:-1].decode('ascii')  # remove NULL termination char

            if name.startswith('WAVEFORM'):

                namestop = name[name.find('_')+1:].find('_')+name.find('_')
                lookupname = name[:namestop+1]

                if 'DATA' in name:
                    fmtstr = f'{wfmlen}H'
                    AWG_FILE_FORMAT_WAV['WAVEFORM_DATA'] = fmtstr

                file_format = AWG_FILE_FORMAT_WAV[lookupname]
                assert file_format is not None
                value = _unwrap(rawvalue, file_format)
                (number, barename) = _getendingnumber(name)
                fieldname = barename + f"{number-20}"
                waveformlist[0].append(fieldname)
                waveformlist[1].append(value)

                if 'LENGTH' in name:
                    assert isinstance(value, int)
                    wfmlen = value

                continue

            if name.startswith('SEQUENCE'):

                namestop = name[name.find('_')+1:].find('_')+name.find('_')
                lookupname = name[:namestop+1]
                value = _unwrap(rawvalue, AWG_FILE_FORMAT_SEQ[lookupname])
                sequencelist[0].append(name)
                sequencelist[1].append(value)

                continue

            else:
                value = _unwrap(rawvalue, AWG_FILE_FORMAT[name])

            if name in AWG_TRANSLATER:
                assert isinstance(value, int)
                value = AWG_TRANSLATER[name][value]

            instdict.update({name: value})

    return instdict, waveformlist, sequencelist

    Helper function doing the heavy lifting of reading and understanding the
    binary .awg file format.

    Args:
        awgfilepath: The absolute path of the awg file to read

    Returns:
        Tuple of instrument settings (a dict), waveforms (list of lists), sequencer settings (list of lists)
    
Helper function doing the heavy lifting of reading and understanding the
binary .awg file format.
Helper function doing the heavy lifting of reading and understanding the binary . awg file format .
def _parser1(
        awgfilepath: str
) -> Tuple[Dict[str, Union[str, int, Tuple[Any, ...]]], List[List[Any]], List[List[Any]]]:
    instdict = {}
    waveformlist: List[List[Any]] = [[], []]
    sequencelist: List[List[Any]] = [[], []]
    wfmlen: int
    with open(awgfilepath, 'rb') as fid:
        while True:
            chunk = fid.read(8)
            if not chunk:
                break
            (namelen, valuelen) = struct.unpack('<II', chunk)
            rawname = fid.read(namelen)
            rawvalue = fid.read(valuelen)
            name = rawname[:-1].decode('ascii')  
            if name.startswith('WAVEFORM'):
                namestop = name[name.find('_')+1:].find('_')+name.find('_')
                lookupname = name[:namestop+1]
                if 'DATA' in name:
                    fmtstr = f'{wfmlen}H'
                    AWG_FILE_FORMAT_WAV['WAVEFORM_DATA'] = fmtstr
                file_format = AWG_FILE_FORMAT_WAV[lookupname]
                assert file_format is not None
                value = _unwrap(rawvalue, file_format)
                (number, barename) = _getendingnumber(name)
                fieldname = barename + f"{number-20}"
                waveformlist[0].append(fieldname)
                waveformlist[1].append(value)
                if 'LENGTH' in name:
                    assert isinstance(value, int)
                    wfmlen = value
                continue
            if name.startswith('SEQUENCE'):
                namestop = name[name.find('_')+1:].find('_')+name.find('_')
                lookupname = name[:namestop+1]
                value = _unwrap(rawvalue, AWG_FILE_FORMAT_SEQ[lookupname])
                sequencelist[0].append(name)
                sequencelist[1].append(value)
                continue
            else:
                value = _unwrap(rawvalue, AWG_FILE_FORMAT[name])
            if name in AWG_TRANSLATER:
                assert isinstance(value, int)
                value = AWG_TRANSLATER[name][value]
            instdict.update({name: value})
    return instdict, waveformlist, sequencelist
def _parser1 ( awgfilepath : str ) -> Tuple [ Dict [ str , Union [ str , int , Tuple [ Any , ... ] ] ] , List [ List [ Any ] ] , List [ List [ Any ] ] ] : instdict = { } waveformlist : List [ List [ Any ] ] = [ [ ] , [ ] ] sequencelist : List [ List [ Any ] ] = [ [ ] , [ ] ] wfmlen : int with open ( awgfilepath , 'rb' ) as fid : while True : chunk = fid . read ( 8 ) if not chunk : break ( namelen , valuelen ) = struct . unpack ( '<II' , chunk ) rawname = fid . read ( namelen ) rawvalue = fid . read ( valuelen ) name = rawname [ : - 1 ] . decode ( 'ascii' ) if name . startswith ( 'WAVEFORM' ) : namestop = name [ name . find ( '_' ) + 1 : ] . find ( '_' ) + name . find ( '_' ) lookupname = name [ : namestop + 1 ] if 'DATA' in name : fmtstr = f'{wfmlen}H' AWG_FILE_FORMAT_WAV [ 'WAVEFORM_DATA' ] = fmtstr file_format = AWG_FILE_FORMAT_WAV [ lookupname ] assert file_format is not None value = _unwrap ( rawvalue , file_format ) ( number , barename ) = _getendingnumber ( name ) fieldname = barename + f"{number-20}" waveformlist [ 0 ] . append ( fieldname ) waveformlist [ 1 ] . append ( value ) if 'LENGTH' in name : assert isinstance ( value , int ) wfmlen = value continue if name . startswith ( 'SEQUENCE' ) : namestop = name [ name . find ( '_' ) + 1 : ] . find ( '_' ) + name . find ( '_' ) lookupname = name [ : namestop + 1 ] value = _unwrap ( rawvalue , AWG_FILE_FORMAT_SEQ [ lookupname ] ) sequencelist [ 0 ] . append ( name ) sequencelist [ 1 ] . append ( value ) continue else : value = _unwrap ( rawvalue , AWG_FILE_FORMAT [ name ] ) if name in AWG_TRANSLATER : assert isinstance ( value , int ) value = AWG_TRANSLATER [ name ] [ value ] instdict . update ( { name : value } ) return instdict , waveformlist , sequencelist
Helper function doing the heavy lifting of reading and understanding the
binary .awg file format.
Helper function doing the heavy lifting of reading and understanding the binary . awg file format .
"""
    Helper function doing the heavy lifting of reading and understanding the
    binary .awg file format.

    Args:
        awgfilepath: The absolute path of the awg file to read

    Returns:
        Tuple of instrument settings (a dict), waveforms (list of lists), sequencer settings (list of lists)
    """ # remove NULL termination char
Tuple of instrument settings (a dict), waveforms (list of lists), sequencer settings (list of lists)
Tuple of instrument settings ( a dict ) waveforms ( list of lists ) sequencer settings ( list of lists )
awgfilepath
str
The absolute path of the awg file to read
The absolute path of the awg file to read