6 Copyright (C) 2009-2010 8 RT-Synthesis Research Group 9 Intelligent Systems Research Institute, 10 National Institute of Advanced Industrial Science and Technology (AIST), 13 Licensed under the Eclipse Public License -v 1.0 (EPL) 14 http://www.opensource.org/licenses/eclipse-1.0.txt 18 Objects representing targets. These can be target components, execution 23 __version__ =
'$Revision: $' 27 from rtsprofile
import RTS_NS, RTS_NS_S, RTS_EXT_NS, RTS_EXT_NS_S, \
30 parse_properties_xml, properties_to_xml, \
38 '''Stores enough information to uniquely identify a component in the RT 39 system. Used to specify target components, for example the components 40 participating in a group or running in an execution context, or the 41 execution order of components. 45 def __init__(self, component_id='', instance_name=''):
48 @param component_id The ID of the target component. 49 @type component_id str 50 @param instance_name The instance name of the target component. 51 @type instance_name str 55 expected_type=[str, unicode], required=
False)
58 expected_type=[str, unicode], required=
False)
63 result =
'Component ID: {0}\nInstance name: {1}\n'.format(\
66 result +=
'Properties:\n' 68 result +=
' {0}: {1}\n'.format(p, self.
properties[p])
73 '''The ID of the target component. 75 RT components can be uniquely identified using the component ID and the 84 expected_type=[str, unicode], required=
True)
89 '''The instance name of the target component. 91 RT components can be uniquely identified using the component ID and the 100 expected_type=[str, unicode], required=
True)
105 '''Miscellaneous properties. 107 Stores key/value pair properties. 109 Part of the extended profile. 117 expected_type=dict, required=
False)
121 '''Parse an xml.dom Node object representing a target component into 127 for c
in node.getElementsByTagNameNS(RTS_EXT_NS,
'Properties'):
133 '''Parse a YAML specification of a target component into this 139 if RTS_EXT_NS_YAML +
'properties' in y:
140 for p
in y.get(RTS_EXT_NS_YAML +
'properties'):
149 '''Save this target component into an xml.dom.Element object.''' 150 element.setAttributeNS(RTS_NS, RTS_NS_S +
'componentId',
152 element.setAttributeNS(RTS_NS, RTS_NS_S +
'instanceName',
155 new_prop_element = doc.createElementNS(RTS_EXT_NS,
156 RTS_EXT_NS_S +
'Properties')
158 element.appendChild(new_prop_element)
161 '''Save this target component into a dictionary.''' 171 d[RTS_EXT_NS_YAML +
'properties'] = props
179 '''Stores enough information to uniquely identify a port on a component in 180 the RT system. Used to specify target ports in connections. 184 def __init__(self, component_id='', instance_name='', port_name=''):
185 '''Constructor. See also the @ref TargetComponent constructor. 187 @param port_name The name of the target port. 191 super(TargetPort, self).
__init__(component_id, instance_name)
193 expected_type=[str, unicode], required=
False)
197 return TargetComponent.__str__(self) +
'\nPort name: {0}'.format(\
202 '''The ID of the target port.''' 208 expected_type=[str, unicode], required=
True)
212 '''Parse an xml.dom Node object representing a target port into this 217 self.
port_name = node.getAttributeNS(RTS_NS,
'portName')
221 '''Parse a YAML specification of a target port into this object.''' 227 '''Save this target port into an xml.dom.Element object.''' 228 super(TargetPort, self).
save_xml(doc, element)
229 element.setAttributeNS(RTS_NS, RTS_NS_S +
'portName', self.
port_name)
232 '''Save this target port into a dictionary.''' 233 d = super(TargetPort, self).
to_dict()
242 '''Stores enough information to uniquely identify an execution context in 243 the RT system. Used to specify target execution contexts of components that 244 are used to manage execution order, execution conditions, and so on. An 245 RT component may hold multiple execution contexts. The execution context 246 concerned must be specified when activating, shutting down, etc an RT 251 def __init__(self, component_id='', instance_name='', id=''):
252 '''Constructor. See also the @ref TargetComponent constructor. 254 @param id The ID of the target execution context. 258 super(TargetExecutionContext, self).
__init__(component_id,
261 expected_type=[str, unicode], required=
False)
266 result = TargetComponent.__str__(self) +
'\nID: {0}\n'.format(self.
id)
268 result +=
'Properties:\n' 270 result +=
' {0}: {1}\n'.format(p, self.
properties[p])
275 '''The ID of the target execution context.''' 281 expected_type=[str, unicode], required=
True)
286 '''Miscellaneous properties. 288 Stores key/value pair properties. 290 Part of the extended profile. 298 'target_executioncontext.ext.Properties',
299 expected_type=dict, required=
False)
303 '''Parse an xml.dom Node object representing a target execution context 308 if node.hasAttributeNS(RTS_NS,
'id'):
309 self.
id = node.getAttributeNS(RTS_NS,
'id')
315 '''Parse a YAML specification of a target execution context into this 319 super(TargetExecutionContext, self).
parse_yaml(y)
327 '''Save this target execution context into an xml.dom.Element 331 super(TargetExecutionContext, self).
save_xml(doc, element)
332 element.setAttributeNS(RTS_NS, RTS_NS_S +
'id', self.
id)
335 '''Save this target execution context into a dictionary.''' 336 d = super(TargetExecutionContext, self).
to_dict()
def __init__(self, component_id='', instance_name='', id='')
def save_xml(self, doc, element)
def parse_xml_node(self, node)
def save_xml(self, doc, element)
def parse_xml_node(self, node)
def save_xml(self, doc, element)
def properties_to_xml(element, name, value=None)
def parse_properties_xml(node)
def validate_attribute(attr, name, expected_type=None, required=False)
def __init__(self, component_id='', instance_name='')
TargetExecutionContext object.
def parse_xml_node(self, node)
def __init__(self, component_id='', instance_name='', port_name='')