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__ = "Example custom event archiver class" 00012 __author__ = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online" 00013 __date__ = ("$Date: 2004/08/26 02:01:16 $").split(' ')[1] 00014 __version__ = "$Revision: 1.2 $" 00015 __release__ = "$Name: R04-12-00 $" 00016 __credits__ = "SLAC" 00017 00018 import LATTE.copyright_SLAC 00019 00020 # History: 00021 # $Log: testArchiver.py,v $ 00022 # Revision 1.2 2004/08/26 02:01:16 stuvi 00023 # Fixed for LATTE 4 00024 # 00025 # Revision 1.1 2004/07/28 21:24:00 stuvi 00026 # Added testAppCal and its supporting classes. 00027 # 00028 # Revision 1.3 2004/03/08 21:40:23 stuvi 00029 # Added comments for userMethod. 00030 # 00031 # Revision 1.2 2004/03/06 01:18:26 stuvi 00032 # Added userMethod example 00033 # 00034 # Revision 1.1 2004/02/20 00:33:44 stuvi 00035 # Sample testArchiver app and class 00036 # 00037 # 00038 00039 from LATTE.runcontrol import rcArchiver 00040 import logging as log 00041 00042 class testArchiver(rcArchiver.rcArchiver): 00043 00044 def __init__(self, filePath=None, fileName=None): 00045 rcArchiver.rcArchiver.__init__(self, filePath, fileName) 00046 00047 def write(self, data): 00048 log.info("Writing data using the custom event archiver %s" % self.__class__.__name__) 00049 rcArchiver.rcArchiver.write(self, data) 00050 00051 def getFileNameFromTS(ts): 00052 return "custom" + ts + ".data" 00053 getFileNameFromTS = staticmethod(getFileNameFromTS) 00054 00055 def userMethod(self, data, moreData): 00056 """User defined method for adding custom data to the archive 00057 It should not be called before startRun() method since the 00058 archiver doesn't get instantiated before then. 00059 """ 00060 log.info("In userMethod of %s" % self.__class__.__name__) 00061 rcArchiver.rcArchiver.write(self, data) 00062 rcArchiver.rcArchiver.write(self, moreData) 00063