Ignore:
Timestamp:
12/10/12 19:28:32 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The basic strobe-less RTO handling logic works (#143)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/logger.py

    r346 r349  
    9797
    9898        def copy(self, timestamp = None, clearTimestamp = False, text = None,
    99                  faultScore = None):
     99                 faultID = None, faultScore = None, clearFault = False):
    100100            """Create a copy of this entry with the given values changed."""
    101             assert faultScore is None or self._faultID is not None
    102 
    103101            return Logger.Entry(None if clearTimestamp
    104102                                else self._timestamp if timestamp is None
     
    109107                                showTimestamp = self._showTimestamp,
    110108
    111                                 faultID = self._faultID,
     109                                faultID =
     110                                None if clearFault
     111                                else self._faultID if faultID is None
     112                                else faultID,
    112113
    113114                                faultScore =
    114                                 self._faultScore if faultScore is None
     115                                None if clearFault
     116                                else self._faultScore if faultScore is None
    115117                                else faultScore,
    116118
     
    248250
    249251    def fault(self, faultID, timestamp, what, score,
    250               updatePrevious = False):
     252              updatePrevious = False, updateID = None):
    251253        """Report a fault.
    252254
     
    262264        and the new score is not greater than the latest one, the ID of the
    263265        latest one is returned.
     266
     267        If updateID is given, the log entry with the given ID will be
     268        'upgraded' to be a fault with the given data.
    264269
    265270        Returns an ID of the fault, or -1 if it was not logged."""
     
    279284                                        faultScore = score)
    280285            self._updateEntry(id, newEntry)
     286        elif updateID is not None:
     287            id = updateID
     288            newEntry = self._entries[id].copy(timestamp = timestamp,
     289                                              text = text, faultID = faultID,
     290                                              faultScore = score)
     291            self._updateEntry(id, newEntry)
    281292        else:
    282293            id = self._addEntry(Logger.Entry(timestamp, text, faultID = faultID,
    283294                                             faultScore = score))
    284295
    285         (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \
    286                                   if score==Logger.NO_GO_SCORE \
    287                                   else (const.MESSAGETYPE_FAULT, 5)
    288         sendMessage(messageType, text, duration)
     296        if updateID is None:
     297            (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \
     298                                      if score==Logger.NO_GO_SCORE \
     299                                      else (const.MESSAGETYPE_FAULT, 5)
     300            sendMessage(messageType, text, duration)
    289301
    290302        return id
     
    311323        self._updateEntry(id, self._entries[id].copy(text = line))
    312324
     325    def clearFault(self, id, text):
     326        """Update the line with the given ID to contain the given string,
     327        and clear its fault state."""
     328        newEntry = self._entries[id].copy(text = text, clearFault = True)
     329        self._updateEntry(id, newEntry)
     330
    313331    def _addEntry(self, entry):
    314332        """Add the given entry to the log.
Note: See TracChangeset for help on using the changeset viewer.