Changeset 346:78e378a97bdf
- Timestamp:
- 12/08/12 15:22:06 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r344 r346 1292 1292 FaultChecker._appendDuring(flight, message), 1293 1293 FaultChecker._getLinearScore(50, 80, 10, 15, 1294 state.groundSpeed)) 1294 state.groundSpeed), 1295 updatePrevious = True) 1295 1296 1296 1297 def isCondition(self, flight, aircraft, oldState, state): -
src/mlx/flight.py
r304 r346 269 269 return False 270 270 271 def handleFault(self, faultID, timestamp, what, score): 271 def handleFault(self, faultID, timestamp, what, score, 272 updatePrevious = False): 272 273 """Handle the given fault. 273 274 … … 276 277 the score is greater than last time. This ID can be, e.g. the checker 277 278 the report comes from.""" 278 self.logger.fault(faultID, timestamp, what, score) 279 self.logger.fault(faultID, timestamp, what, score, 280 updatePrevious = updatePrevious) 279 281 self._gui.setRating(self.logger.getRating()) 280 282 -
src/mlx/logger.py
r345 r346 96 96 return self._faultScore 97 97 98 def copy(self, text = None): 98 def copy(self, timestamp = None, clearTimestamp = False, text = None, 99 faultScore = None): 99 100 """Create a copy of this entry with the given values changed.""" 100 return Logger.Entry(self._timestamp, 101 assert faultScore is None or self._faultID is not None 102 103 return Logger.Entry(None if clearTimestamp 104 else self._timestamp if timestamp is None 105 else timestamp, 106 101 107 self._text if text is None else text, 108 102 109 showTimestamp = self._showTimestamp, 110 103 111 faultID = self._faultID, 104 faultScore = self._faultScore, 112 113 faultScore = 114 self._faultScore if faultScore is None 115 else faultScore, 116 105 117 id = self._id) 106 118 … … 151 163 152 164 return len(entries)>0 165 166 def getLatestEntry(self): 167 """Get the entry with the highest score.""" 168 return self._entries[0] 153 169 154 170 # FIXME: shall we use const.stage2string() instead? … … 231 247 sendMessage(messageType, "Flight stage: " + s, 3) 232 248 233 def fault(self, faultID, timestamp, what, score): 249 def fault(self, faultID, timestamp, what, score, 250 updatePrevious = False): 234 251 """Report a fault. 235 252 … … 239 256 the report comes from. 240 257 258 If updatePrevious is True, and an instance of the given fault is 259 already in the log, only that instance will be updated with the new 260 timestamp and score. If there are several instances, the latest one 261 (with the highest score) will be updated. If updatePrevious is True, 262 and the new score is not greater than the latest one, the ID of the 263 latest one is returned. 264 241 265 Returns an ID of the fault, or -1 if it was not logged.""" 242 if faultID in self._faults: 243 if score<=self._faults[faultID].score: 244 return -1 266 fault = self._faults[faultID] if faultID in self._faults else None 267 268 if fault is not None and score<=fault.score: 269 return fault.getLatestEntry().id if updatePrevious else -1 245 270 246 271 text = "%s (NO GO)" % (what) if score==Logger.NO_GO_SCORE \ 247 272 else "%s (%.1f)" % (what, score) 248 273 249 id = self._addEntry(Logger.Entry(timestamp, text, faultID = faultID, 250 faultScore = score)) 274 if updatePrevious and fault is not None: 275 latestEntry = fault.getLatestEntry() 276 id = latestEntry.id 277 newEntry = latestEntry.copy(timestamp = timestamp, 278 text = text, 279 faultScore = score) 280 self._updateEntry(id, newEntry) 281 else: 282 id = self._addEntry(Logger.Entry(timestamp, text, faultID = faultID, 283 faultScore = score)) 251 284 252 285 (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \
Note:
See TracChangeset
for help on using the changeset viewer.