From 0443ae6a587e083db400c25e52c9a2fff3d1a582 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 26 Mar 2012 00:56:16 +0200 Subject: digital/io-hub: add support for several robots --- digital/io-hub/tools/io_hub/mex.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'digital/io-hub/tools/io_hub/mex.py') diff --git a/digital/io-hub/tools/io_hub/mex.py b/digital/io-hub/tools/io_hub/mex.py index 9b72ccde..a86a5b2d 100644 --- a/digital/io-hub/tools/io_hub/mex.py +++ b/digital/io-hub/tools/io_hub/mex.py @@ -28,10 +28,8 @@ import simu.mex.msg ADC_NB = 8 -PWM_NB = 6 PWM_VALUE_MAX = 1024 -CONTACT_NB = 10 CONTACT_INIT = 0xffffffff class Mex: @@ -200,16 +198,20 @@ class Mex: self.pos[id] = p self.notify () - def __init__ (self, node, instance = 'io-hub0'): + def __init__ (self, node, instance = 'io-hub0', + pwm_nb = 0, contact_nb = 0, codebar = False): self.adc = tuple (self.ADC (node, instance, i) for i in range (0, ADC_NB)) - self.pwm = tuple (self.PWM () for i in range (0, PWM_NB)) - self.__pwm_pack = self.PWM.Pack (node, instance, self.pwm) - self.__contact_pack = self.Contact.Pack (node, instance) - self.contact = tuple (self.Contact (self.__contact_pack, i) - for i in range (CONTACT_NB)) - self.__codebar_pack = self.Codebar.Pack (node, instance) - self.codebar = tuple (self.Codebar (self.__codebar_pack, i) - for i in (0, 1)) + if pwm_nb: + self.pwm = tuple (self.PWM () for i in range (0, pwm_nb)) + self.__pwm_pack = self.PWM.Pack (node, instance, self.pwm) + if contact_nb: + self.__contact_pack = self.Contact.Pack (node, instance) + self.contact = tuple (self.Contact (self.__contact_pack, i) + for i in range (contact_nb)) + if codebar: + self.__codebar_pack = self.Codebar.Pack (node, instance) + self.codebar = tuple (self.Codebar (self.__codebar_pack, i) + for i in (0, 1)) self.path = self.Path (node, instance) self.pos_report = self.PosReport (node, instance) -- cgit v1.2.3