Changeset 320:cc7c3c84efa0
- Timestamp:
- 10/02/12 15:46:17 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r319 r320 288 288 289 289 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) 292 293 293 294 #------------------------------------------------------------------------------- … … 371 372 def _getMessage(self, flight, state): 372 373 """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,) 374 376 375 377 #--------------------------------------------------------------------------------------- … … 411 413 #--------------------------------------------------------------------------------------- 412 414 413 class NAV1Logger(GenericStateChangeLogger): 415 class 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 444 class NAV1Logger(NAVLogger): 414 445 """Logger for the NAV1 radio setting.""" 415 446 def __init__(self): 416 447 """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 452 class NAV2Logger(NAVLogger): 422 453 """Logger for the NAV2 radio setting.""" 423 454 def __init__(self): 424 455 """Construct the logger.""" 425 super(NAV2Logger, self).__init__("nav2", "NAV2 frequency: %s MHz")456 super(NAV2Logger, self).__init__("nav2", "NAV2") 426 457 427 458 #--------------------------------------------------------------------------------------- -
src/mlx/fs.py
r317 r320 229 229 - nav1: the frequency of the NAV1 radio in MHz (string). Can be None, if 230 230 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. 231 233 - nav2: the frequency of the NAV1 radio in MHz (string). Can be None, if 232 234 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. 233 237 - adf1: the frequency of the ADF1 radio in kHz (string). Can be None, if 234 238 the frequency is unreliable or meaningless. -
src/mlx/fsuipc.py
r317 r320 1177 1177 ("altimeter", 0x0330, "H"), 1178 1178 ("nav1", 0x0350, "H"), 1179 ("nav1_obs", 0x0c4e, "H"), 1179 1180 ("nav2", 0x0352, "H"), 1181 ("nav2_obs", 0x035e, "H"), 1180 1182 ("adf1_main", 0x034c, "H"), 1181 1183 ("adf1_ext", 0x0356, "H"), … … 1362 1364 1363 1365 state.nav1 = AircraftModel.convertFrequency(data[self._monidx_nav1]) 1366 state.nav1_obs = data[self._monidx_nav1_obs] 1364 1367 state.nav2 = AircraftModel.convertFrequency(data[self._monidx_nav2]) 1368 state.nav2_obs = data[self._monidx_nav2_obs] 1365 1369 state.adf1 = \ 1366 1370 AircraftModel.convertADFFrequency(data[self._monidx_adf1_main],
Note:
See TracChangeset
for help on using the changeset viewer.