Skip to content
Snippets Groups Projects
Commit 0251ac14 authored by jkerdreu's avatar jkerdreu
Browse files

Added groupId

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/fork@1565 b32b6428-25c9-4566-ad07-03861ab6144f
parent 3d1e410f
No related branches found
No related tags found
No related merge requests found
......@@ -5,14 +5,16 @@ from xaal.lib import Device,Attribute
class OutputChannel(object):
def __init__(self,ipx,channel,addr,state_name):
def __init__(self,ipx,channel,addr,state_name,group):
dev = Device("changeme.basic",addr)
dev.vendor_id = "IHSEV"
dev.version = 0.1
dev.hw_id = channel
dev.group_id = group
# attribute
self.state = dev.new_attribute(state_name)
# method
dev.add_method('on',self.on)
dev.add_method('off',self.off)
......@@ -30,15 +32,15 @@ class OutputChannel(object):
self.state.value = False
def new_lamp(ipx,channel,addr):
lamp = OutputChannel(ipx,channel,addr,'light')
def new_lamp(ipx,channel,addr,group):
lamp = OutputChannel(ipx,channel,addr,'light',group)
lamp.dev.devtype = 'lamp.basic'
lamp.dev.product_id = 'IPX-800 Lamp'
return lamp
def new_relay(ipx,channel,addr):
relay = OutputChannel(ipx,channel,addr,'power')
def new_relay(ipx,channel,addr,group):
relay = OutputChannel(ipx,channel,addr,'power',group)
relay.dev.devtype = 'powerrelay.basic'
relay.dev.product_id = 'IPX-800 Power Relay'
return relay
......@@ -12,7 +12,7 @@ import socket
PACKAGE_NAME = "xaal.ipx800"
logger = tools.get_logger(PACKAGE_NAME,'DEBUG')
class IPX800(gevent.Greenlet):
class GW(gevent.Greenlet):
def __init__(self,engine):
gevent.Greenlet.__init__(self)
self.engine = engine
......@@ -35,14 +35,16 @@ class IPX800(gevent.Greenlet):
self.in_out=[]
i = 0
group = cfg['group']
for t in cfg['outputs_type']:
i = i+1
out = None
addr = '%s%02x' % (cfg['base_addr'][:-2],i)
if t == 'relay':
out = devices.new_relay(self,i,addr)
out = devices.new_relay(self,i,addr,group)
if t == 'lamp':
out = devices.new_lamp(self,i,addr)
out = devices.new_lamp(self,i,addr,group)
if out:
self.engine.add_device(out.dev)
self.in_out.append(out)
......@@ -96,7 +98,7 @@ class IPX800(gevent.Greenlet):
def run():
eng = Engine()
ipx = IPX800.spawn(eng)
ipx = GW.spawn(eng)
eng.run()
def main():
......
......@@ -70,6 +70,7 @@ class Device(object):
self.url = None # product URL
self.info = None # additionnal info
self.hw_id = None # hardware info
self.group_id = None # group devices
self.unsupported_attributes = []
self.unsupported_methods = []
......@@ -170,12 +171,13 @@ class Device(object):
#####################################################
def _get_description(self):
result = {}
if self.vendor_id: result['vendorID'] = self.vendor_id
if self.product_id: result['productID'] = self.product_id
if self.vendor_id: result['vendorId'] = self.vendor_id
if self.product_id: result['productId'] = self.product_id
if self.version: result['version'] = self.version
if self.url: result['url'] = self.url
if self.info: result['info'] = self.info
if self.hw_id: result['hw_id'] = self.hw_id
if self.hw_id: result['hwId'] = self.hw_id
if self.group_id: result['groupId'] = self.group_id
result['unsupportedMethods'] = self.unsupported_methods
result['unsupportedNotifications'] = self.unsupported_notifications
result['unsupportedAttributes'] = self.unsupported_attributes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment