Infrastructure/Current-Stabilization/Development/GTE_Tabletop/Codes/rigol.py

from ds1054z import DS1054Z

def prepare_osc(scope):
    """
    Sets osciloscope to single mode. Meaning it will wait for trigger.
    Input:
    scope -- DS1054 class - osciloscope python object
    """
    scope.single()

def get_data(scope, channel):
    """
    Loads data from time axis and values from given oscliloscope channel.
    Input:
    scope -- DS1054 class - osciloscope python object
    channel -- number of channel to read data from
    """
    data = scope.get_waveform_samples(channel)
    time = scope.waveform_time_values
    return time, data

def save_screen(scope, name = 'oscope.bmp',folder = 'screenshots'):
    """
    Saves osciloscope screen as a name.bmp file into folder
    Input:
    scope -- DS1054 class - osciloscope python object
    name = oscope.bmp -- name of screenshot
    folder = screenshots -- name of folder for screenshot saving
    """
    scshot = scope.display_data
    File = open(os.path,join(folder,name),'w')
    File.write(scshot)
    File.close()