Skip to content
Snippets Groups Projects
Commit 352431ce authored by jkerdreu's avatar jkerdreu
Browse files

Added comments

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/fork@1773 b32b6428-25c9-4566-ad07-03861ab6144f
parent 2bd2a57b
Branches
No related tags found
No related merge requests found
......@@ -29,7 +29,6 @@ from . import tools
import sys
import time
import inspect
import binascii
import collections
......@@ -61,15 +60,18 @@ class Engine(object):
# Devices management
#####################################################
def add_device(self, dev):
"""register a new device """
if dev not in self.devices:
self.devices.append(dev)
dev.engine = self
def add_devices(self, devs):
"""register new devices"""
for dev in devs:
self.add_device(dev)
def remove_device(self, dev):
"""unregister a device """
dev.engine = None
# Remove dev from devices list
self.devices.remove(dev)
......@@ -80,12 +82,11 @@ class Engine(object):
#####################################################
# Fifo for msg to send
def queue_tx(self, msg):
"""queue a message"""
self.__txFifo.append(msg)
def process_tx_msg(self):
""" Process (send) message in tx queue
called from the loop()
"""
""" Process (send) message in tx queue called from the loop()"""
while self.__txFifo:
temp = self.__txFifo.popleft()
self.send_msg(temp)
......@@ -94,21 +95,26 @@ class Engine(object):
self.network.send(msg)
def send_request(self,dev,targets,action,body = None):
"""queue a new request"""
msg = self.msg_factory.build_msg(dev, targets, 'request', action, body)
self.queue_tx(msg)
def send_reply(self, dev, targets, action, body=None):
"""queue a new reply"""
msg = self.msg_factory.build_msg(dev, targets, 'reply', action, body)
self.queue_tx(msg)
def send_error(self, dev, errcode, description=None):
"""queue a error message"""
msg = self.msg_factory.build_error_msg(dev, errcode, description)
self.queue_tx(msg)
def send_get_description(self,dev,targets):
"""queue a getDescription request"""
self.send_request(dev,targets,'getDescription')
def send_get_attributes(self,dev,targets):
"""queue a getAttributes request"""
self.send_request(dev,targets,'getAttributes')
#####################################################
......@@ -139,13 +145,15 @@ class Engine(object):
# xAAL attributes changes
#####################################################
def add_attributesChange(self, attr):
"""add a new attribute change to the list"""
self.__attributesChange.append(attr)
def get_attributesChange(self):
"""return the pending attributes changes list"""
return self.__attributesChange
def process_attributesChange(self):
"""Processes attributes change for all devices"""
"""Processes (send notify) attributes changes for all devices"""
devices = {}
# Group attributes changed by device
for attr in self.get_attributesChange():
......@@ -166,6 +174,7 @@ class Engine(object):
# xAAL messages rx handlers
#####################################################
def receive_msg(self):
"""return new received message or None"""
result = None
data = self.network.get_data()
if data:
......@@ -178,6 +187,7 @@ class Engine(object):
return result
def process_rx_msg(self):
"""process incomming messages"""
msg = self.receive_msg()
if msg:
self.handle_rx_msg(msg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment