@@ -280,21 +280,31 @@ def add_event_subscriber(self,srv,dev,libpath=''):
280280 def add_attributes (self ,attributes ,* args ,** kwargs ):
281281 """
282282 Call add_attribute sequentially with a 1s pause between calls
283+ :param start: True by default, will force Start() in related archivers
283284 See add_attribute? for more help on arguments
284285 """
285286 try :
287+ start = kwargs .get ('start' ,True )
286288 for a in attributes :
289+ kwargs ['start' ] = False #Avoid recursive start
287290 self .add_attribute (a ,* args ,** kwargs )
288291 time .sleep (3. )
289292 for a in attributes :
290293 self .start_archiving (a )
294+
295+ if start :
296+ archs = set (map (self .get_attribute_archiver ,attributes ))
297+ for h in archs :
298+ self .info ('%s.Start()' % h )
299+ fn .get_device (h ).Start ()
300+
291301 except Exception ,e :
292302 print ('add_attribute(%s) failed!: %s' % (a ,traceback .print_exc ()))
293303 return
294304
295305 def add_attribute (self ,attribute ,archiver ,period = 0 ,
296306 rel_event = None ,per_event = 300000 ,abs_event = None ,
297- code_event = False , ttl = None ):
307+ code_event = False , ttl = None , start = False ):
298308 """
299309 set _event arguments to -1 to ignore them and not modify the database
300310
@@ -337,14 +347,21 @@ def add_attribute(self,attribute,archiver,period=0,
337347
338348 d .write_attribute ('SetArchiver' ,archiver )
339349 time .sleep (.2 )
340- #d.AttributeAdd()
341350 d .AttributeAdd ()
351+
352+ if start :
353+ arch = self .get_attribute_archiver (attribute )
354+ self .info ('%s.Start()' % arch )
355+ fn .get_device (arch ).Start ()
356+
342357 except Exception ,e :
343358 if 'already archived' not in str (e ).lower ():
344359 self .error ('add_attribute(%s,%s,%s): %s'
345360 % (attribute ,archiver ,period ,
346361 traceback .format_exc ().replace ('\n ' ,'' )))
347- return False
362+ else :
363+ self .warning ('%s already archived!' % attribute )
364+ return False
348365 finally :
349366 #self.warning('unlocking %s ..'%self.manager)
350367 d .unlock ()
0 commit comments