LHK.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__ = "LHK related mnemonics"
00012 __author__   = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__     = "2005/07/23 00:08:27"
00014 __updated__  = "$Date: 2006/04/07 01:19:19 $"
00015 __version__  = "$Revision: 1.16 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 import os
00022 import logging as log
00023 
00024 from LICOS.lib.cmdTlmDb.cmdTlmDb       import CmdPkg
00025 from LICOS.lib.cmdTlmDb.TelemetryEvent import TelemetryEvent
00026 from LICOS.lib.cmdTlmDb.FILE           import FswFileID
00027 from LICOS.lib.LATconstants            import *
00028 
00029 class LHK(CmdPkg):
00030   """!\brief LHK telecommand package class
00031 
00032   Provides access to LHK telecommands.
00033   """
00034   def __init__(self, db):
00035     """!\brief LHK constructor.
00036 
00037     \param db  Wrapper database object for the generated module
00038               containing command and telemetry database classes.
00039     """
00040     CmdPkg.__init__(self, db)
00041     self.__hskFileSeq = 0
00042     self.hskConfigs = {}
00043 
00044   def requestDiagHskPacket(self, apid, payloadMnems, timeout=10, count=1, interval=100):
00045     """!\brief Request a housekeeping diagnostic packet.
00046 
00047     This method requests a housekeeping diagnostic packet identified
00048     by \a apid, waits on it and returns the payload values corresponding
00049     to the \a payloadMnems list.
00050 
00051     Once the telemetry is received, the request is cancelled.
00052 
00053     \param apid         Housekeeping apid
00054     \param payloadMnems List of payload mnemonics
00055     \param timeout      Amount of time to wait for the packet
00056     \param count        Number of times the packet is requested
00057     \param interval     The interval between each packet
00058 
00059     \return A list of payload values or None if the packet times out.
00060             If a given payload mnemonic is not found its value is set to None.
00061     """
00062     self.LHKREQDIAGPKT(LHKDIAGAPID=apid, LHKDIAGCOUNT=count, LHKDIAGINTERVAL=interval)
00063     self.getCmdDb().waitForConfirmation(timeout)
00064     lhkDiagTlm = TelemetryEvent(self.getCmdDb().getVsc().getDiagHandler(), [apid + 0x60])
00065     lhkDiagTlm.enable()
00066     payloads = lhkDiagTlm.waitForPayload(payloadMnems, timeout)
00067     lhkDiagTlm.disable()
00068     self.LHKSTOPDIAG()
00069     self.getCmdDb().waitForConfirmation(timeout)
00070     return payloads
00071 
00072   def uploadHskCfg(self, hskCfgFile, fileNo, inputPath=LICOS_CONFIG_LHK):
00073     """!\brief Upload a HSK configuration file to the SIU.
00074 
00075     \param hskCfgFile HSK configuration file
00076     \param fileNo     File number
00077 
00078     \return File upload status, if None it means file upload failed
00079     """
00080     diskFileName = os.path.expandvars(os.path.join(inputPath, hskCfgFile))
00081 
00082     fileID = FswFileID( device     = FSW_DEVICE_RAM,
00083                         directory  = INT_DIR_LHK,
00084                         fileNumber = fileNo)
00085 
00086     log.debug("Uploading file %s with file ID 0x%08x=%d" %
00087               ( diskFileName, fileID.id(), fileID.id() ) )
00088 
00089     try:
00090       uplFile = self.getCmdDb().FILE.uploadFileFromDisk(
00091                                             fileName = diskFileName,
00092                                             unit     = FSW_UNIT_SIU,
00093                                             fileID   = fileID)
00094     except Exception, e:
00095       log.exception(e)
00096       return None
00097     else:
00098       self.hskConfigs[hskCfgFile] = uplFile
00099       return uplFile
00100 
00101   def getHskFileSeq(self):
00102     """!\brief Retrieve the next available file number.
00103 
00104     \return The next file number starting with 1
00105     """
00106     self.__hskFileSeq+=1
00107     return self.__hskFileSeq
00108 
00109   def clearHskConfigs(self):
00110     """!\brief Clear the HSK Config cache.
00111 
00112     """
00113     self.__hskFileSeq = 0
00114     self.hskConfigs = {}

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