import sys
import time
from ctypes import *
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 to +300mV ...', end='')
sys.stdout.flush()

dut = OutputDut.DUT1.value

device.reset()
device.set_dc_offset_variable_mode(dut, False)
device.set_dc_offset(dut, 300)
device.set_amplitude(0)
device.set_output_lead(dut, 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)

print('set DC offset to -300mV ...', end='')
sys.stdout.flush()

device.set_dc_offset(dut, -300)
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')
