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()

pulseWidth = device.get_pulse_width()
print('Initial Pulse Widht: ', pulseWidth, ' ms')

device.set_output_function(OutputFunction_E.Output_RectanglePulse.value)
print('Output ', OutputFunction_E(device.get_output_function()), ' signal with ', pulseWidth, ' ms Pulse Width')
time.sleep(5)

device.set_output_function(OutputFunction_E.Output_Off.value)
device.set_output_function(OutputFunction_E.Output_TrianglePulse.value)
print('Output ', OutputFunction_E(device.get_output_function()), ' signal with ', pulseWidth, ' ms Pulse Width')
time.sleep(5)

device.set_output_function(OutputFunction_E.Output_Off.value)
pulseWidth = c_double(200)
if 0 == device.set_pulse_width(pulseWidth):
    print('Set Pulse Width to ', device.get_pulse_width())

device.set_output_function(OutputFunction_E.Output_RectanglePulse.value)
print('Output ', OutputFunction_E(device.get_output_function()), ' signal with ', device.get_pulse_width(), ' ms Pulse Width')
time.sleep(5)

device.close()
