2323 Asynchronous Tornado service for REDHAWK. Maps the functions
2424 in domain.py and caches the domain object.
2525"""
26- import logging
2726from _utils .tasking import background_task
2827
2928from domain import Domain , scan_domains , ResourceNotFound
3029
30+ from ossie .cf import CF
3131from ossie .properties import __TYPE_MAP as TYPE_MAP
3232from ossie .properties import props_from_dict , props_to_dict
3333
3434from tornado .websocket import WebSocketClosedError
35- from tornado import ioloop
35+ from tornado import ioloop , log
3636
3737import collections
3838
@@ -166,6 +166,10 @@ def get_application(self, domain_name, app_id):
166166 dom = self ._get_domain (domain_name )
167167 return dom .find_app (app_id )
168168
169+ def _get_application (self , domain_name , app_id ):
170+ dom = self ._get_domain (domain_name )
171+ return dom .find_app (app_id )
172+
169173 @background_task
170174 def get_application_list (self , domain_name ):
171175 dom = self ._get_domain (domain_name )
@@ -186,8 +190,18 @@ def release_application(self, domain_name, app_id):
186190 dom = self ._get_domain (domain_name )
187191 return dom .release (app_id )
188192
193+ @background_task
194+ def application_configure (self , domain_name , app_id , new_properties ):
195+ app = self ._get_application (domain_name , app_id )
196+ props = app ._getPropertySet ()
197+ changes = Redhawk ._get_prop_changes (props , new_properties )
198+ return app .configure (changes )
199+
189200 ##############################
190201 # COMMON PROPERTIES
202+ '''
203+ Cleans out IDs being unicode, etc. since CF can't handle unicode strings.
204+ '''
191205 @staticmethod
192206 def _clean_property (property ):
193207 if isinstance (property , basestring ):
@@ -203,16 +217,22 @@ def _clean_property(property):
203217 # CF.Properties and dict() of { 'id': value, ... }
204218 # Use force to treat all ID matches as required changes
205219 def _get_prop_changes (current_props , new_properties , force = False ):
206- changes = {}
220+ changes = []
207221 for prop in current_props :
208222 if prop .id in new_properties :
209223 if new_properties [prop .id ] != prop .queryValue () or force :
210- changes [str (prop .id )] = prop .fromAny (
211- prop .toAny (
212- Redhawk ._clean_property (new_properties [prop .id ])
224+ changes .append (
225+ CF .DataType (
226+ prop .id ,
227+ prop .toAny (
228+ Redhawk ._clean_property (new_properties [prop .id ])
229+ )
213230 )
214231 )
215- return props_from_dict (changes )
232+ log .app_log .debug ('Current properties: {}' .format (current_props ))
233+ log .app_log .debug ('New properties: {}' .format (new_properties ))
234+ log .app_log .debug ('Changes: {}' .format (changes ))
235+ return changes
216236
217237 ##############################
218238 # COMPONENT
0 commit comments