DiagTelemetryHandler.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 __facility__ = "Online"
00011 __abstract__ = "Diagnostics telemetry handler class"
00012 __author__   = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__     = "2005/09/19 10:00:00"
00014 __updated__  = "$Date: 2005/09/22 00:29:31 $"
00015 __version__  = "$Revision: 1.2 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 from VSC import VscHandling
00022 
00023 class DiagTelemetryHandler(VscHandling.TelemetryHandler):
00024   """!\brief Diagnostic telemetry handler class.
00025 
00026   """
00027   def __init__(self, apidRangeList):
00028     """!\brief DiagTelemetryHandler constructor.
00029 
00030     \param apidRangeList List containing from and to apids
00031     """
00032     VscHandling.TelemetryHandler.__init__(self)
00033     for (fromApId, toApId) in apidRangeList:
00034       self.handle(fromApId, toApId)
00035     self.callbacks = {}
00036 
00037   def process(self, telemetry):
00038     """!\brief Callback method for the telemetry handler.
00039 
00040     \param telemetry Raw telemetry packet
00041     """
00042     if telemetry.apid() in self.callbacks:
00043       for callback in self.callbacks[telemetry.apid()]:
00044         callback(telemetry)
00045 
00046   def register(self, apids, callback):
00047     """!\brief Register a callback for a given telemetry apid.
00048 
00049     \param apids    Telemetry apids
00050     \param callback Callback method
00051     """
00052     for apid in apids:
00053       if apid not in self.callbacks:
00054         self.callbacks[apid] = [callback]
00055       else:
00056         self.callbacks[apid].append(callback)
00057 
00058   def clear(self):
00059     """!\brief Clear all registered callbacks.
00060 
00061     """
00062     self.callbacks.clear()
00063 
00064   def unregister(self, apids, callback):
00065     """!\brief Unregister a registered callback.
00066 
00067     \param apids     Telemetry apids
00068     \param callback Callback method
00069     """
00070     for apid in apids:
00071       if apid in self.callbacks:
00072         if callback in self.callbacks[apid]:
00073           self.callbacks[apid].remove(callback)

Generated on Thu Apr 27 20:52:41 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO