diff --git a/model/redhawk.py b/model/redhawk.py index ec90109..4d6fa8a 100644 --- a/model/redhawk.py +++ b/model/redhawk.py @@ -27,11 +27,12 @@ from domain import Domain, scan_domains, ResourceNotFound +from ossie.cf import CF from ossie.properties import __TYPE_MAP as TYPE_MAP from ossie.properties import props_from_dict, props_to_dict from tornado.websocket import WebSocketClosedError -from tornado import ioloop +from tornado import ioloop, log import collections @@ -192,30 +193,15 @@ def release_application(self, domain_name, app_id): @background_task def application_configure(self, domain_name, app_id, new_properties): app = self._get_application(domain_name, app_id) - props = Redhawk._application_externalProps(app) - + props = app._getPropertySet() changes = Redhawk._get_prop_changes(props, new_properties) return app.configure(changes) - ''' - Helper function to streamline getting a property list similar to what one - gets from components, devices, etc. - ''' - @staticmethod - def _application_externalProps(app): - props = [] - for epid, t in app._externalProps.iteritems(): - pid = t[0] # First item is the property id relative to the component - cid = t[1] # Second item in tuple is prefix of component identifier - for comp in app.comps: - if comp.identifier.startswith(cid): - for prop in comp._properties: - if prop.id == pid: - props.append(prop) - return props - ############################## # COMMON PROPERTIES + ''' + Cleans out IDs being unicode, etc. since CF can't handle unicode strings. + ''' @staticmethod def _clean_property(property): if isinstance(property, basestring): @@ -231,16 +217,22 @@ def _clean_property(property): # CF.Properties and dict() of { 'id': value, ... } # Use force to treat all ID matches as required changes def _get_prop_changes(current_props, new_properties, force=False): - changes = {} + changes = [] for prop in current_props: if prop.id in new_properties: if new_properties[prop.id] != prop.queryValue() or force: - changes[str(prop.id)] = prop.fromAny( - prop.toAny( - Redhawk._clean_property(new_properties[prop.id]) + changes.append( + CF.DataType( + prop.id, + prop.toAny( + Redhawk._clean_property(new_properties[prop.id]) + ) ) ) - return props_from_dict(changes) + log.app_log.debug('Current properties: {}'.format(current_props)) + log.app_log.debug('New properties: {}'.format(new_properties)) + log.app_log.debug('Changes: {}'.format(changes)) + return changes ############################## # COMPONENT diff --git a/rest/application.py b/rest/application.py index 72c679c..5283d5f 100644 --- a/rest/application.py +++ b/rest/application.py @@ -38,7 +38,7 @@ def get(self, domain_name, app_id=None): if app_id: app = yield self.redhawk.get_application(domain_name, app_id) comps = yield self.redhawk.get_component_list(domain_name, app_id) - props = self.redhawk._application_externalProps(app) + props = app._getPropertySet() info = { 'id': app._get_identifier(), @@ -120,7 +120,7 @@ class ApplicationProperties(JsonHandler, PropertyHelper): def get(self, domain, app_id): try: app = yield self.redhawk.get_application(domain, app_id) - props = self.redhawk._application_externalProps(app) + props = app._getPropertySet() self._render_json({ 'properties': self.format_properties(props, app.query([]))