signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
|---|---|---|---|
@property<EOL><INDENT>def properties(self):<DEDENT>
|
return self._properties<EOL>
|
Miscellaneous properties.
Stores key/value pair properties.
Part of the extended profile.
Example:
>>> s = RtsProfile()
>>> s.properties = {'key':'value'}
Invalid assignment should throw exception:
>>> s.properties = 1
Traceback (most recent call last):
...
InvalidTypeError: ('rtsprofile.ext.Properties', <type 'int'>, <type 'dict'>)
|
f5228:c0:m38
|
def find_comp_by_target(self, target):
|
for comp in self._components:<EOL><INDENT>if comp.id == target.component_id andcomp.instance_name == target.instance_name:<EOL><INDENT>return comp<EOL><DEDENT><DEDENT>raise MissingComponentError<EOL>
|
Finds a component using a TargetComponent or one of its subclasses.
@param A @ref TargetComponent object or subclass of @ref
TargetComponent.
@return A Component object matching the target.
@raises MissingComponentError
|
f5228:c0:m40
|
def optional_data_connections(self):
|
result = []<EOL>for conn in self._data_port_connectors:<EOL><INDENT>source_comp = self.find_comp_by_target(conn.source_data_port)<EOL>target_comp = self.find_comp_by_target(conn.target_data_port)<EOL>if not source_comp.is_required or not target_comp.is_required:<EOL><INDENT>result.append(conn)<EOL><DEDENT><DEDENT>return result<EOL>
|
Finds all data connections in which one or more components are not
required.
If all the components involved in a connection are required, that
connection is also required. If one or more are not required, that
connection is optional.
Example:
>>> s = RtsProfile(xml_spec=open('test/rtsystem.xml').read())
>>> len(s.optional_data_connections())
0
|
f5228:c0:m41
|
def optional_service_connections(self):
|
result = []<EOL>for conn in self._service_port_connectors:<EOL><INDENT>source_comp = self.find_comp_by_target(conn.source_service_port)<EOL>target_comp = self.find_comp_by_target(conn.target_service_port)<EOL>if not source_comp.is_required or not target_comp.is_required:<EOL><INDENT>result.append(conn)<EOL><DEDENT><DEDENT>return result<EOL>
|
Finds all service connections in which one or more components are
not required.
If all the components involved in a connection are required, that
connection is also required. If one or more are not required, that
connection is optional.
Example:
>>> s = RtsProfile(xml_spec=open('test/rtsystem.xml').read())
>>> len(s.optional_service_connections())
0
|
f5228:c0:m42
|
def required_data_connections(self):
|
result = []<EOL>for conn in self._data_port_connectors:<EOL><INDENT>source_comp = self.find_comp_by_target(conn.source_data_port)<EOL>target_comp = self.find_comp_by_target(conn.target_data_port)<EOL>if source_comp.is_required and target_comp.is_required:<EOL><INDENT>result.append(conn)<EOL><DEDENT><DEDENT>return result<EOL>
|
Finds all data connections in which all components are required.
If all the components involved in a connection are required, that
connection is also required. If one or more are not required, that
connection is optional.
Example:
>>> s = RtsProfile(xml_spec=open('test/rtsystem.xml').read())
>>> len(s.required_data_connections())
2
|
f5228:c0:m43
|
def required_service_connections(self):
|
result = []<EOL>for conn in self._service_port_connectors:<EOL><INDENT>source_comp = self.find_comp_by_target(conn.source_service_port)<EOL>target_comp = self.find_comp_by_target(conn.target_service_port)<EOL>if source_comp.is_required and target_comp.is_required:<EOL><INDENT>result.append(conn)<EOL><DEDENT><DEDENT>return result<EOL>
|
Finds all service connections in which all components are required.
If all the components involved in a connection are required, that
connection is also required. If one or more are not required, that
connection is optional.
Example:
>>> s = RtsProfile(xml_spec=open('test/rtsystem.xml').read())
>>> len(s.required_service_connections())
1
|
f5228:c0:m44
|
def parse_from_xml(self, xml_spec):
|
if type(xml_spec) in string_types():<EOL><INDENT>dom = xml.dom.minidom.parseString(xml_spec)<EOL><DEDENT>else:<EOL><INDENT>dom = xml.dom.minidom.parse(xml_spec)<EOL><DEDENT>self._parse_xml(dom)<EOL>dom.unlink()<EOL>
|
Parse a string or file containing an XML specification.
Example:
>>> s = RtsProfile()
>>> s.parse_from_xml(open('test/rtsystem.xml'))
>>> len(s.components)
3
Load of invalid data should throw exception:
>>> s.parse_from_xml('non-XML string')
Traceback (most recent call last):
...
ExpatError: syntax error: line 1, column 0
|
f5228:c0:m45
|
def save_to_xml(self):
|
xml_obj = self._to_xml_dom()<EOL>return xml_obj.toprettyxml(indent='<STR_LIT:U+0020>')<EOL>
|
Save this RtsProfile into an XML-formatted string.
Example:
>>> input = xml.dom.minidom.parse(open('test/rtsystem.xml')).toprettyxml(indent=' ')
>>> input = '\\n'.join([l for l in input.split('\\n') if l.strip() != ''])
>>> s = RtsProfile(xml_spec=input)
>>> output = s.save_to_xml()
>>> open('/tmp/rtsystem-input.xml', 'w').write(input)
>>> open('/tmp/rtsystem-output.xml', 'w').write(output)
>>> import difflib
>>> print('\\n'.join(list(difflib.unified_diff(input.splitlines(), output.splitlines(), 'input', 'output'))))
<BLANKLINE>
|
f5228:c0:m46
|
def parse_from_yaml(self, yaml_spec):
|
self._parse_yaml(yaml.safe_load(yaml_spec))<EOL>
|
Parse a string or file containing a YAML specification.
Example:
>>> s = RtsProfile()
>>> s.parse_from_yaml(open('test/rtsystem.yaml'))
>>> len(s.components)
3
Load of invalid data should throw exception:
>>> s.parse_from_yaml('non-YAML string')
Traceback (most recent call last):
...
RtsProfileError: Missing root node.
|
f5228:c0:m47
|
def save_to_yaml(self):
|
return self._to_yaml()<EOL>
|
Save this RtsProfile into a YAML-formatted string.
Example:
>>> input = yaml.safe_dump(yaml.safe_load(open('test/rtsystem.yaml')))
>>> s = RtsProfile()
>>> s.parse_from_yaml(input)
>>> output = s.save_to_yaml()
>>> import difflib
>>> print('\\n'.join(list(difflib.unified_diff(input.splitlines(), output.splitlines(), 'input', 'output'))))
<BLANKLINE>
|
f5228:c0:m48
|
def __init__(self, targets=[]):
|
validate_attribute(targets, '<STR_LIT>',<EOL>expected_type=list, required=False)<EOL>self._targets = targets<EOL>
|
@param targets Orderings and conditions.
|
f5229:c0:m0
|
@property<EOL><INDENT>def targets(self):<DEDENT>
|
return self._targets<EOL>
|
Orderings and conditions.
|
f5229:c0:m2
|
def parse_xml_node(self, node):
|
self._targets = []<EOL>for c in node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>if c.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>new_target = WaitTime()<EOL><DEDENT>elif c.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>new_target = Preceding()<EOL><DEDENT>else:<EOL><INDENT>new_target = Condition()<EOL><DEDENT>new_target.parse_xml_node(c)<EOL>self._targets.append(new_target)<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a message sending object
into this object.
|
f5229:c0:m4
|
def parse_yaml(self, y):
|
self._targets = []<EOL>if '<STR_LIT>' in y:<EOL><INDENT>for t in y['<STR_LIT>']:<EOL><INDENT>if '<STR_LIT>' in t['<STR_LIT>']:<EOL><INDENT>new_target = WaitTime()<EOL><DEDENT>elif '<STR_LIT>' in t['<STR_LIT>']:<EOL><INDENT>new_target = Preceding()<EOL><DEDENT>else:<EOL><INDENT>new_target = Condition()<EOL><DEDENT>new_target.parse_yaml(t)<EOL>self._targets.append(new_target)<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML speficication of a message sending object into this
object.
|
f5229:c0:m5
|
def save_xml(self, doc, element):
|
for cond in self._targets:<EOL><INDENT>new_element = doc.createElementNS(RTS_NS, RTS_NS_S + '<STR_LIT>')<EOL>new_element.setAttributeNS(XSI_NS, XSI_NS_S + '<STR_LIT:type>', '<STR_LIT>')<EOL>cond.save_xml(doc, new_element)<EOL>element.appendChild(new_element)<EOL><DEDENT>
|
Save this message_sending object into an xml.dom.Element object.
|
f5229:c0:m6
|
def to_dict(self):
|
targets = []<EOL>for cond in self._targets:<EOL><INDENT>targets.append(cond.to_dict())<EOL><DEDENT>if targets:<EOL><INDENT>return {'<STR_LIT>': targets}<EOL><DEDENT>else:<EOL><INDENT>return {}<EOL><DEDENT>
|
Save this message sending object into a dictionary.
|
f5229:c0:m7
|
def __init__(self, sequence=<NUM_LIT:0>, target_component=TargetExecutionContext()):
|
validate_attribute(sequence, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._sequence = sequence<EOL>validate_attribute(target_component, '<STR_LIT>',<EOL>expected_type=TargetExecutionContext,<EOL>required=True)<EOL>self._target_component = target_component<EOL>self._properties = {}<EOL>
|
Constructor.
@param sequence Execution order of the target component.
@type sequence int
@param target_component The target of the condition.
@type target_component TargetComponent
|
f5229:c8:m0
|
@property<EOL><INDENT>def sequence(self):<DEDENT>
|
return self._sequence<EOL>
|
The execution order of the target components for the various
actions.
|
f5229:c8:m2
|
@property<EOL><INDENT>def target_component(self):<DEDENT>
|
return self._target_component<EOL>
|
Target component of the condition.
|
f5229:c8:m4
|
@property<EOL><INDENT>def properties(self):<DEDENT>
|
return self._properties<EOL>
|
Miscellaneous properties.
Stores key/value pair properties.
Part of the extended profile.
|
f5229:c8:m6
|
def parse_xml_node(self, node):
|
self.sequence = int(node.getAttributeNS(RTS_NS, '<STR_LIT>'))<EOL>c = node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>')<EOL>if c.length != <NUM_LIT:1>:<EOL><INDENT>raise InvalidParticipantNodeError<EOL><DEDENT>self.target_component = TargetExecutionContext().parse_xml_node(c[<NUM_LIT:0>])<EOL>for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,<EOL>local_name='<STR_LIT>'):<EOL><INDENT>name, value = parse_properties_xml(c)<EOL>self._properties[name] = value<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a condition into this
object.
|
f5229:c8:m8
|
def parse_yaml(self, y):
|
self.sequence = int(y['<STR_LIT>'])<EOL>self.target_component =TargetExecutionContext().parse_yaml(y['<STR_LIT>'])<EOL>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>for p in y.get(RTS_EXT_NS_YAML + '<STR_LIT>'):<EOL><INDENT>if '<STR_LIT:value>' in p:<EOL><INDENT>value = p['<STR_LIT:value>']<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>self._properties[p['<STR_LIT:name>']] = value<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML specification of a condition into this object.
|
f5229:c8:m9
|
def save_xml(self, doc, element):
|
element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>',<EOL>str(self.sequence))<EOL>new_element = doc.createElementNS(RTS_NS, RTS_NS_S + '<STR_LIT>')<EOL>self.target_component.save_xml(doc, new_element)<EOL>element.appendChild(new_element)<EOL>for p in self.properties:<EOL><INDENT>new_prop_element = doc.createElementNS(RTS_EXT_NS,<EOL>RTS_EXT_NS_S + '<STR_LIT>')<EOL>properties_to_xml(new_prop_element, p, self.properties[p])<EOL>element.appendChild(new_prop_element)<EOL><DEDENT>
|
Save this condition into an xml.dom.Element object.
|
f5229:c8:m10
|
def to_dict(self):
|
d = {'<STR_LIT>': self.sequence,<EOL>'<STR_LIT>': self.target_component.to_dict()}<EOL>props = []<EOL>for name in self.properties:<EOL><INDENT>p = {'<STR_LIT:name>': name}<EOL>if self.properties[name]:<EOL><INDENT>p['<STR_LIT:value>'] = str(self.properties[name])<EOL><DEDENT>props.append(p)<EOL><DEDENT>if props:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = props<EOL><DEDENT>return d<EOL>
|
Save this condition into a dictionary.
|
f5229:c8:m11
|
def __init__(self, sequence=<NUM_LIT:0>, target_component=TargetExecutionContext(),<EOL>timeout=<NUM_LIT:0>, sending_timing='<STR_LIT>', preceding_components=[]):
|
super(Preceding, self).__init__(sequence, target_component)<EOL>validate_attribute(timeout, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._timeout = timeout<EOL>validate_attribute(sending_timing, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._sending_timing = sending_timing<EOL>validate_attribute(preceding_components,<EOL>'<STR_LIT>',<EOL>expected_type=list, required=False)<EOL>self._preceding_components = preceding_components<EOL>
|
Constructor.
@param sequence Execution order of the target component.
@type sequence int
@param target_component The target of the condition.
@type target_component TargetComponent
@param timeout Status check timeout.
@type timeout int
@param sending_timing Timing for executing actions.
@type sending_timing str
@param preceding_components Preceding components of the condition.
@type preceding components list(TargetExecutionContext)
|
f5229:c9:m0
|
@property<EOL><INDENT>def timeout(self):<DEDENT>
|
return self._timeout<EOL>
|
Time out for checking if the target component has executed the
action successfully.
Can be zero. Specified in milliseconds.
|
f5229:c9:m2
|
@property<EOL><INDENT>def sending_timing(self):<DEDENT>
|
return self._sending_timing<EOL>
|
Timing for executing actions.
Either wait for the preceding RT component to finish executing the
action (specified by "SYNC"), or execute the action without waiting for
the preceding RT component to finish (specified by "ASYNC"). When not
specified, the first option will be assumed.
|
f5229:c9:m4
|
@property<EOL><INDENT>def preceding_components(self):<DEDENT>
|
return self._preceding_components<EOL>
|
Preceding components of this condition.
|
f5229:c9:m6
|
def parse_xml_node(self, node):
|
super(Preceding, self).parse_xml_node(node)<EOL>p_nodes = node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>')<EOL>if p_nodes.length != <NUM_LIT:1>:<EOL><INDENT>raise InvalidParticipantNodeError<EOL><DEDENT>p_node = p_nodes[<NUM_LIT:0>]<EOL>if p_node.hasAttributeNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self.timeout = int(p_node.getAttributeNS(RTS_NS, '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>self.timeout = <NUM_LIT:0><EOL><DEDENT>if p_node.hasAttributeNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self.sending_timing = p_node.getAttributeNS(RTS_NS, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self.sending_timing = '<STR_LIT>'<EOL><DEDENT>self._preceding_components = []<EOL>for c in p_node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self._preceding_components.append(TargetExecutionContext().parse_xml_node(c))<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a preceding condition into
this object.
|
f5229:c9:m8
|
def parse_yaml(self, y):
|
super(Preceding, self).parse_yaml(y)<EOL>c = y['<STR_LIT>']['<STR_LIT>']<EOL>if '<STR_LIT>' in c:<EOL><INDENT>self.timeout = int(c['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>self.timeout = <NUM_LIT:0><EOL><DEDENT>if '<STR_LIT>' in c:<EOL><INDENT>self.sending_timing = c['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>self.sending_timing = '<STR_LIT>'<EOL><DEDENT>self._preceding_components = []<EOL>if '<STR_LIT>' in c:<EOL><INDENT>for p in c.get('<STR_LIT>'):<EOL><INDENT>self._preceding_components.append(TargetExecutionContext().parse_yaml(p))<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML specification of a preceding condition into this
object.
|
f5229:c9:m9
|
def save_xml(self, doc, element):
|
super(Preceding, self).save_xml(doc, element)<EOL>pre_element = doc.createElementNS(RTS_NS, RTS_NS_S + '<STR_LIT>')<EOL>if self.timeout:<EOL><INDENT>pre_element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>',<EOL>str(self.timeout))<EOL><DEDENT>if self.sending_timing:<EOL><INDENT>pre_element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>',<EOL>self.sending_timing)<EOL><DEDENT>for pc in self._preceding_components:<EOL><INDENT>new_element = doc.createElementNS(RTS_NS,<EOL>RTS_NS_S + '<STR_LIT>')<EOL>pc.save_xml(doc, new_element)<EOL>pre_element.appendChild(new_element)<EOL><DEDENT>element.appendChild(pre_element)<EOL>
|
Save this preceding condition into an xml.dom.Element object.
|
f5229:c9:m10
|
def to_dict(self):
|
d = super(Preceding, self).to_dict()<EOL>e = {}<EOL>if self.timeout != <NUM_LIT:0>:<EOL><INDENT>e['<STR_LIT>'] = self.timeout<EOL><DEDENT>if self.sending_timing:<EOL><INDENT>e['<STR_LIT>'] = self.sending_timing<EOL><DEDENT>pcs = []<EOL>for pc in self._preceding_components:<EOL><INDENT>pcs.append(pc.to_dict())<EOL><DEDENT>if pcs:<EOL><INDENT>e['<STR_LIT>'] = pcs<EOL><DEDENT>d['<STR_LIT>'] = {'<STR_LIT>': e}<EOL>return d<EOL>
|
Save this preceding condition into a dictionary.
|
f5229:c9:m11
|
def __init__(self, wait_time=<NUM_LIT:0>, sequence=<NUM_LIT:0>,<EOL>target_component=TargetExecutionContext()):
|
super(WaitTime, self).__init__(sequence, target_component)<EOL>validate_attribute(wait_time, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._wait_time = wait_time<EOL>
|
Constructor.
@param sequence Execution order of the target component.
@type sequence int
@param target_component The target of the condition.
@type target_component TargetComponent
@param wait_time The length of time to wait, in milliseconds.
@type wait_time int
|
f5229:c10:m0
|
@property<EOL><INDENT>def wait_time(self):<DEDENT>
|
return self._wait_time<EOL>
|
The length of time to wait before executing the specified action.
In milliseconds.
|
f5229:c10:m2
|
def parse_xml_node(self, node):
|
super(WaitTime, self).parse_xml_node(node)<EOL>wait_time_nodes = node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>')<EOL>if wait_time_nodes.length != <NUM_LIT:1>:<EOL><INDENT>raise InvalidParticipantNodeError<EOL><DEDENT>self.wait_time = int(wait_time_nodes[<NUM_LIT:0>].getAttributeNS(RTS_NS,<EOL>'<STR_LIT>'))<EOL>return self<EOL>
|
Parse an xml.dom Node object representing a wait_time condition into
this object.
|
f5229:c10:m4
|
def parse_yaml(self, y):
|
super(WaitTime, self).parse_yaml(y)<EOL>self.wait_time = int(y['<STR_LIT>']['<STR_LIT>']['<STR_LIT>'])<EOL>return self<EOL>
|
Parse a YAML specification of a wait_time condition into this
object.
|
f5229:c10:m5
|
def save_xml(self, doc, element):
|
super(WaitTime, self).save_xml(doc, element)<EOL>new_element = doc.createElementNS(RTS_NS, RTS_NS_S + '<STR_LIT>')<EOL>new_element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>',<EOL>str(self.wait_time))<EOL>element.appendChild(new_element)<EOL>
|
Save this wait_time condition into an xml.dom.Element object.
|
f5229:c10:m6
|
def to_dict(self):
|
d = super(WaitTime, self).to_dict()<EOL>d['<STR_LIT>'] = {'<STR_LIT>': {'<STR_LIT>': self.wait_time}}<EOL>return d<EOL>
|
Save this wait_time condition into a dictionary.
|
f5229:c10:m7
|
def __init__(self, name='<STR_LIT>', comment='<STR_LIT>', visible=True):
|
validate_attribute(name, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._name = name<EOL>validate_attribute(comment, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._comment = comment<EOL>validate_attribute(visible, '<STR_LIT>',<EOL>expected_type=bool, required=False)<EOL>self._visible = visible<EOL>self._properties = {}<EOL>
|
Constructor.
@param name Name of the port.
@type name str
@param comment A comment about the port.
@type comment str
@param visible If this port is visible in graphical displays.
@type visible bool
|
f5230:c0:m0
|
@property<EOL><INDENT>def name(self):<DEDENT>
|
return self._name<EOL>
|
The name of this data port.
This name is used in connector profiles to identify the port.
Example:
>>> p = DataPort()
>>> p.name = "test"
Invalid assignment should throw exception:
>>> p.name = 1
Traceback (most recent call last):
...
InvalidTypeError: ('dataPort.name', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5230:c0:m2
|
@property<EOL><INDENT>def comment(self):<DEDENT>
|
return self._comment<EOL>
|
Comment about the data port.
A brief comment about the data port. May or may not be displayed in
other tools. May be empty.
Part of the extended profile.
Example:
>>> p = DataPort()
>>> p.comment = "test"
Invalid assignment should throw exception:
>>> p.comment = 1
Traceback (most recent call last):
...
InvalidTypeError: ('dataPort.ext.comment', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5230:c0:m4
|
@property<EOL><INDENT>def visible(self):<DEDENT>
|
return self._visible<EOL>
|
Display the port in graphical tools.
This value controls whether graphical tools will display this port or
not.
Part of the extended profile.
Example:
>>> p = DataPort()
>>> p.visible = True
Invalid assignment should throw exception:
>>> p.visible = 1
Traceback (most recent call last):
...
InvalidTypeError: ('dataPort.ext.visible', <type 'int'>, <type 'bool'>)
|
f5230:c0:m6
|
@property<EOL><INDENT>def properties(self):<DEDENT>
|
return self._properties<EOL>
|
Miscellaneous properties.
Stores key/value pair properties.
Part of the extended profile.
Example:
>>> p = DataPort()
>>> p.properties = {"key": "value"}
Invalid assignment should throw exception:
>>> p.properties = 1
Traceback (most recent call last):
...
InvalidTypeError: ('dataPort.ext.Properties', <type 'int'>, <type 'dict'>)
|
f5230:c0:m8
|
def parse_xml_node(self, node):
|
self.name = node.getAttributeNS(RTS_NS, '<STR_LIT:name>')<EOL>self.comment = node.getAttributeNS(RTS_EXT_NS, '<STR_LIT>')<EOL>if node.hasAttributeNS(RTS_EXT_NS, '<STR_LIT>'):<EOL><INDENT>visible = node.getAttributeNS(RTS_EXT_NS, '<STR_LIT>')<EOL>if visible.lower() == '<STR_LIT:true>' or visible == '<STR_LIT:1>':<EOL><INDENT>self.visible = True<EOL><DEDENT>else:<EOL><INDENT>self.visible = False<EOL><DEDENT><DEDENT>for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,<EOL>local_name='<STR_LIT>'):<EOL><INDENT>name, value = parse_properties_xml(c)<EOL>self._properties[name] = value<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a data port into this
object.
|
f5230:c0:m10
|
def parse_yaml(self, y):
|
self.name = y['<STR_LIT:name>']<EOL>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>self.comment = y[RTS_EXT_NS_YAML + '<STR_LIT>']<EOL><DEDENT>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>visible = y.get(RTS_EXT_NS_YAML + '<STR_LIT>')<EOL>if visible == True or visible == '<STR_LIT:true>' or visible == '<STR_LIT:True>':<EOL><INDENT>self.visible = True<EOL><DEDENT>else:<EOL><INDENT>self.visible = False<EOL><DEDENT><DEDENT>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>for p in y.get(RTS_EXT_NS_YAML + '<STR_LIT>'):<EOL><INDENT>if '<STR_LIT:value>' in p:<EOL><INDENT>value = p['<STR_LIT:value>']<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>self._properties[p['<STR_LIT:name>']] = value<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML specification of a data port into this object.
|
f5230:c0:m11
|
def save_xml(self, doc, element):
|
element.setAttributeNS(XSI_NS, XSI_NS_S + '<STR_LIT:type>', '<STR_LIT>')<EOL>element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT:name>', self.name)<EOL>if self.comment:<EOL><INDENT>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>self.comment)<EOL><DEDENT>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>str(self.visible).lower())<EOL>for p in self.properties:<EOL><INDENT>new_prop_element = doc.createElementNS(RTS_EXT_NS,<EOL>RTS_EXT_NS_S + '<STR_LIT>')<EOL>properties_to_xml(new_prop_element, p, self.properties[p])<EOL>element.appendChild(new_prop_element)<EOL><DEDENT>
|
Save this data port into an xml.dom.Element object.
|
f5230:c0:m12
|
def to_dict(self):
|
d = {'<STR_LIT:name>': self.name,<EOL>RTS_EXT_NS_YAML + '<STR_LIT>': self.visible}<EOL>if self.comment:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = self.comment<EOL><DEDENT>props = []<EOL>for name in self.properties:<EOL><INDENT>p = {'<STR_LIT:name>': name}<EOL>if self.properties[name]:<EOL><INDENT>p['<STR_LIT:value>'] = str(self.properties[name])<EOL><DEDENT>props.append(p)<EOL><DEDENT>if props:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = props<EOL><DEDENT>return d<EOL>
|
Save this data port into a dictionary.
|
f5230:c0:m13
|
def __init__(self, name='<STR_LIT>', comment='<STR_LIT>', visible=True):
|
validate_attribute(name, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._name = name<EOL>validate_attribute(comment, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._comment = comment<EOL>validate_attribute(visible, '<STR_LIT>',<EOL>expected_type=bool, required=False)<EOL>self._visible = visible<EOL>self._properties = {}<EOL>
|
Constructor.
@param name Name of the port.
@type name str
@param comment A comment about the port.
@type comment str
@param visible If this port is visible in graphical displays.
@type visible bool
|
f5230:c1:m0
|
@property<EOL><INDENT>def name(self):<DEDENT>
|
return self._name<EOL>
|
The name of this service port.
This name is used in connector profiles to identify the port.
Example:
>>> p = ServicePort()
>>> p.name = "test"
Invalid assignment should throw exception:
>>> p.name = 1
Traceback (most recent call last):
...
InvalidTypeError: ('serviceport.name', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5230:c1:m2
|
@property<EOL><INDENT>def comment(self):<DEDENT>
|
return self._comment<EOL>
|
Comment about the service port.
A brief comment about the service port. May or may not be displayed in
other tools. May be empty.
Part of the extended profile.
Example:
>>> p = ServicePort()
>>> p.comment = "test"
Invalid assignment should throw exception:
>>> p.comment = 1
Traceback (most recent call last):
...
InvalidTypeError: ('serviceport.ext.comment', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5230:c1:m4
|
@property<EOL><INDENT>def visible(self):<DEDENT>
|
return self._visible<EOL>
|
Display the port in graphical tools.
This value controls whether graphical tools will display this port or
not.
Part of the extended profile.
Example:
>>> p = ServicePort()
>>> p.visible = True
Invalid assignment should throw exception:
>>> p.visible = 1
Traceback (most recent call last):
...
InvalidTypeError: ('serviceport.ext.visible', <type 'int'>, <type 'bool'>)
|
f5230:c1:m6
|
@property<EOL><INDENT>def properties(self):<DEDENT>
|
return self._properties<EOL>
|
Miscellaneous properties.
Stores key/value pair properties.
Part of the extended profile.
Example:
>>> p = ServicePort()
>>> p.properties = {"key": "value"}
Invalid assignment should throw exception:
>>> p.properties = 1
Traceback (most recent call last):
...
InvalidTypeError: ('serviceport.ext.Properties', <type 'int'>, <type 'dict'>)
|
f5230:c1:m8
|
def parse_xml_node(self, node):
|
self.name = node.getAttributeNS(RTS_NS, '<STR_LIT:name>')<EOL>self.comment = node.getAttributeNS(RTS_EXT_NS, '<STR_LIT>')<EOL>if node.hasAttributeNS(RTS_EXT_NS, '<STR_LIT>'):<EOL><INDENT>visible = node.getAttributeNS(RTS_EXT_NS, '<STR_LIT>')<EOL>if visible.lower() == '<STR_LIT:true>' or visible == '<STR_LIT:1>':<EOL><INDENT>self.visible = True<EOL><DEDENT>else:<EOL><INDENT>self.visible = False<EOL><DEDENT><DEDENT>for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,<EOL>local_name='<STR_LIT>'):<EOL><INDENT>name, value = parse_properties_xml(c)<EOL>self._properties[name] = value<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a service port into this
object.
|
f5230:c1:m10
|
def parse_yaml(self, y):
|
self.name = y['<STR_LIT:name>']<EOL>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>self.comment = y[RTS_EXT_NS_YAML + '<STR_LIT>']<EOL><DEDENT>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>visible = y.get(RTS_EXT_NS_YAML + '<STR_LIT>')<EOL>if visible == True or visible == '<STR_LIT:true>' or visible == '<STR_LIT:True>':<EOL><INDENT>self.visible = True<EOL><DEDENT>else:<EOL><INDENT>self.visible = False<EOL><DEDENT><DEDENT>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>for p in y.get(RTS_EXT_NS_YAML + '<STR_LIT>'):<EOL><INDENT>if '<STR_LIT:value>' in p:<EOL><INDENT>value = p['<STR_LIT:value>']<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>self._properties[p['<STR_LIT:name>']] = value<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML specification of a service port into this object.
|
f5230:c1:m11
|
def save_xml(self, doc, element):
|
element.setAttributeNS(XSI_NS, XSI_NS_S + '<STR_LIT:type>', '<STR_LIT>')<EOL>element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT:name>', self.name)<EOL>if self.comment:<EOL><INDENT>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>self.comment)<EOL><DEDENT>if self.visible != True:<EOL><INDENT>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>str(self.visible).lower())<EOL><DEDENT>for p in self.properties:<EOL><INDENT>new_prop_element = doc.createElementNS(RTS_EXT_NS,<EOL>RTS_EXT_NS_S + '<STR_LIT>')<EOL>properties_to_xml(new_prop_element, p, self.properties[p])<EOL>element.appendChild(new_prop_element)<EOL><DEDENT>
|
Save this service port into an xml.dom.Element object.
|
f5230:c1:m12
|
def to_dict(self):
|
d = {'<STR_LIT:name>': self.name}<EOL>if self.visible != True:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = self.visible<EOL><DEDENT>if self.comment:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = self.comment<EOL><DEDENT>props = []<EOL>for name in self.properties:<EOL><INDENT>p = {'<STR_LIT:name>': name}<EOL>if self.properties[name]:<EOL><INDENT>p['<STR_LIT:value>'] = str(self.properties[name])<EOL><DEDENT>props.append(p)<EOL><DEDENT>if props:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = props<EOL><DEDENT>return d<EOL>
|
Save this service port into a dictionary.
|
f5230:c1:m13
|
def __init__(self, group_id='<STR_LIT>', members=[]):
|
validate_attribute(group_id, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._group_id = group_id<EOL>validate_attribute(members, '<STR_LIT>',<EOL>expected_type=list, required=False)<EOL>self._members = members<EOL>
|
Constructor.
@param group_id ID of the group.
@type group_id str
@param members Members of the group. At least one must be present.
@type members list
|
f5231:c0:m0
|
@property<EOL><INDENT>def group_id(self):<DEDENT>
|
return self._group_id<EOL>
|
The ID used to distinguish this group in the RT system.
Example:
>>> g = ComponentGroup()
>>> g.group_id = "test"
Invalid assignment should throw exception:
>>> g.group_id = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component_group.groupID', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5231:c0:m2
|
@property<EOL><INDENT>def members(self):<DEDENT>
|
return self._members<EOL>
|
A list of the components in the group.
At least one must be present.
Example:
>>> import rtsprofile.component
>>> g = ComponentGroup()
>>> g.members = [rtsprofile.component.Component()]
Invalid assignment should throw exception:
>>> g.members = []
Traceback (most recent call last):
...
RequiredAttributeError: component_group.Members
>>> g.members = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component_group.Members', <type 'int'>, <type 'list'>)
|
f5231:c0:m4
|
def parse_xml_node(self, node):
|
self.group_id = node.getAttributeNS(RTS_NS, '<STR_LIT>')<EOL>self._members = []<EOL>for c in node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self._members.append(TargetComponent().parse_xml_node(c))<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing a component group into
this object.
|
f5231:c0:m6
|
def parse_yaml(self, node):
|
self.group_id = y['<STR_LIT>']<EOL>self._members = []<EOL>if '<STR_LIT>' in y:<EOL><INDENT>for m in y.get('<STR_LIT>'):<EOL><INDENT>self._members.append(TargetComponent().parse_yaml(m))<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML specification of a component group into this
object.
|
f5231:c0:m7
|
def save_xml(self, doc, element):
|
element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>', self.group_id)<EOL>for m in self.members:<EOL><INDENT>new_element = doc.createElementNS(RTS_NS, RTS_NS_S + '<STR_LIT>')<EOL>m.save_xml(doc, new_element)<EOL>element.appendChild(new_element)<EOL><DEDENT>
|
Save this component group into an xml.dom.Element object.
|
f5231:c0:m8
|
def to_dict(self):
|
d = {'<STR_LIT>': self.group_id}<EOL>members = []<EOL>for m in self.members:<EOL><INDENT>members.append(m.to_dict())<EOL><DEDENT>if members:<EOL><INDENT>d['<STR_LIT>'] = members<EOL><DEDENT>return d<EOL>
|
Save this component group to a dictionary.
|
f5231:c0:m9
|
def from_string(type_string):
|
if type_string == NONE:<EOL><INDENT>return NONE<EOL><DEDENT>elif type_string == PERIODIC_EC_SHARED:<EOL><INDENT>return PERIODC_EC_SHARED<EOL><DEDENT>elif type_string == PERIODIC_STATE_SHARED:<EOL><INDENT>return PERIODIC_STATE_SHARED<EOL><DEDENT>elif type_string == GROUPING:<EOL><INDENT>return GROUPING<EOL><DEDENT>elif type_string == FSM_EC_SHARED:<EOL><INDENT>return FSM_EC_SHARED<EOL><DEDENT>elif type_string == FSM_STATE_SHARED:<EOL><INDENT>return FSM_STATE_SHARED<EOL><DEDENT>else:<EOL><INDENT>raise InvalidCompositeTypeError(type_string)<EOL><DEDENT>
|
Returns the correct constant for a given string.
@raises InvalidCompositeTypeError
|
f5232:m0
|
def to_string(comp_type):
|
if comp_type == NONE:<EOL><INDENT>return NONE<EOL><DEDENT>elif comp_type== PERIODIC_EC_SHARED:<EOL><INDENT>return PERIODC_EC_SHARED<EOL><DEDENT>elif comp_type == PERIODIC_STATE_SHARED:<EOL><INDENT>return PERIODIC_STATE_SHARED<EOL><DEDENT>elif comp_type == GROUPING:<EOL><INDENT>return GROUPING<EOL><DEDENT>elif comp_type == FSM_EC_SHARED:<EOL><INDENT>return FSM_EC_SHARED<EOL><DEDENT>elif comp_type == FSM_STATE_SHARED:<EOL><INDENT>return FSM_STATE_SHARED<EOL><DEDENT>else:<EOL><INDENT>raise InvalidCompositeTypeError(type_string)<EOL><DEDENT>
|
Returns the correct string for a given composite type.
@raises InvalidCompositeTypeError
|
f5232:m1
|
def __init__(self, x=<NUM_LIT:0>, y=<NUM_LIT:0>, height=<NUM_LIT:0>, width=<NUM_LIT:0>, direction=dir.DOWN):
|
validate_attribute(x, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._x = x<EOL>validate_attribute(y, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._y = y<EOL>validate_attribute(height, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._height = height<EOL>validate_attribute(width, '<STR_LIT>',<EOL>expected_type=int, required=False)<EOL>self._width = width<EOL>validate_attribute(direction, '<STR_LIT>',<EOL>expected_type=dir.const_type, required=False)<EOL>self._direction = direction<EOL>
|
Constructor.
@param x X position of the top-left of the component.
@type x int
@param y Y position of the top-left of the component.
@type y int
@param height Height of the component.
@type height int
@param width Width of the component.
@type width int
@param direction Direction the component faces.
@type direction direction.const_type
|
f5233:c0:m0
|
@property<EOL><INDENT>def x(self):<DEDENT>
|
return self._x<EOL>
|
The X position of the component in a graphical tool.
|
f5233:c0:m2
|
@property<EOL><INDENT>def y(self):<DEDENT>
|
return self._y<EOL>
|
The Y position of the component in a graphical tool.
|
f5233:c0:m4
|
@property<EOL><INDENT>def height(self):<DEDENT>
|
return self._height<EOL>
|
The height of the component in a graphical tool.
|
f5233:c0:m6
|
@property<EOL><INDENT>def width(self):<DEDENT>
|
return self._width<EOL>
|
The width of the component in a graphical tool.
A value of -1 for this property indicates that the width should be as
wide as is necessary.
|
f5233:c0:m8
|
@property<EOL><INDENT>def direction(self):<DEDENT>
|
return self._direction<EOL>
|
The direction of the component in a graphical tool.
A value of -1 for this property indicates that the height should be as
wide as is necessary.
|
f5233:c0:m10
|
def parse_xml_node(self, node):
|
self.x = int(node.getAttributeNS(RTS_EXT_NS, '<STR_LIT:x>'))<EOL>self.y = int(node.getAttributeNS(RTS_EXT_NS, '<STR_LIT:y>'))<EOL>self.height = int(node.getAttributeNS(RTS_EXT_NS, '<STR_LIT>'))<EOL>self.width = int(node.getAttributeNS(RTS_EXT_NS, '<STR_LIT:width>'))<EOL>self.direction = dir.from_string(node.getAttributeNS(RTS_EXT_NS,<EOL>'<STR_LIT>'))<EOL>return self<EOL>
|
Parse an xml.dom Node object representing a location into this
object.
|
f5233:c0:m12
|
def parse_yaml(self, y):
|
self.x = int(y['<STR_LIT:x>'])<EOL>self.y = int(y['<STR_LIT:y>'])<EOL>self.height = int(y['<STR_LIT>'])<EOL>self.width = int(y['<STR_LIT:width>'])<EOL>self.direction = dir.from_string(y['<STR_LIT>'])<EOL>return self<EOL>
|
Parse a YAML specification of a location into this object.
|
f5233:c0:m13
|
def save_xml(self, doc, element):
|
element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT:x>', str(self.x))<EOL>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT:y>', str(self.y))<EOL>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>str(self.height))<EOL>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT:width>',<EOL>str(self.width))<EOL>element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + '<STR_LIT>',<EOL>dir.to_string(self.direction).lower())<EOL>
|
Save this location into an xml.dom.Element object.
|
f5233:c0:m14
|
def to_dict(self):
|
return {'<STR_LIT:x>': self.x,<EOL>'<STR_LIT:y>': self.y,<EOL>'<STR_LIT>': self.height,<EOL>'<STR_LIT:width>': self.width,<EOL>'<STR_LIT>': dir.to_string(self.direction)}<EOL>
|
Save this location into a dictionary.
|
f5233:c0:m15
|
def __init__(self, id='<STR_LIT>', kind='<STR_LIT>', rate=<NUM_LIT:0.0>):
|
validate_attribute(id, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._id = id<EOL>validate_attribute(kind, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._kind = kind<EOL>validate_attribute(rate, '<STR_LIT>',<EOL>expected_type=[int, float], required=False)<EOL>self._rate = rate<EOL>self._participants = []<EOL>self._properties = {}<EOL>
|
Constructor.
@param id The ID of this execution context.
@type id str
@param kind The action execution type used by this context.
@type kind str
@param rate The execution rate of this context, if it is periodic.
@type float
|
f5234:c0:m0
|
@property<EOL><INDENT>def id(self):<DEDENT>
|
return self._id<EOL>
|
The ID used to identify this execution context.
Example:
>>> ec = ExecutionContext()
>>> ec.id = "test"
Invalid assignment should throw exception:
>>> ec.id = 1
Traceback (most recent call last):
...
InvalidTypeError: ('execution_context.id', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5234:c0:m2
|
@property<EOL><INDENT>def kind(self):<DEDENT>
|
return self._kind<EOL>
|
The action execution type used by this context.
Valid values are supposed to be in the specification appendix, but they
aren't. The best way to find them is to create a system with
RTSystemEditor and look at the XML. A common valid value is
PeriodicExecutionContext.
Example:
>>> ec = ExecutionContext()
>>> ec.kind = "PeriodicExecutionContext"
Invalid assignment should throw exception:
>>> ec.kind = 1
Traceback (most recent call last):
...
InvalidTypeError: ('execution_context.kind', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5234:c0:m4
|
@property<EOL><INDENT>def participants(self):<DEDENT>
|
return self._participants<EOL>
|
The components participating in this execution context.
An ordered list. May be an empty list if no components are
participating in this context.
Example:
>>> ec = ExecutionContext()
>>> ec.participants = []
Invalid assignment should throw exception:
>>> ec.participants = 1
Traceback (most recent call last):
...
InvalidTypeError: ('execution_context.participants', <type 'int'>, <type 'list'>)
|
f5234:c0:m6
|
@property<EOL><INDENT>def rate(self):<DEDENT>
|
return self._rate<EOL>
|
The execution rate of this context, if it has one, in Hertz.
This value is only used if the execution context is periodic for a data
flow component.
Example:
>>> ec = ExecutionContext()
>>> ec.rate = 1000.0
Invalid assignment should throw exception:
>>> ec.rate = "test"
Traceback (most recent call last):
...
InvalidTypeError: ('execution_context.rate', <type 'str'>, [<type 'int'>, <type 'float'>])
|
f5234:c0:m8
|
@property<EOL><INDENT>def properties(self):<DEDENT>
|
return self._properties<EOL>
|
Miscellaneous properties.
Stores key/value pair properties.
Part of the extended profile.
Example:
>>> ec = ExecutionContext()
>>> ec.properties = {"key": "value"}
Invalid assignment should throw exception:
>>> ec.properties = 1
Traceback (most recent call last):
...
InvalidTypeError: ('execution_context.ext.Properties', <type 'int'>, <type 'dict'>)
|
f5234:c0:m10
|
def parse_xml_node(self, node):
|
self.id = node.getAttributeNS(RTS_NS, '<STR_LIT:id>')<EOL>self.kind = node.getAttributeNS(RTS_NS, '<STR_LIT>')<EOL>if node.hasAttributeNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self.rate = float(node.getAttributeNS(RTS_NS, '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>self.rate = <NUM_LIT:0.0><EOL><DEDENT>self._participants = []<EOL>for c in node.getElementsByTagNameNS(RTS_NS, '<STR_LIT>'):<EOL><INDENT>self._participants.append(TargetComponent().parse_xml_node(c))<EOL><DEDENT>for c in get_direct_child_elements_xml(node, prefix=RTS_EXT_NS,<EOL>local_name='<STR_LIT>'):<EOL><INDENT>name, value = parse_properties_xml(c)<EOL>self._properties[name] = value<EOL><DEDENT>return self<EOL>
|
Parse an xml.dom Node object representing an execution context into
this object.
|
f5234:c0:m12
|
def parse_yaml(self, y):
|
self.id = y['<STR_LIT:id>']<EOL>self.kind = y['<STR_LIT>']<EOL>if '<STR_LIT>' in y:<EOL><INDENT>self.rate = float(y['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>self.rate = <NUM_LIT:0.0><EOL><DEDENT>self._participants = []<EOL>if '<STR_LIT>' in y:<EOL><INDENT>for p in y.get('<STR_LIT>'):<EOL><INDENT>self._participants.append(TargetComponent().parse_yaml(p))<EOL><DEDENT><DEDENT>if RTS_EXT_NS_YAML + '<STR_LIT>' in y:<EOL><INDENT>for p in y.get(RTS_EXT_NS_YAML + '<STR_LIT>'):<EOL><INDENT>if '<STR_LIT:value>' in p:<EOL><INDENT>value = p['<STR_LIT:value>']<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>self._properties[p['<STR_LIT:name>']] = value<EOL><DEDENT><DEDENT>return self<EOL>
|
Parse a YAML spefication of an execution context into this
object.
|
f5234:c0:m13
|
def save_xml(self, doc, element):
|
element.setAttributeNS(XSI_NS, XSI_NS_S + '<STR_LIT:type>', '<STR_LIT>')<EOL>element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT:id>', self.id)<EOL>element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>', self.kind)<EOL>element.setAttributeNS(RTS_NS, RTS_NS_S + '<STR_LIT>', str(self.rate))<EOL>for p in self.participants:<EOL><INDENT>new_element = doc.createElementNS(RTS_NS,<EOL>RTS_NS_S + '<STR_LIT>')<EOL>p.save_xml(doc, new_element)<EOL>element.appendChild(new_element)<EOL><DEDENT>for p in self.properties:<EOL><INDENT>new_prop_element = doc.createElementNS(RTS_EXT_NS,<EOL>RTS_EXT_NS_S + '<STR_LIT>')<EOL>properties_to_xml(new_prop_element, p, self.properties[p])<EOL>element.appendChild(new_prop_element)<EOL><DEDENT>
|
Save this execution context into an xml.dom.Element object.
|
f5234:c0:m14
|
def to_dict(self):
|
d = {'<STR_LIT:id>': self.id,<EOL>'<STR_LIT>': self.kind}<EOL>if self.rate != <NUM_LIT:0.0>:<EOL><INDENT>d['<STR_LIT>'] = self.rate<EOL><DEDENT>participants = []<EOL>for p in self.participants:<EOL><INDENT>participants.append(p.to_dict())<EOL><DEDENT>if participants:<EOL><INDENT>d['<STR_LIT>'] = participants<EOL><DEDENT>props = []<EOL>for name in self.properties:<EOL><INDENT>p = {'<STR_LIT:name>': name}<EOL>if self.properties[name]:<EOL><INDENT>p['<STR_LIT:value>'] = str(self.properties[name])<EOL><DEDENT>props.append(p)<EOL><DEDENT>if props:<EOL><INDENT>d[RTS_EXT_NS_YAML + '<STR_LIT>'] = props<EOL><DEDENT>return d<EOL>
|
Save this execution context into a dictionary.
|
f5234:c0:m15
|
def __init__(self, id='<STR_LIT>', path_uri='<STR_LIT>', active_configuration_set='<STR_LIT>',<EOL>instance_name='<STR_LIT>', composite_type=comp_type.NONE,<EOL>is_required=False, comment='<STR_LIT>', visible=True,<EOL>location=Location()):
|
self._reset()<EOL>validate_attribute(id, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._id = id<EOL>validate_attribute(path_uri, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._path_uri = path_uri<EOL>validate_attribute(active_configuration_set,<EOL>'<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._active_config_set = active_configuration_set<EOL>validate_attribute(instance_name, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._instance_name = instance_name<EOL>validate_attribute(composite_type, '<STR_LIT>',<EOL>expected_type=comp_type.const_type, required=False)<EOL>self._composite_type = composite_type<EOL>validate_attribute(is_required, '<STR_LIT>',<EOL>expected_type=bool)<EOL>self._is_required = is_required<EOL>validate_attribute(comment, '<STR_LIT>',<EOL>expected_type=string_types(), required=False)<EOL>self._comment = comment<EOL>validate_attribute(visible, '<STR_LIT>',<EOL>expected_type=bool, required=False)<EOL>self._visible = visible<EOL>validate_attribute(location, '<STR_LIT>',<EOL>expected_type=Location, required=True)<EOL>self._location = location<EOL>
|
@param id Component ID.
@type id str
@param path_uri Path to the component.
@type path_uri str
@param active_configuration_set Name of the active configuration set.
@type active_configuration_set str
@param instance_name Component's instance name.
@type instance_name str
@param composite_type Type of composition the component is in.
@type composite_type CompositeType
@param is_required If the component is optional in the system.
@type is_required bool
@param comment A comment about the component.
@type comment str
@param visible If this component is visible in graphical displays.
@type visible bool
@param location The location of this component in graphical displays.
@type location Location
|
f5236:c0:m0
|
@property<EOL><INDENT>def id(self):<DEDENT>
|
return self._id<EOL>
|
ID of this component in the RT system.
In case of the same RT Component specification being used to create
multiple RT Components within a single RT system, this ID is prepended
to the instance name attribute to distinguish individual components.
Example:
>>> c = Component()
>>> c.id = "test0.rtc"
Invalid assignment should throw exception:
>>> c.id = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.id', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5236:c0:m2
|
@property<EOL><INDENT>def path_uri(self):<DEDENT>
|
return self._path_uri<EOL>
|
Path to where this component is registered in URI format.
Example:
>>> c = Component()
>>> c.path_uri = "file://tmp"
Invalid assignment should throw exception:
>>> c.path_uri = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.pathUri', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5236:c0:m4
|
@property<EOL><INDENT>def active_configuration_set(self):<DEDENT>
|
return self._active_config_set<EOL>
|
The ID of the active configuration set of the component.
If no configuration set is active, this may be empty.
Example:
>>> c = Component()
>>> c.active_configuration_set = "config1"
Invalid assignment should throw exception:
>>> c.active_configuration_set = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.activeConfigurationSet', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5236:c0:m6
|
@property<EOL><INDENT>def instance_name(self):<DEDENT>
|
return self._instance_name<EOL>
|
Instance name of the component in the RT system.
In case of the same RT Component specification being used to create
multiple RT Components within a single RT system, this instance name is
appended to the ID attribute to distinguish individual components.
Example:
>>> c = Component()
>>> c.instance_name = "test0.rtc"
Invalid assignment should throw exception:
>>> c.instance_name = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.instanceName', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5236:c0:m8
|
@property<EOL><INDENT>def composite_type(self):<DEDENT>
|
return self._composite_type<EOL>
|
The type of composite component this component is involved in.
If this component is involved in a composite component, this attribute
specifies the type of composition. See @ref CompositeType for valid
values.
Example:
>>> import composite_type
>>> c = Component()
>>> c.composite_type = composite_type.PERIODIC_EC_SHARED
Invalid assignment should throw exception:
>>> c.composite_type = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.compositeType', <type 'int'>, <type 'str'>)
|
f5236:c0:m10
|
@property<EOL><INDENT>def is_required(self):<DEDENT>
|
return self._is_required<EOL>
|
Specifies if this component is optional in the RT system.
Sometimes a component does not need to be present for an RT system to
function. If this component must be present for the RT system to
function, this attribute will be True.
Example:
>>> c = Component()
>>> c.is_required = True
Invalid assignment should throw exception:
>>> c.is_required = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.isRequired', <type 'int'>, <type 'bool'>)
|
f5236:c0:m12
|
@property<EOL><INDENT>def data_ports(self):<DEDENT>
|
return self._data_ports<EOL>
|
Data ports owned by this component.
May be an empty list if this component has no data ports. Members are
of type @ref DataPort.
Example:
>>> c = Component()
>>> c.data_ports = []
Invalid assignment should throw exception:
>>> c.data_ports = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.DataPorts', <type 'int'>, <type 'list'>)
|
f5236:c0:m14
|
@property<EOL><INDENT>def service_ports(self):<DEDENT>
|
return self._service_ports<EOL>
|
Service ports owned by this component.
May be an empty list if this component has no service ports. Members
are of type @ref ServicePort.
Example:
>>> c = Component()
>>> c.service_ports = []
Invalid assignment should throw exception:
>>> c.service_ports = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ServicePorts', <type 'int'>, <type 'list'>)
|
f5236:c0:m16
|
@property<EOL><INDENT>def configuration_sets(self):<DEDENT>
|
return self._config_sets<EOL>
|
The configuration sets in this component.
May be an empty list if this component has no configuration sets.
Members are of type @ref ConfigurationSet.
Example:
>>> c = Component()
>>> c.configuration_sets = []
Invalid assignment should throw exception:
>>> c.configuration_sets = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ConfigurationSets', <type 'int'>, <type 'list'>)
|
f5236:c0:m18
|
@property<EOL><INDENT>def execution_contexts(self):<DEDENT>
|
return self._exec_contexts<EOL>
|
The execution contexts owned by this component.
May be an empty list if this component does not own any contexts.
Members are of type @ref ExecutionContext.
Example:
>>> c = Component()
>>> c.execution_contexts = []
Invalid assignment should throw exception:
>>> c.execution_contexts = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ExecutionContexts', <type 'int'>, <type 'list'>)
|
f5236:c0:m20
|
@property<EOL><INDENT>def participants(self):<DEDENT>
|
return self._participants<EOL>
|
The list of participating components, if this component is a
composite component.
Members are of type @ref Participant.
Example:
>>> c = Component()
>>> c.participants = []
Invalid assignment should throw exception:
>>> c.participants = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.Participants', <type 'int'>, <type 'list'>)
|
f5236:c0:m22
|
@property<EOL><INDENT>def comment(self):<DEDENT>
|
return self._comment<EOL>
|
Comment about the component.
A brief comment about the component. May or may not be displayed in
other tools. May be empty.
Part of the extended profile.
Example:
>>> c = Component()
>>> c.comment = "test comment"
Invalid assignment should throw exception:
>>> c.comment = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ext.comment', <type 'int'>, [<type 'str'>, <type 'unicode'>])
|
f5236:c0:m24
|
@property<EOL><INDENT>def visible(self):<DEDENT>
|
return self._visible<EOL>
|
Display the component in graphical tools.
This value controls whether graphical tools will display this component
or not.
Part of the extended profile.
Example:
>>> c = Component()
>>> c.visible = True
Invalid assignment should throw exception:
>>> c.visible = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ext.visible', <type 'int'>, <type 'bool'>)
|
f5236:c0:m26
|
@property<EOL><INDENT>def location(self):<DEDENT>
|
return self._location<EOL>
|
Specifies the position of the component in graphical tools.
Part of the extended profile.
Example:
>>> import direction
>>> c = Component()
>>> l = Location()
>>> l.direction = direction.LEFT
>>> c.location = l
>>> c.location.direction
'LEFT'
Invalid assignment should throw exception:
>>> c.location = 1
Traceback (most recent call last):
...
InvalidTypeError: ('component.ext.Location', <type 'int'>, <class 'rtsprofile.location.Location'>)
|
f5236:c0:m28
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.