Changeset 320:cc7c3c84efa0 for src/mlx


Ignore:
Timestamp:
10/02/12 15:46:17 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for logging the OBS settings for navigational radios

Location:
src/mlx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r319 r320  
    288288       
    289289        if shouldLog:
    290             logger.message(self._getLogTimestamp(state),
    291                            self._getMessage(flight, state))
     290            message = self._getMessage(flight, state)
     291            if message is not None:
     292                logger.message(self._getLogTimestamp(state), message)
    292293       
    293294#-------------------------------------------------------------------------------
     
    371372    def _getMessage(self, flight, state):
    372373        """Get the message."""
    373         return self._template % (self._getValue(state),)
     374        value = self._getValue(state)       
     375        return None if value is None else self._template % (value,)
    374376
    375377#---------------------------------------------------------------------------------------
     
    411413#---------------------------------------------------------------------------------------
    412414
    413 class NAV1Logger(GenericStateChangeLogger):
     415class NAVLogger(StateChangeLogger, DelayedChangeMixin):
     416    """Logger for NAV radios.
     417
     418    It also logs the OBS frequency set."""
     419    def __init__(self, attrName, logName):
     420        """Construct the NAV logger."""
     421        StateChangeLogger.__init__(self, logInitial = True)
     422        DelayedChangeMixin.__init__(self)
     423
     424        self._attrName = attrName
     425        self._logName = logName
     426       
     427    def _getValue(self, state):
     428        """Get the value.
     429
     430        If both the frequency and the obs settings are available, a tuple
     431        containing them is returned, otherwise None."""
     432        frequency = getattr(state, self._attrName)
     433        obs = getattr(state, self._attrName + "_obs")
     434        return None if frequency is None or obs is None else (frequency, obs)
     435
     436    def _getMessage(self, flight, state):
     437        """Get the message."""
     438        value = self._getValue(state)
     439        return None if value is None else \
     440               (u"%s frequency: %s MHz [%d\u00b0]" % (self._logName, value[0], value[1]))
     441
     442#---------------------------------------------------------------------------------------
     443
     444class NAV1Logger(NAVLogger):
    414445    """Logger for the NAV1 radio setting."""
    415446    def __init__(self):
    416447        """Construct the logger."""
    417         super(NAV1Logger, self).__init__("nav1", "NAV1 frequency: %s MHz")
    418 
    419 #---------------------------------------------------------------------------------------
    420 
    421 class NAV2Logger(GenericStateChangeLogger):
     448        super(NAV1Logger, self).__init__("nav1", "NAV1")
     449
     450#---------------------------------------------------------------------------------------
     451
     452class NAV2Logger(NAVLogger):
    422453    """Logger for the NAV2 radio setting."""
    423454    def __init__(self):
    424455        """Construct the logger."""
    425         super(NAV2Logger, self).__init__("nav2", "NAV2 frequency: %s MHz")
     456        super(NAV2Logger, self).__init__("nav2", "NAV2")
    426457
    427458#---------------------------------------------------------------------------------------
  • src/mlx/fs.py

    r317 r320  
    229229    - nav1: the frequency of the NAV1 radio in MHz (string). Can be None, if
    230230    the frequency is unreliable or meaningless.
     231    - nav1_obs: the OBS setting of the NAV1 radio in degrees (int). Can be None, if
     232    the value is unreliable or meaningless.
    231233    - nav2: the frequency of the NAV1 radio in MHz (string). Can be None, if
    232234    the frequency is unreliable or meaningless.
     235    - nav2_obs: the OBS setting of the NAV2 radio in degrees (int). Can be None, if
     236    the value is unreliable or meaningless.
    233237    - adf1: the frequency of the ADF1 radio in kHz (string). Can be None, if
    234238    the frequency is unreliable or meaningless.
  • src/mlx/fsuipc.py

    r317 r320  
    11771177                      ("altimeter", 0x0330, "H"),
    11781178                      ("nav1", 0x0350, "H"),
     1179                      ("nav1_obs", 0x0c4e, "H"),
    11791180                      ("nav2", 0x0352, "H"),
     1181                      ("nav2_obs", 0x035e, "H"),
    11801182                      ("adf1_main", 0x034c, "H"),
    11811183                      ("adf1_ext", 0x0356, "H"),
     
    13621364           
    13631365        state.nav1 = AircraftModel.convertFrequency(data[self._monidx_nav1])
     1366        state.nav1_obs = data[self._monidx_nav1_obs]
    13641367        state.nav2 = AircraftModel.convertFrequency(data[self._monidx_nav2])
     1368        state.nav2_obs = data[self._monidx_nav2_obs]
    13651369        state.adf1 = \
    13661370            AircraftModel.convertADFFrequency(data[self._monidx_adf1_main],
Note: See TracChangeset for help on using the changeset viewer.