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 a component's configuration set. 22 __version__ =
'$Revision: $' 26 from rtsprofile
import RTS_NS, RTS_NS_S
35 '''Represents a configuration set. 37 A configuration set is a collection of configuration parameters. An RT 38 Component can have multiple configuration sets. 45 @param id The configuration set ID. 50 expected_type=[str, unicode], required=
False)
55 result =
'ID: {0}\n'.format(self.
id)
57 result +=
'Configuration data:\n' 64 '''The configuration parameters contained in this set. 66 May be an empty list if this set has no parameters. 71 @configuration_data.setter
74 'configuration_set.ConfigurationData',
80 '''The configuration set ID. 82 Used to distinguish this configuration set from others in the RT 91 expected_type=[str, unicode], required=
True)
95 '''Parse an xml.dom Node object representing a configuration set into 99 self.
id = node.getAttributeNS(RTS_NS,
'id')
101 for d
in node.getElementsByTagNameNS(RTS_NS,
'ConfigurationData'):
106 '''Parse a YAML specification of a configuration set into this 112 if 'configurationData' in y:
113 for d
in y.get(
'configurationData'):
118 '''Save this configuration set into an xml.dom.Element object.''' 119 element.setAttributeNS(RTS_NS, RTS_NS_S +
'id', self.
id)
121 new_element = doc.createElementNS(RTS_NS,
122 RTS_NS_S +
'ConfigurationData')
123 c.save_xml(doc, new_element)
124 element.appendChild(new_element)
127 '''Save this configuration set into a dictionary.''' 131 data.append(c.to_dict())
133 d[
'configurationData'] = data
141 '''Represents an individual configuration parameter and its value.''' 146 @param name The name of the parameter. 148 @param data The parameter's value, if any. 153 expected_type=[str, unicode], required=
False)
156 expected_type=[str, unicode], required=
False)
160 return '{0}: {1}'.format(self.
name, self.
data)
164 '''The value of this configuration parameter. 166 May be an empty string if the parameter has no value. 174 expected_type=[str, unicode], required=
False)
179 '''The name of this configuration parameter. 181 Used as the parameter's key in the configuration set object. 189 expected_type=[str, unicode], required=
True)
193 '''Parse an xml.dom Node object representing a configuration data into 197 self.
name = node.getAttributeNS(RTS_NS,
'name')
198 if node.hasAttributeNS(RTS_NS,
'data'):
199 self.
data = node.getAttributeNS(RTS_NS,
'data')
205 '''Parse a YAML specification of a configuration data into this 209 self.
name = y[
'name']
211 self.
data = y[
'data']
217 '''Save this configuration data into an xml.dom.Element object.''' 218 element.setAttributeNS(RTS_NS, RTS_NS_S +
'name', self.
name)
220 element.setAttributeNS(RTS_NS, RTS_NS_S +
'data', self.
data)
223 '''Save this configuration data into a dictionary.''' 224 d = {
'name': self.
name}
226 d[
'data'] = self.
data
def parse_xml_node(self, node)
def __init__(self, id='')
def validate_attribute(attr, name, expected_type=None, required=False)
def configuration_data(self)
def parse_xml_node(self, node)
def save_xml(self, doc, element)
def indent_string(string, num_spaces=2)
def __init__(self, name='', data='')
def save_xml(self, doc, element)
ConfigurationData object.