Adapt demo due to direct core function access removal.

This commit is contained in:
Mikaël Ates 2013-10-07 15:39:56 +02:00
parent 99c9e0036a
commit 9292e30f32
1 changed files with 52 additions and 37 deletions

89
demo.py
View File

@ -21,7 +21,6 @@
Demo
'''
import models
import utils
import core_standard
@ -30,47 +29,15 @@ from stid_readers import core as stid_core
if __name__ == '__main__':
reader = models.RFIDReader()
print 'Get_RFSettings'
try:
command = models.ReaderCommand(command_name='Get_RFSettings',
reader=reader)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
logic_ports = stid_core.get_rfsettings(response)
i = 0
for logic_port in logic_ports:
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
print "Logic port: %s" % i
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
print "\tPowerAnt: %s dBm" % logic_port['PowerAnt']
print "\tAntNb: %s" % logic_port['AntNb']
i += 1
except Exception, err:
print str(err)
try:
logic_port = {\
'ScanDelay': 700,
'PowerAnt': 31,
'AntNb': 0,
}
logic_ports = [logic_port]
data = stid_core.set_rfsettings(logic_ports)
command = models.ReaderCommand(command_name='Set_RFSettings',
reader=reader, data=data)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
except Exception, err:
print str(err)
try:
command = models.ReaderCommand(command_name='Get_RFSettings',
reader=reader)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
logic_ports = stid_core.get_rfsettings(response)
i = 0
for logic_port in logic_ports:
for logic_port in response.processed_data:
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
print "Logic port: %s" % i
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
@ -79,13 +46,61 @@ if __name__ == '__main__':
i += 1
except Exception, err:
print str(err)
print 'Inventory'
try:
command = models.Command(command_name='Inventory')
response = reader.send(command)
command.pretty_print()
response.pretty_print()
tags = core_standard.inventory(response)
for tag in tags:
for tag in response.processed_data:
print "Tag: %s" % tag['EPC'].encode('hex')
print "\t Read on logic port: %s" % tag['AntID']
print "\t Times read on all logic ports: %s" % tag['NbRead']
except Exception, err:
print str(err)
print 'Set_RFSettings'
try:
logic_port = {\
'ScanDelay': 800,
'PowerAnt': 23,
'AntNb': 0,
}
logic_ports = [logic_port]
command = models.ReaderCommand(command_name='Set_RFSettings',
reader=reader, data_to_process=logic_ports)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
except Exception, err:
print str(err)
print 'Get_RFSettings'
try:
command = models.ReaderCommand(command_name='Get_RFSettings',
reader=reader)
response = reader.send(command)
command.pretty_print()
response.pretty_print()
i = 0
for logic_port in response.processed_data:
if logic_port['ScanDelay'] or logic_port['PowerAnt']:
print "Logic port: %s" % i
print "\tScanDelay: %s ms" % logic_port['ScanDelay']
print "\tPowerAnt: %s dBm" % logic_port['PowerAnt']
print "\tAntNb: %s" % logic_port['AntNb']
i += 1
except Exception, err:
print str(err)
print 'Inventory'
try:
command = models.Command(command_name='Inventory')
response = reader.send(command)
command.pretty_print()
response.pretty_print()
for tag in response.processed_data:
print "Tag: %s" % tag['EPC'].encode('hex')
print "\t Read on logic port: %s" % tag['AntID']
print "\t Times read on all logic ports: %s" % tag['NbRead']