LIM.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__ = "LIM 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/26 23:41:13 $"
00015 __version__  = "$Revision: 1.13 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 import logging as log
00022 import time
00023 
00024 from LICOS.lib.cmdTlmDb.cmdTlmDb       import CmdPkg
00025 from LICOS.lib.cmdTlmDb.TelemetryEvent import TelemetryEvent
00026 
00027 class LIM(CmdPkg):
00028   """!\brief LIM telecommand package class
00029 
00030   Provides access to LIM telecommands.
00031   """
00032     
00033   ## LIM Operating modes
00034   ( LIM_OP_MODE_TERMINAL,
00035     LIM_OP_MODE_QUIESCENT,
00036     LIM_OP_MODE_CALIBRATION,
00037     LIM_OP_MODE_DIAGNOSTIC,
00038     LIM_OP_MODE_PHYSICS,
00039     LIM_OP_MODE_PHYSICS_SAA,
00040     LIM_OP_MODE_TOO,
00041     LIM_OP_MODE_TOO_SAA,
00042     LIM_OP_MODE_ARR,
00043     LIM_OP_MODE_ARR_SAA,
00044     LIM_OP_MODE_HOLD,
00045   ) = range(11)
00046 
00047   OPERATING_MODES = {
00048                      LIM_OP_MODE_TERMINAL: 'TERMINAL',
00049                      LIM_OP_MODE_QUIESCENT: 'QUIESCENT',
00050                      LIM_OP_MODE_CALIBRATION: 'CALIBRATION',
00051                      LIM_OP_MODE_DIAGNOSTIC: 'DIAGNOSTIC',
00052                      LIM_OP_MODE_PHYSICS: 'PHYSICS',
00053                      LIM_OP_MODE_PHYSICS_SAA: 'PHYSICS-SAA',
00054                      LIM_OP_MODE_TOO: 'TOO',
00055                      LIM_OP_MODE_TOO_SAA: 'TOO-SAA',
00056                      LIM_OP_MODE_ARR: 'ARR',
00057                      LIM_OP_MODE_ARR_SAA: 'ARR-SAA',
00058                      LIM_OP_MODE_HOLD: 'HOLD',
00059                     }
00060 
00061   ## LIM Actions
00062   ( LIM_ACTION_UNKNOWN               ,
00063     LIM_ACTION_START                 ,
00064     LIM_ACTION_OP_MODE_CHANGE        ,
00065     LIM_ACTION_MAIN_FEED_ON          ,
00066     LIM_ACTION_POWER_ON              ,
00067     LIM_ACTION_POWER_OFF             ,
00068     LIM_ACTION_EVENT_CONFIG          ,
00069     LIM_ACTION_EVENT_INSERT          ,
00070     LIM_ACTION_EVENT_REMOVE          ,
00071     LIM_ACTION_SHED_BEGIN            ,
00072     LIM_ACTION_SHED_END              ,
00073     LIM_ACTION_SAFE_BEGIN            ,
00074     LIM_ACTION_SAFE_END              ,
00075     LIM_ACTION_PHYSICS_START         ,
00076     LIM_ACTION_PHYSICS_SET_MODE      ,
00077     LIM_ACTION_PHYSICS_STOP          ,
00078     LIM_ACTION_LTC_STOP              ,
00079     LIM_ACTION_SIU_REBOOT            ,
00080     LIM_ACTION_SAA_ENTER             ,
00081     LIM_ACTION_SAA_CONFIG            ,
00082     LIM_ACTION_SAA_EXIT              ,
00083     LIM_ACTION_NON_SAA_CONFIG        ,
00084     LIM_ACTION_CAL_START             ,
00085     LIM_ACTION_CAL_ABORT             ,
00086     LIM_ACTION_CAL_OTHER             ,
00087     LIM_ACTION_DIAG_START            ,
00088     LIM_ACTION_DIAG_ABORT            ,
00089     LIM_ACTION_DIAG_OTHER            ,
00090     NA                               ,
00091     NA                               ,
00092     LIM_ACTION_CAL_COMPLETE          ,
00093     LIM_ACTION_DIAG_COMPLETE         ,
00094     LIM_ACTION_PHYSICS_COMPLETE      ,
00095     LIM_ACTION_LCI_STATE_CHANGE      ,
00096     LIM_ACTION_LDF_STATE_CHANGE      ,
00097     LIM_ACTION_LPA_STATE_CHANGE      ,
00098     LIM_ACTION_ARR_READY             ,
00099     LIM_ACTION_ARR_STATE_CHANGE      ,
00100     LIM_ACTION_ARR_STOP              ,
00101     LIM_ACTION_TOO_READY             ,
00102     LIM_ACTION_TOO_STATE_CHANGE      ,
00103     LIM_ACTION_TOO_STOP              ,
00104     LIM_ACTION_PHYSICS_ACTIVE        ,
00105     LIM_ACTION_PHYSICS_IDLE          ,
00106     LIM_ACTION_VIRT_MODE_CHANGE      ,
00107     LIM_ACTION_SAA_CHANGE            ,
00108     LIM_ACTION_PHYSICS_RESTART       ,
00109     LIM_ACTION_RCV_GBM_REP_REC       ,
00110     LIM_ACTION_RCV_GBM_REP_NOREC     ,
00111     LIM_ACTION_GBM_COMMAND           ,
00112     LIM_ACTION_SEND_SLEW_REQ         ,
00113     LIM_ACTION_RCV_SLEW_ACCEPT       ,
00114     LIM_ACTION_RCV_SLEW_REJECT       ,
00115     LIM_ACTION_PID_SELECT_PRI        ,
00116     LIM_ACTION_PID_SELECT_RED        ,
00117     LIM_ACTION_STOP                  ,
00118     LIM_ACTION_BIAS_ACD              ,
00119     LIM_ACTION_BIAS_CAL              ,
00120     LIM_ACTION_BIAS_TKR              ,
00121     LIM_ACTION_GBM_STATE_CHANGE      ,
00122     LIM_ACTION_HV_STATE_CHANGE       ,
00123     LIM_ACTION_CAL_START_STATUS      ,
00124     LIM_ACTION_DIAG_START_STATUS     ,
00125     LIM_ACTION_PHYSICS_START_STATUS  ,
00126     LIM_ACTION_CAL_ABORT_STATUS      ,
00127     LIM_ACTION_DIAG_ABORT_STATUS     ,
00128     LIM_ACTION_PHYSICS_STOP_STATUS   ,
00129     LIM_ACTION_PID_EN_GBM_PRI        ,
00130     LIM_ACTION_PID_EN_GBM_RED        ,
00131     LIM_ACTION_GBM_INT_PRI           ,
00132     LIM_ACTION_GBM_INT_RED           ,
00133     LIM_ACTION_REP_REQ_STATE_CHANGE  ,
00134     LIM_ACTION_RCV_GBM_CALCINFO      ,
00135     LIM_ACTION_RCV_GBM_CLOSEOUT      ,
00136     LIM_ACTION_PID_DIS_GBM_PRI       ,
00137     LIM_ACTION_PID_DIS_GBM_RED       ,
00138   ) = range(76)
00139 
00140   ACTIONS = {
00141     LIM_ACTION_UNKNOWN              : "Unknown action",
00142     LIM_ACTION_START                : "The LIM task started",
00143     LIM_ACTION_OP_MODE_CHANGE       : "The operating mode changed",
00144     LIM_ACTION_MAIN_FEED_ON         : "LIM enabled power to the main feed and initialized the SIU",
00145     LIM_ACTION_POWER_ON             : "LIM enabled power to one or more components of the LAT",
00146     LIM_ACTION_POWER_OFF            : "LIM disabled power from one or more components of the LAT",
00147     LIM_ACTION_EVENT_CONFIG         : "LIM configured the event fabric",
00148     LIM_ACTION_EVENT_INSERT         : "LIM added one or more components to the event fabric",
00149     LIM_ACTION_EVENT_REMOVE         : "LIM removed one or more components from the event fabric",
00150     LIM_ACTION_SHED_BEGIN           : "LIM started disabling instrument power in response to a Load-Shed command",
00151     LIM_ACTION_SHED_END             : "LIM finished disabling instrument power in response to a Load-Shed command",
00152     LIM_ACTION_SAFE_BEGIN           : "LIM started the Safe-Mode procedure",
00153     LIM_ACTION_SAFE_END             : "LIM finished the Safe-Mode procedure and is about to reboot the SIU",
00154     LIM_ACTION_PHYSICS_START        : "LIM sent the Physics-Start command to the LPA task",
00155     LIM_ACTION_PHYSICS_SET_MODE     : "LIM called the LPA_set_mode() function to change the observation mode",
00156     LIM_ACTION_PHYSICS_STOP         : "LIM sent the Physics-Stop command to the LPA task",
00157     LIM_ACTION_LTC_STOP             : "LIM sent the LTC-Stop command to the LTC task",
00158     LIM_ACTION_SIU_REBOOT           : "LIM is about to reboot the SIU",
00159     LIM_ACTION_SAA_ENTER            : "LIM received SAA entry notification",
00160     LIM_ACTION_SAA_CONFIG           : "LIM configured the LAT instrument for SAA transit",
00161     LIM_ACTION_SAA_EXIT             : "LIM received SAA exit notification",
00162     LIM_ACTION_NON_SAA_CONFIG       : "LIM configured the LAT instrument for non-SAA operation",
00163     LIM_ACTION_CAL_START            : "LIM sent the Calibration-Start command to the LCI task",
00164     LIM_ACTION_CAL_ABORT            : "LIM sent the Calibration-Abort command to the LCI task",
00165     LIM_ACTION_CAL_OTHER            : "LIM sent some 'other' command to the LCI task",
00166     LIM_ACTION_DIAG_START           : "LIM sent the Diagnostic-Start command to the LDF task",
00167     LIM_ACTION_DIAG_ABORT           : "LIM sent the Diagnostic-Abort command to the LDF task",
00168     LIM_ACTION_DIAG_OTHER           : "LIM sent some 'other' command to the LDF task",
00169     LIM_ACTION_CAL_COMPLETE         : "LIM received the Calibration-Complete command from the LCI task",
00170     LIM_ACTION_DIAG_COMPLETE        : "LIM received the Diagnostic-Complete command from the LDF task",
00171     LIM_ACTION_PHYSICS_COMPLETE     : "LIM received the Physics-Complete command from the LPA task",
00172     LIM_ACTION_LCI_STATE_CHANGE     : "LIM changed the state of the LCI task",
00173     LIM_ACTION_LDF_STATE_CHANGE     : "LIM changed the state of the LDF task",
00174     LIM_ACTION_LPA_STATE_CHANGE     : "LIM changed the state of the LPA task",
00175     LIM_ACTION_ARR_READY            : "The ARR repointed observation is now ready to start",
00176     LIM_ACTION_ARR_STATE_CHANGE     : "The ARR observation state changed",
00177     LIM_ACTION_ARR_STOP             : "The ARR repointed observation is now stopped",
00178     LIM_ACTION_TOO_READY            : "The TOO repointed observation is now ready to start",
00179     LIM_ACTION_TOO_STATE_CHANGE     : "The TOO observation state changed",
00180     LIM_ACTION_TOO_STOP             : "The TOO repointed observation is now stopped",
00181     LIM_ACTION_PHYSICS_ACTIVE       : "LIM sent an 'active' command to the LPA task",
00182     LIM_ACTION_PHYSICS_IDLE         : "LIM sent an 'idle' command to the LPA task",
00183     LIM_ACTION_VIRT_MODE_CHANGE     : "The virtual mode changed",
00184     LIM_ACTION_SAA_CHANGE           : "The SAA transit state changed",
00185     LIM_ACTION_PHYSICS_RESTART      : "LIM called the LPA_resume() function to restart an observation",
00186     LIM_ACTION_RCV_GBM_REP_REC      : "LIM received a GBM Candidate Repoint Recommendation command which recommended a repoint",
00187     LIM_ACTION_RCV_GBM_REP_NOREC    : "LIM received a GBM Candidate Repoint Recommendation command which did not recommend a repoint",
00188     LIM_ACTION_GBM_COMMAND          : "LIM forwarded a GBM command to the LPA task",
00189     LIM_ACTION_SEND_SLEW_REQ        : "LIM sent a Slew-Request command to the spacecraft",
00190     LIM_ACTION_RCV_SLEW_ACCEPT      : "LIM received a Slew-Request-Reply from the spacecraft which indicated that the request was accepted",
00191     LIM_ACTION_RCV_SLEW_REJECT      : "LIM received a Slew-Request-Reply from the spacecraft which indicated that the request was rejected",
00192     LIM_ACTION_PID_SELECT_PRI       : "LIM selected the primary PID input signals",
00193     LIM_ACTION_PID_SELECT_RED       : "LIM selected the redundant PID input signals",
00194     LIM_ACTION_STOP                 : "The LIM task was stopped",
00195     LIM_ACTION_BIAS_ACD             : "LIM configured the ACD bias voltages",
00196     LIM_ACTION_BIAS_CAL             : "LIM configured the CAL bias voltages",
00197     LIM_ACTION_BIAS_TKR             : "LIM configured the TKR bias voltages",
00198     LIM_ACTION_GBM_STATE_CHANGE     : "The configuration of the GBM interface changed",
00199     LIM_ACTION_HV_STATE_CHANGE      : "The configuration of the high-voltage interface changed",
00200     LIM_ACTION_CAL_START_STATUS     : "LIM received a status code for a Calibration-Start command that it sent to the LCI task",
00201     LIM_ACTION_DIAG_START_STATUS    : "LIM received a status code for a Diagnostic-Start command that it sent to the LDF task",
00202     LIM_ACTION_PHYSICS_START_STATUS : "LIM received a status code for a Physics-Start command that it sent to the LPA task",
00203     LIM_ACTION_CAL_ABORT_STATUS     : "LIM received a status code for a Calibration-Abort command that it sent to the LCI task",
00204     LIM_ACTION_DIAG_ABORT_STATUS    : "LIM received a status code for a Diagnostic-Abort command that it sent to the LDF task",
00205     LIM_ACTION_PHYSICS_STOP_STATUS  : "LIM received a status code for a Physics-Stop command that it sent to the LPA task",
00206     LIM_ACTION_PID_EN_GBM_PRI       : "LIM enabled the primary GBM interrupt signal",
00207     LIM_ACTION_PID_EN_GBM_RED       : "LIM enabled the redundant GBM interrupt signal",
00208     LIM_ACTION_GBM_INT_PRI          : "LIM received an interrupt on the primary GBM interrupt signal",
00209     LIM_ACTION_GBM_INT_RED          : "LIM received an interrupt on the redundant GBM interrupt signal",
00210     LIM_ACTION_REP_REQ_STATE_CHANGE : "The repoint request PENDING status changed",
00211     LIM_ACTION_RCV_GBM_CALCINFO     : "LIM received a GBM Calculated Information command",
00212     LIM_ACTION_RCV_GBM_CLOSEOUT     : "LIM received a GBM Closeout command",
00213     LIM_ACTION_PID_DIS_GBM_PRI      : "LIM disabled the primary GBM interrupt signal",
00214     LIM_ACTION_PID_DIS_GBM_RED      : "LIM disbled the redundant GBM interrupt signal",
00215   }
00216 
00217   ## LIM GRB States
00218   ( LIM_GRB_STATE_IDLE,
00219     NA,
00220     NA,
00221     NA,
00222     LIM_GRB_STATE_0,
00223     LIM_GRB_STATE_1,
00224     LIM_GRB_STATE_2,
00225   ) = range(7)
00226   
00227   GRB_STATES =  {
00228                   LIM_GRB_STATE_IDLE: "No GRB in progress",
00229                   LIM_GRB_STATE_0: "GRB0 state - a GRB is suspected, but the spacecraft has not been repointed",
00230                   LIM_GRB_STATE_1: "GRB1 state - a GRB has been confirmed   and the spacecraft has been repointed",
00231                   LIM_GRB_STATE_2: "GRB2 state - a GRB has ended, but the spacecraft is still repointed",
00232                 }
00233 
00234   def __init__(self, db):
00235     """!\brief LIM constructor.
00236 
00237     \param db  Wrapper database object for the generated module
00238               containing command and telemetry database classes.
00239     """
00240     CmdPkg.__init__(self, db)
00241     self.__limOperatingMode = None
00242     self.__limAction = None
00243     self.__limStatus = None
00244     # Setup a telemetry handler for the "State" telemetry.
00245     vsc = self.getCmdDb().getVsc()
00246     self.__limStatusTlm  = TelemetryEvent(vsc.getDiagHandler(),
00247                                 [vsc.getTlmDb().getApidFromName('State')],
00248                                 self.__setLimState)
00249     # Threshold interval in seconds for the LIM state to be considered stale
00250     self.__limStaleThreshold = 180 # Default to 3 minutes
00251     self.__lastLimStateUpdate = None
00252 
00253   def startStateMonitor(self):
00254     """!\brief Enable the "State" telemetry handler.
00255 
00256     """
00257     self.__limStatusTlm.enable()
00258 
00259   def stopStateMonitor(self):
00260     """!\brief Disable the "State" telemetry handler.
00261 
00262     """
00263     self.__limStatusTlm.disable()
00264 
00265   def __setLimState(self, telem):
00266     """!\brief Callback method for processing the "State" telemetry.
00267 
00268     \param telem Telemetry object
00269     """
00270     lcatTlm = self.getCmdDb().getVsc().getTlmDb()
00271     pkt = lcatTlm.decodeTelemetry(telem)
00272     self.__limOperatingMode = pkt.get_payload("LIMTOPMODE")
00273     self.__limAction        = pkt.get_payload("LIMTACTION")
00274     self.__limStatus        = pkt.get_payload("LIMTSTATUS")
00275     self.__limSaaTransit    = pkt.get_payload("LIMTSAATRANSIT")
00276     self.__limHvAllow       = pkt.get_payload("LIMTHVALLOW")
00277     log.debug("LIM State:")
00278     log.debug("\tOperating Mode: %d" % self.__limOperatingMode)
00279     log.debug("\tAction        : %d" % self.__limAction)
00280     log.debug("\tStatus        : 0x%08x - %s" % (self.__limStatus,
00281                                          lcatTlm.msgByValue(self.__limStatus)))
00282     log.debug("\tSaaTransit    : %d" % self.__limSaaTransit)
00283     log.debug("\tHV Allow      : %d" % self.__limHvAllow)
00284     self.__lastLimStateUpdate = time.time()
00285 
00286   def getOperatingMode(self):
00287     """!\brief Retrieve the LIM operating mode.
00288 
00289     \return Numeric value of the LIM operating mode
00290     """
00291     return self.__limOperatingMode
00292 
00293   def getOperatingModeStr(self):
00294     """!\brief Retrieve the LIM operating mode string.
00295 
00296     \return String value of the LIM operating mode
00297     """
00298     if self.__limOperatingMode in self.OPERATING_MODES:
00299       return self.OPERATING_MODES[self.__limOperatingMode]
00300 
00301   def getAction(self):
00302     """!\brief Retrieve the LIM action performed.
00303 
00304     \return Numeric value of the LIM action performed
00305     """
00306     return self.__limAction
00307 
00308   def getActionStr(self):
00309     """!\brief Retrieve the LIM action performed.
00310 
00311     \return String value of the LIM action performed
00312     """
00313     if self.__limAction in self.ACTIONS:
00314       return self.ACTIONS[self.__limAction]
00315 
00316   def getStatus(self):
00317     """!\brief Retrieve the status of the last LIM action performed.
00318 
00319     \return Status tuple of the last LIM action performed
00320     """
00321     return self.__limStatus
00322 
00323   def getStatusStr(self):
00324     """!\brief Retrieve the status of the last LIM action performed.
00325 
00326     \return Status string of the last LIM action performed
00327     """
00328     if self.__limStatus is not None:
00329       lcatTlm = self.getCmdDb().getVsc().getTlmDb()
00330       return lcatTlm.msgByValue(self.__limStatus)[1]
00331 
00332   def isLimStateStale(self):
00333     """!\brief Check if the last received LIM State telemetry is stale.
00334 
00335     \return Booleean indication whether the LIM state is stale.
00336     """
00337     if self.__lastLimStateUpdate is not None and \
00338        time.time() - self.__lastLimStateUpdate > self.__limStaleThreshold:
00339       return True
00340     else:
00341       return False
00342 
00343   def setStaleThreshold(self, threshold):
00344     """!\brief Set the stale interval threshold in seconds.
00345 
00346     \param threshold Threshold in seconds.
00347     """
00348     self.__limStaleThreshold = threshold

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