diff --git a/examples/communication/xml/communication.dtd b/examples/communication/xml/communication.dtd index c2e9322b1..1540afe8c 100644 --- a/examples/communication/xml/communication.dtd +++ b/examples/communication/xml/communication.dtd @@ -79,4 +79,5 @@ diff --git a/examples/communication/xml/communication.xml b/examples/communication/xml/communication.xml index e2bfbda2b..6f6044064 100644 --- a/examples/communication/xml/communication.xml +++ b/examples/communication/xml/communication.xml @@ -71,24 +71,24 @@ - + - + - + - + - + diff --git a/tools/system_design/builder/cpp_identifier.py b/tools/system_design/builder/cpp_identifier.py index dee807b45..daa4b17e9 100644 --- a/tools/system_design/builder/cpp_identifier.py +++ b/tools/system_design/builder/cpp_identifier.py @@ -55,6 +55,7 @@ def generate(self): cppFilter = { 'enumElement': filter.enumElement, + 'enumElementStrong': filter.typeName, 'enumValue': filter.toHexValue, } @@ -66,6 +67,7 @@ def generate(self): substitutions = { 'domains' : self.tree.domains, + 'containers' : self.tree.containers, 'components': components, 'actions': self.tree.components.actions, 'events': self.tree.events, diff --git a/tools/system_design/builder/templates/robot_identifier.tpl b/tools/system_design/builder/templates/robot_identifier.tpl index 5e63ac54c..ea0adadfd 100644 --- a/tools/system_design/builder/templates/robot_identifier.tpl +++ b/tools/system_design/builder/templates/robot_identifier.tpl @@ -35,6 +35,16 @@ namespace {{ namespace }} } } } + + namespace container + { + enum class Identifier : uint8_t + { + {%- for item in containers %} + {{ item.name | enumElementStrong }} = {{ item.id | enumValue }}, + {%- endfor %} + }; + } namespace component { diff --git a/tools/system_design/xml/dtd/rca_container.dtd b/tools/system_design/xml/dtd/rca_container.dtd index d3beab695..899bb68e4 100644 --- a/tools/system_design/xml/dtd/rca_container.dtd +++ b/tools/system_design/xml/dtd/rca_container.dtd @@ -13,6 +13,7 @@ diff --git a/tools/system_design/xmlparser/container.py b/tools/system_design/xmlparser/container.py index 2eeed2efb..3dbb9bcc6 100644 --- a/tools/system_design/xmlparser/container.py +++ b/tools/system_design/xmlparser/container.py @@ -9,9 +9,11 @@ class Container: """ Representation of a container which bundles components. + For microcontrollers, each container runs on a separate controller. Attributes: name -- Name of the container + id -- Globally unique identifier of the container (0..255). bootloader -- Information about a bootloader used to program this container. description -- Description string @@ -43,6 +45,7 @@ def __init__(self, node): self.bootloader = bootloader self.description = xml_utils.get_description(node) + self.id = xml_utils.get_identifier(self.node) self.components = None self.events = EventContainer() @@ -95,7 +98,7 @@ def updateIndex(self): self.indexReady = True def __cmp__(self, other): - return cmp(self.name.lower(), other.name.lower()) + return cmp(self.name.lower(), other.name.lower()) or cmp(self.id, other.id) def dump(self): str = "%s : container\n" % self.__str__() @@ -104,4 +107,8 @@ def dump(self): return str[:-1] def __str__(self): - return self.name + if self.id is None: + name = "[--] %s" % self.name + else: + name = "[%02x] %s" % (self.id, self.name) + return name