from numato_usb_relay.relay import Relay

#Please change the number of Relays and COM Port accordingly.
#Numato(numberRelays=options.relays, port=options.port, baudrate=options.baudrate, timeout=options.timeout, name=options.name)
Device = Relay(numberRelays=2, port="COM27", name="powered")

#To get the version of the module
print(Device.ver())

#To get the Device Id 
print(Device.id_get())

Device.id_set("12345678")
print(Device.id_get())

#To turn on a single relay & read the status
for i in range(0,4):
    Device.relay_on(i) 

for i in range(0,4):
    print(Device.relay_read(i))

for i in range(0,4):
    Device.relay_off(i)

for i in range(0,4):
    print(Device.relay_read(i))


print(Device.relay_readall())
Device.relay_writeall("03")
print(Device.relay_readall())
Device.reset()


for i in range(0,5):
    Device.gpio_set(i)

for i in range(0,5):
    print(Device.gpio_read(i))

for i in range(0,5):
    Device.gpio_clear(i)

for i in range(0,5):
    print(Device.gpio_read(i))

for i in range(0,5):
    print(Device.adc_read(i))



#To get the Power Status of the module
print(Device.info())

#Setting the Gpio Power-On Direction & Value
Device.relay_poweron("01")

Device.gpio_poweron("00","0f")

print(Device.info())

