# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import rigol
import rigol.usbtmc
import rigol.rigol

import rigol.key
# -

import os

assert os.path.exists("/dev/usbtmc1")

stat = os.stat("/dev/usbtmc1")

device = rigol.rigol.RigolScope(device="/dev/usbtmc1")

device

device.reset()

scope = rigol.rigol.RigolScope(device=device)

scope.device

assert scope.vendor=="Rigol Technologies"
assert scope.model=="DS1052D"
assert scope.version=="00.04.02.01.00"

# # Keys

key = rigol.key.Key(device=device)

key.auto()

scope.key.auto()


# +
def key_factory(key_str:str, wait: int=0):
    def press_key(self):
        command_string = f":{self}:{key_str}"
        print(command_string)
        self.device.write(f":{self}:{key_str}")
    return press_key
                          
                          
def key_factory2(key_str:str, wait: int=0):
    key_str = key_str.strip().strip(":").split(":")[-1].upper()
    key_function = key_factory(key_str, wait)                   
    return key_str.lower(), key_function


# -

result = match
result

key_factory(result)

key=Key(device=device)

key_factory(result)(key)

key_factory2(result)

key_str, key_function = key_factory2(result)

key_str

key_function(key)

setattr(Key, key_str, key_function)

command_re = re.compile("(:KEY:[\w]+)")
subsystem_commands=dict()
for result in command_re.findall(DS1000DE_Command_QuickReference):
    if result.startswith(":KEY"):
        key_str, key_function = key_factory2(result)
        subsystem_commands[key_str] = key_function

Key=type("Key", (Subsystem, ), subsystem_commands)

key=Key(device=device)

key.auto

key.auto()

key.auto()

key.device.reset()

key.channel1()

key.measure()





StarcoderdataJupyterScriptsDedupFiltered