from wecg400 import *

device = WECG400(get_lib_path())
if not device.connect(-1, 5000):
    print('Error: device is not connected')
    device.free()
    sys.exit()

print('set DC offset variable to +200mV ...', end='')
sys.stdout.flush()

dut = 0

device.reset()
device.set_dc_offset_variable_mode(dut, True)
device.set_dc_offset(dut, 200)
device.set_amplitude(0)
device.set_output_lead(OutputDut.DUT1.value, OutputLead.Lead_RA.value)
device.set_output_function(OutputFunction.Output_Sine.value)

time.sleep(10)
print('done')
device.set_output_function(OutputFunction.Output_Off.value)

# +500 mV
print('set DC offset variable to +500mV ...', end='')
sys.stdout.flush()
device.set_dc_offset(dut, 500)
device.set_output_function(OutputFunction.Output_Sine.value)

time.sleep(10)
print('done')
device.set_output_function(OutputFunction.Output_Off.value)

# -200 mV
print('set DC offset variable to -200mV ...', end='')
sys.stdout.flush()
device.set_dc_offset(dut, -200)
device.set_output_function(OutputFunction.Output_Sine.value)

time.sleep(10)
print('done')
device.set_output_function(OutputFunction.Output_Off.value)

# -500 mV
print('set DC offset variable to -500mV ...', end='')
sys.stdout.flush()
device.set_dc_offset(dut, -500)
device.set_output_function(OutputFunction.Output_Sine.value)

time.sleep(10)
device.set_dc_offset(dut, 0)
device.set_output_function(OutputFunction.Output_Off.value)  # stop output
device.free()

print('done')
