| ||||||
|
Allows access to ADAM 6050, 6051, 6017 and other 6000 series cards. Source code tested with ADAM-6051 model. More information: Advantech Web Methods:
For all functions a tuple ok,txt,val/msg is returned. If success - ok is 1 and data is found in val. If Failure - ok is 0 and error text found in txt. Example 1: Read the 1st and the 2nd (0 and 1 channel)digital inputs
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,val=a.ReadInput(0)
print 'ReadInput(0):',val
ok,txt,val=a.ReadInput(1)
print 'ReadInput(1):',val
a.close
except:
print 'exeption'
Example 2: Read multiple inputs
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,val=a.ReadWord(0x0000)
print 'ReadWord(0x0000):',val
a.close
except:
print 'exeption'
Example 3: Write the 1st and the 2nd (0 and 1 channel) digital outputs
# 0 and 1 output channel set to 1
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,msg=a.WriteOutput(0,1)
print 'WriteOutput(0,1):',txt
ok,txt,msg=a.WriteOutput(1,1)
print 'WriteOutput(1,1):',txt
a.close
except:
print 'exeption'
Example 4: Write multiple outputs
# 1 output channel set to 1, 0 and others channels set to 0
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,msg=a.WriteWord(2,0x0002)
print 'WriteWord(2,0x0002):',txt
a.close
except:
print 'exeption'
Example 5: Read the 1st and the 2nd counter/frequency (only for ADAM-6051)
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,val=a.ReadCounter(0)
print 'ReadCounter(0):',val
ok,txt,val=a.ReadCounter(1)
print 'ReadCounter(1):',val
a.close
except:
print 'exeption'
Example 6: Read the 1st channel counter/frequency value
from adam6000 import *
try:
a=Adam6000('10.0.0.100')
ok,txt,val=a.ReadRegisterWord(2)
print 'ReadRegisterWord(2):',val
a.close
except:
print 'exeption'
|
|