LCM.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__ = "LCM 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/02/23 02:43:33 $"
00015 __version__  = "$Revision: 1.8 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 from LICOS.lib.cmdTlmDb.cmdTlmDb       import CmdPkg
00022 from LICOS.lib.LATconstants            import *
00023 from LICOS.lib.cmdTlmDb.TelemetryEvent import TelemetryEvent
00024 
00025 class LCM(CmdPkg):
00026   """!\brief LCM telecommand package class
00027 
00028   Provides access to LCM telecommands.
00029   """
00030   def __init__(self, db):
00031     """!\brief LCM constructor.
00032 
00033     \param db  Wrapper database object for the generated module
00034               containing command and telemetry database classes.
00035     """
00036     CmdPkg.__init__(self, db)
00037     self.__modList = None
00038 
00039   def modListPopulated(self):
00040     """!\brief Check if the module list has already been populated.
00041 
00042     \return Boolean specifying whether the module list is populated or not.
00043     """
00044     return (self.__modList is not None)
00045 
00046   def cmxAsBuilt(self, unitId, timeout=60, force=False):
00047     """!\brief Return name and versions of the FSW modules loaded on a unit.
00048 
00049     \param unitId  Unit id
00050     \param timeout Optional amount of seconds to wait until the version data
00051                    is completely received. Default is 60 seconds.
00052     \param force   Force version collection. Default is False.
00053 
00054     \return A list of tuples in the following format:
00055             (package name, constituent name, version)
00056     """
00057     if self.__modList is not None and not force:
00058       return self.__modList
00059     cmdDb = self.getCmdDb()
00060     # Check if we are in primary boot or not
00061     latHskTlm  = TelemetryEvent(cmdDb.getVsc().getTelemHandler(),
00062                                 range(0x210, 0x231))
00063     latHskTlm.enable()
00064     payloads = latHskTlm.waitForPayload([], timeout=5, quiet=True)
00065     latHskTlm.disable()
00066     if payloads is None:
00067       # We are in primary boot so skip version collection
00068       return None
00069     self.__modList = []
00070     modListTlm = TelemetryEvent(cmdDb.getVsc().getDiagHandler(),
00071                                 [cmdDb.getVsc().getTlmDb().getApidFromName('LLCMMODLIST')],
00072                                 self.__collectModuleInfo)
00073     modListTlm.enable()
00074     cmdConfirmTelemEnabled = cmdDb.isCmdConfirmTelemEnabled()
00075     if not cmdConfirmTelemEnabled:
00076       cmdDb.enableCmdConfirmTelem()
00077     saveCallback = cmdDb.getCmdConfirmCallback()
00078     cmdDb.setCmdConfirmCallback(cmdDb.quietConfirmation)
00079     self.LCMMODDUMP(unitId)
00080     if cmdDb.waitForSuccessfulConfirmation(timeout, quiet=True):
00081       result = True
00082     else:
00083       result = False
00084     cmdDb.setCmdConfirmCallback(saveCallback)
00085     if not cmdConfirmTelemEnabled:
00086       cmdDb.disableCmdConfirmTelem()
00087     modListTlm.disable()
00088     if result:
00089       return self.__modList
00090     else:
00091       return None
00092 
00093   def __collectModuleInfo(self, telem):
00094     lcatTlm = self.getCmdDb().getVsc().getTlmDb()
00095     pkt = lcatTlm.decodeTelemetry(telem)
00096     pkgName = ""
00097     for i in range(8):
00098       pkgName+=chr(pkt.get_payload("LCMMDMPPACKAGE%d" % i))
00099 
00100     conName = ""
00101     for i in range(15):
00102       conName+=chr(pkt.get_payload("LCMMDMPCONSTIT%d" % i))
00103 
00104     verStr = 'V%s-%s-%s' % (pkt.get_payload("LCMMDMPMAJVER"),
00105                             pkt.get_payload("LCMMDMPMINVER"),
00106                             pkt.get_payload("LCMMDMPPATVER"))
00107     self.__modList.append((pkgName, conName, verStr))

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