# import the class
from adam6000 import *
# connect using the specified IP address, default keep the connection open
try:
a=Adam6000('10.0.0.100')
except:
print 'no connection for this IP address'
else:
# set relay 0,5 to 1 and 1,2,3,4 to 0
ok,txt,msg=a.WriteRelay(0,1)
ok,txt,msg=a.WriteRelay(1,0)
ok,txt,msg=a.WriteRelay(2,0)
ok,txt,msg=a.WriteRelay(3,0)
ok,txt,msg=a.WriteRelay(4,0)
ok,txt,msg=a.WriteRelay(5,1)
# read the individual relay values back
ok,txt,val=a.ReadRelay(0)
ok,txt,val=a.ReadRelay(1)
ok,txt,val=a.ReadRelay(2)
ok,txt,val=a.ReadRelay(3)
ok,txt,val=a.ReadRelay(4)
ok,txt,val=a.ReadRelay(5)
# read all relay values back with one single call
ok,txt,val=a.ReadRelays()
# read all DI values with one single call
ok,txt,val=a.ReadDIs()
# read the individual DI values
ok,txt,val=a.ReadDI(0)
ok,txt,val=a.ReadDI(1)
ok,txt,val=a.ReadDI(2)
ok,txt,val=a.ReadDI(3)
ok,txt,val=a.ReadDI(4)
ok,txt,val=a.ReadDI(5)
# check the timeout (default 1.0 sec
print 'Timeout is',a.timeout
# set the new timeout to 2.0
a.timeout=2.0
print 'New Timeout is',a.timeout
# close the connection
a.close()
|