from ctypes import *
from secg40 import *
import sys
import time

device = SECG40(get_lib_path())

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

print('device is connected... ({})'.format(device.get_serial_number()))

for lead in range(0, 2):
    if 0 != device.set_output_lead(lead, 1):
        print('set_output_lead(lead,1) failed')
    else:
        print('lead is', lead)

    if 0 != device.set_output_function(1):
        print('set_output_function(1) failed')
    else:
        print('Output Sine')
        time.sleep(5)
    
    pacingAmp = c_double(100)
    if 0 != device.set_pacing_amplitude(pacingAmp):
        print('set_pacing_amplitude(100.0) failed')
    else:
        print('Pacing Amp', device.get_pacing_amplitude())
        time.sleep(10)

    pacingAmp = c_double(-100)
    if 0 != device.set_pacing_amplitude(pacingAmp):
        print('set_pacing_amplitude(-100.0) failed')
    else:
        print('Pacing Amp', device.get_pacing_amplitude())
        time.sleep(10)

    pacingAmp = c_double(0)
    if 0 != device.set_pacing_amplitude(pacingAmp):
        print('set_pacing_amplitude(0) failed')        
    else:
        print('Pacing Amp', device.get_pacing_amplitude())
        time.sleep(10)

    if 0 != device.set_output_function(0):
        print('set_output_function(0) failed')
    else:
        print('Output Off')
    
device.close()
