00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 __facility__ = "Online"
00011 __abstract__ = "Dump FSW module names and versions from a unit"
00012 __author__ = "S. Tuvi <Stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__ = "2006/02/08 00:17:30"
00014 __updated__ = "$Date: 2006/04/18 01:31:29 $"
00015 __version__ = "$Revision: 1.3 $"
00016 __release__ = "$Name: HEAD $"
00017 __credits__ = "SLAC"
00018
00019 import LICOS.copyright_SLAC
00020
00021 import logging as log
00022 import struct
00023
00024 from LICOS.lib.scriptEngine.seAppBase import seAppBase
00025 from LICOS.lib.scriptEngine.ArgumentImpl import ArgumentImpl
00026 from LICOS.lib.cmdTlmDb.LCATcmdDb import LCATcmdDb
00027 from LICOS.lib.cmdTlmDb.LCATtlmDb import LCATtlmDb
00028 from LICOS.lib.cmdTlmDb.TelemetryEvent import TelemetryEvent
00029
00030
00031
00032
00033 class dumpModules(seAppBase):
00034 """!\brief Sample script based on seAppBase that demonstrates tele-commands.
00035
00036 Demonstrates queuing memory dump commands to the VSC.
00037
00038 """
00039 def __init__(self, common):
00040 """!\brief MemDump constructor.
00041
00042 \param common ScriptEngineCommon constructor
00043 """
00044 seAppBase.__init__(self, common)
00045 log.debug("%s.__init__()" % self.getName())
00046 self.__arg = None
00047
00048 def getName(self):
00049 """!\brief Return the name of this class.
00050
00051 \return Class name
00052 """
00053 return self.__class__.__name__
00054
00055 def setup(self):
00056 """!\brief SETUP transition method.
00057
00058 """
00059 log.debug("%s.setup()" % self.getName())
00060
00061 if self.rc is None:
00062 self.__arg = userArgText()
00063 else:
00064 self.rc.execGUImethod(self.createGUI)
00065
00066 def createGUI(self):
00067 """!\brief Create the argument GUI.
00068
00069 Must be passed to an execGUImethod.
00070 This is done here in a separate method so that the GUI creation
00071 and deletion is done in the GUI thread.
00072
00073 Executing self.__arg = self.rc.createGUI(userArgument, self.rc, 'test1', 1)
00074 does not work since the GUI object was being garbage collected (deleted)
00075 in the non-GUI thread.
00076 """
00077 self.__arg = userArgument(self.rc, 'test1', 1)
00078
00079 def run(self):
00080 """!\brief RUN transition method.
00081
00082 """
00083 log.debug("%s.run()" % self.getName())
00084
00085 caption = "Enter Unit Id"
00086 if self.rc is None:
00087 unit = self.__arg.getValue(caption)
00088 else:
00089 unit = self.rc.execGUImethod(self.__arg.getValue, caption)
00090
00091 if unit is None:
00092 self.setCompletionStatus(self.COMPL_STATUS_ABORTED)
00093 return -1
00094
00095 unit = unit << 12
00096
00097 self.lcatTlm = LCATtlmDb()
00098
00099 mnem = 'LLCMMODLIST'
00100
00101 modListTlm = TelemetryEvent(self.vsc.getDiagHandler(),
00102 [self.lcatTlm.getApidFromName(mnem)],
00103 self.printModule)
00104 modListTlm.enable()
00105
00106 lcat = LCATcmdDb(self.vsc)
00107 lcat.enableCmdConfirmTelem()
00108 lcatTlm = LCATtlmDb()
00109 lcm = lcat.LCM
00110 result = lcm.LCMMODDUMP(unit)
00111 if lcat.waitForSuccessfulConfirmation(timeout=60):
00112 self.setCompletionStatus(self.COMPL_STATUS_PASSED)
00113 else:
00114 self.setCompletionStatus(self.COMPL_STATUS_FAILED)
00115 modListTlm.disable()
00116 lcat.disableCmdConfirmTelem()
00117
00118
00119 def printModule(self, telem):
00120 pkt = self.lcatTlm.decodeTelemetry(telem)
00121 pkgName = ""
00122 for i in range(8):
00123 pkgName+=chr(pkt.get_payload("LCMMDMPPACKAGE%d" % i))
00124
00125 conName = ""
00126 for i in range(15):
00127 conName+=chr(pkt.get_payload("LCMMDMPCONSTIT%d" % i))
00128
00129 verStr = 'V%s-%s-%s' % (pkt.get_payload("LCMMDMPMAJVER"),
00130 pkt.get_payload("LCMMDMPMINVER"),
00131 pkt.get_payload("LCMMDMPPATVER"))
00132
00133 log.info('%(pkg)-8s %(con)-15s %(ver)s'% \
00134 {'pkg':pkgName.strip(),'ver':verStr.strip(),'con':conName.strip()})
00135
00136
00137 def teardown(self):
00138 """!\brief TEARDOWN transition method.
00139
00140 """
00141
00142 if self.__arg is not None:
00143 self.__arg.deleteLater()
00144
00145
00146
00147
00148 class userArgument(ArgumentImpl):
00149 """!\brief GUI for getting the user to input some sort of value.
00150
00151 """
00152 def __init__(self, parent = None, name = None, modal = 0, fl = 0):
00153 """!\brief userArgument constructor.
00154
00155 \param parent Parent GUI
00156 \param name GUI name
00157 \param modal Whether the dialog is modal or not
00158 \param fl GUI flags
00159 """
00160 ArgumentImpl.__init__(self, parent, name, modal, fl)
00161 self.__value = 0
00162 self.setCaption("Hello world!")
00163
00164 def OKButtonClicked(self):
00165 """!\brief Slot for the OK button.
00166
00167 """
00168 self.__value = int(self.ArgumentList.text().latin1())
00169 self.close()
00170
00171 def CancelButtonClicked(self):
00172 """!\brief Slot for the Cancel button.
00173
00174 """
00175 self.__value = None
00176 self.close()
00177
00178 def getValue(self, caption):
00179 """!\brief Bring up the GUI and return a value when OK is clicked.
00180
00181 \param caption Dialog caption
00182
00183 \return The value entered by the user
00184 """
00185 self.setCaption(caption)
00186 self.show()
00187 self.exec_loop()
00188 return self.__value
00189
00190 class userArgText(object):
00191 """!\brief Text user interface for getting the user to input some sort of value.
00192
00193 """
00194 def __init__(self):
00195 """!\brief userArgText constructor.
00196
00197 """
00198 pass
00199
00200 def getValue(self, caption):
00201 """!\brief Use console input to return a value from the user.
00202
00203 \return The value entered by the user
00204 """
00205 return int(raw_input("%s: " % (caption)))