Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

Retriever.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2004
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__ = "Housekeeping retriever module"
00012 __author__   = "J. Panetta <panetta@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__     = "7/20/2004"
00014 __version__  = "$Revision: 1.3 $"
00015 __credits__  = "SLAC"
00016 
00017 
00018 import LATTE.copyright_SLAC
00019 
00020 from LATTE.monitoring.Trendable import Trendable
00021 
00022 class Retriever(object):
00023   def __init__(self):
00024     pass
00025   def startup(self):
00026     pass
00027   def shutdown(self):
00028     pass
00029   def retrievePacket(self):
00030     raise NotImplementedError('retrievePacket()'\
00031                               +'must be implemented in a subclass.')
00032 
00033 class DummyRetriever(Retriever):
00034   """ Dummy retriever used for testing.
00035 
00036   Creates 24 trendable objects which are simply sin/cos functions.
00037   """
00038   def __init__(self):
00039     self.monitorList={}
00040     for i in range(12):
00041       self.monitorList['cos_'+'%02i'%(i,)]={'lofail':-0.9,'lowarn':-0.7,
00042                                             'hiwarn':0.7,'hifail':0.9}
00043       self.monitorList['sin_'+'%02i'%(i,)]={'lofail':-0.9,'lowarn':-0.7,
00044                                             'hiwarn':0.7,'hifail':0.9}
00045 
00046   def retrievePacket(self):
00047     import math, time
00048     t=time.time()  # time() returns seconds since epoch, UTC
00049     data=[]
00050     keys=self.monitorList.keys()
00051     keys.sort()
00052     for k in keys:
00053       if k.startswith('sin'):
00054         v=math.sin(t*math.pi/12)
00055       elif k.startswith('cos'):
00056         v=math.cos(t*math.pi/12)
00057       # print "appending Trendable ", k
00058       data.append(Trendable(k,t,{'Raw Value':v}))
00059     return data
00060 

Generated on Fri Jul 21 13:26:32 2006 for LATTE R04-12-00 by doxygen 1.4.3