##// END OF EJS Templates
Se realizar la lectura en modo online llamando al metodo digitalRFReader(self.path) en reemplazo del metodo reload(), grabando previamente el path de lectura o directorio superior donde se almacena la data. Adicionalmente, se ha definido un tiempo de espera de 3 segundos para dar tiempo suficiente al programa de adquisicion de generar archivos. ...
Se realizar la lectura en modo online llamando al metodo digitalRFReader(self.path) en reemplazo del metodo reload(), grabando previamente el path de lectura o directorio superior donde se almacena la data. Adicionalmente, se ha definido un tiempo de espera de 3 segundos para dar tiempo suficiente al programa de adquisicion de generar archivos. El archivo jroIO_digitalRF.py utiliza la libreria digital_rf cuya version actual es la 2.62( 2017 ) ,esta libreria no tiene definido el metodo o clase reload, este metodo existe en la version 2.0(2014), si uno revisa el archivo jroIO_usrp.py, esta unidad de lectura trabaja con la version 2.0 llamada digital_rf_hdf5, para hacer uso de esta unidad de lectura se instalan los programas correspondiente pero el formato y la informacion difiere un poco de la version actual. Se infiere entonces que al desarrollar del archivo jroIO_digitalRF.py, esperaba que la libreria aun tenga incluido el metodo reload con el update de las versiones pero este ya no es parte del desarrollo, Se realizo la consulta al desarrollador actual de digitalRF Ryan Voltz si se iba a incluir a futuro pero indico que no era necesario.

File last commit:

r697:7ac8878019bb
r1234:b6a76136b1f3
Show More
serialtest.py
187 lines | 6.1 KiB | text/x-python | PythonLexer
#
# when Serializer is imported alone, fault indicates this package is
# dependent on lookup, but don't import Lookup, instead:
#
import DynamicObject # dependent on pysvn
import Serializer # dependent on Dynamic Object
import msgpack
import redis
import numpy as np
class NamedObject():
#---------------------------------------------
@staticmethod
def indexListMatch(list_of_lists, name, value, name2=None, value2=None, unique_f=False):
#
# for each list's <element> attribute compare with value
# if match, return True plus list
# else return False plus empty list
#
# search needs to be named part of class for object else .<value> is unrecognized
#
# unique_f finds non-uniqueness
index = [] # return empty indices
list_data = [] # return empty list
ii = 0
for theList in list_of_lists:
cmd0 = "theList.%s == value" % (name)
cmd1 = "isInlist(theList.%s,value)" % name
# if name is valid then
# match name against value
# match name (as list) against value
if (eval(cmd0) or eval(cmd1)):
if (name2 != None):
cmd2 = "theList.%s == value2" % name2
cmd3 = "isInlist(theList.%s,value2)" % name2
if (eval(cmd2) or eval(cmd3)):
if (unique_f):
index = index + [ii]
list_data = list_data + [theList] # save list of lists if non-unique
# don't exit on match, may be non-unique
else:
list_data = theList # save the list
index = [ii]
break
else:
if (unique_f):
index = index + [ii]
list_data = list_data + [theList] # list of lists if non-unique
else:
list_data = theList
index = [ii]
break # exit on match
#endif
ii = ii + 1
#end for
return index, list_data # return indices of matches and list (or list of lists)
#end indexListMatch
#---------------------------------------------
@staticmethod
def namedListMatch(list_of_lists, name, value, name2=None, value2=None, unique_f=None):
#
# for each list's <element> attribute compare with value
# if match, return True plus list
# else return False plus empty list
#
# search needs to be named part of class for object else .<value> is unrecognized
#
# unique_f finds non-uniqueness ('None' is same as False)
match_f = False
list_data = [] # initialize
for theList in list_of_lists:
cmd0 = "theList.%s == value" % (name)
cmd1 = "isInlist(theList.%s,value)" % name
# if name is valid then
# match name against value
# match name (as list) against value
if (eval(cmd0) or eval(cmd1)):
if (name2 != None):
cmd2 = "theList.%s == value2" % name2
cmd3 = "isInlist(theList.%s,value2)" % name2
if (eval(cmd2) or eval(cmd3)):
match_f = True
if (unique_f):
list_data = list_data + [theList] # save list of lists if non-unique
# don't exit on match, may be non-unique
else:
list_data = theList # save the list
break
else:
match_f = True
if (unique_f):
list_data = list_data + [theList] # list of lists if non-unique
else:
list_data = theList
break # exit on match
#endif
#end for
return match_f, list_data # return match, and list (or list of lists)
#end namedListMatch
#---------------------------------------------
@staticmethod
def combineLists(object):
#
# used for dumping elements in list of lists for debugging
#
ret_list =[]
ii = 0
while ii < len(object):
ret_list = ret_list + [object[ii].list] # not a real list, so can't use built-in list iterator
ii = ii + 1
return ret_list
# end combineLists
class StateListObject(NamedObject):
def __init__(self, concurrent=None, hierarchical=None, history=None, state=None):
self.concurrent = concurrent
self.hierarchical = hierarchical
self.history = history
self.state = state
self.list = [self.concurrent, self.hierarchical, self.history, self.state ]
#end class StateListObject
source_object = "my test string"
serializer = "yaml"
#
# python versioning issue (ver 2.7 -> else path)
#
if isinstance(serializer,Serializer.Serializer):
serial_type = Serializer.serial_types[serializer]
else:
serial_type = serializer
serializer = Serializer.serializers[serializer]()
datastr = serializer.toSerial(source_object)
dest_object = serializer.fromSerial(datastr)
print "dest_object=",dest_object
myObject = StateListObject(hierarchical="yes",state=np.array([1,2,3.0]))
datastr = serializer.toSerial(myObject)
packed = msgpack.packb(datastr)
try:
r= redis.StrictRedis(host='localhost',port=6379,db=0)
except Exception as eobj:
print "is the redis server running?",eobj
else:
r.set('baz',packed) # converts to string
x = r.get('baz')
unpacked = msgpack.unpackb(x)
dest_object = serializer.fromSerial(unpacked)
print "val1=",dest_object.hierarchical
val2 = dest_object.state
print "val2=",val2
# can numpy array be used as array?
print val2.shape