Skip to content
Snippets Groups Projects
Commit 75fa932e authored by jkerdreu's avatar jkerdreu
Browse files

- Added slots to avoid wrong attributes

- Fix properties in devices (don't know when this bug was introduced)


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2754 b32b6428-25c9-4566-ad07-03861ab6144f
parent 06d40d0c
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,8 @@ logger = logging.getLogger(__name__)
class EngineMixin(object):
__slots__ = ['devices','timers','subscribers','__attributesChange','network','msg_factory']
def __init__(self,address,port,hops,key):
self.devices = [] # list of devices / use (un)register_devices()
self.timers = [] # functions to call periodic
......
......@@ -76,19 +76,26 @@ class Attributes(list):
class Device(object):
__slots__ = ['__dev_type','__address','group_id',
'vendor_id','product_id','hw_id',
'__version','__url','schema','info',
'unsupported_attributes','unsupported_methods','unsupported_notifications',
'alive_period','next_alive',
'__attributes','methods','engine']
def __init__(self,dev_type,addr=None,engine=None):
# xAAL internal attributes for a device
self.dev_type = dev_type # xaal dev_type
self.address = addr # xaal addr
self.__dev_type = dev_type # xaal dev_type
self.__address = addr # xaal addr
self.group_id = None # group devices
self.vendor_id = None # vendor ID ie : ACME
self.product_id = None # product ID
self.version = None # product release
self.url = None # product URL
self.hw_id = None # hardware info
self.__version = None # product release
self.__url = None # product URL
self.schema = None # schema URL
self.info = None # additionnal info
self.hw_id = None # hardware info
self.group_id = None # group devices
# Unsupported stuffs
self.unsupported_attributes = []
self.unsupported_methods = []
......@@ -100,7 +107,7 @@ class Device(object):
self.__attributes = Attributes()
self.methods = {'get_attributes' : self._get_attributes,
'get_description': self._get_description }
self.engine = engine
self.engine = engine
@property
def dev_type(self):
......@@ -242,14 +249,14 @@ class Device(object):
result = {}
dev_attr = {attr.name: attr for attr in self.__attributes}
if _attributes:
"""Process attributes filter"""
# Process attributes filter
for attr in _attributes:
if attr in dev_attr.keys():
result.update({dev_attr[attr].name: dev_attr[attr].value})
else:
logger.debug(f"Attribute {attr} not found")
else:
"""Process all attributes"""
# Process all attributes
for attr in dev_attr.values():
result.update({attr.name: attr.value})
return result
......
......@@ -205,13 +205,15 @@ class MessageType(Enum):
class Message(object):
""" Message object used for incomming & outgoint message """
__slots__ = ['version', 'timestamp', 'source', 'dev_type', 'msg_type', 'action', 'body', '__targets']
def __init__(self):
self.version = config.STACK_VERSION # message API version
self.__targets = [] # target property
self.timestamp = None # message timestamp
self.source = None # message source
self.dev_type = None # message dev_type
self.msg_type = None # message type
self.dev_type = None # message dev_type
self.msg_type = None # message type
self.action = None # message action
self.body = {} # message body
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment