Ignore:
Timestamp:
02/08/12 16:28:21 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/logger.py

    r9 r11  
    1212class Logger(object):
    1313    """The class with the interface to log the various events."""
     14    # FIXME: shall we use const.stage2string() instead?
    1415    _stages = { const.STAGE_BOARDING : "Boarding",
    1516                const.STAGE_PUSHANDTAXI : "Pushback and Taxi",
     
    2526                const.STAGE_END : "End" }
    2627
     28    _noGoScore = 10000
     29
    2730    def __init__(self, output = sys.stdout):
    2831        """Construct the logger."""
    29         self._score = 100.0
     32        self._faults = {}
    3033        self._output = output
    3134
     
    5154        self.message(timestamp, "--- %s ---" % (s,))
    5255       
    53     def fault(self, timestamp, what, score):
    54         """Report a fault."""
    55         self._score -= score
    56         self.message(timestamp, "%s (%f)" % (what, score))
     56    def fault(self, faultID, timestamp, what, score):
     57        """Report a fault.
    5758
    58     def noGo(self, timestamp, what):
     59        faultID as a unique ID for the given kind of fault. If another fault of
     60        this ID has been reported earlier, it will be reported again only if
     61        the score is greater than last time. This ID can be, e.g. the checker
     62        the report comes from."""
     63        if faultID in self._faults:
     64            if score<=self._faults[faultID]:
     65                return
     66        self._faults[faultID] = score
     67        if score==Logger._noGoScore:
     68            self.message(timestamp, "%s (NO GO)" % (what))
     69        else:
     70            self.message(timestamp, "%s (%f)" % (what, score))
     71
     72    def noGo(self, faultID, timestamp, what, shortReason):
    5973        """Report a No-Go fault."""
    60         self._score = -1
    61         self.message(timestamp, "%s (NO GO)" % (what,))
     74        self.fault(faultID, timestamp, what, Logger._noGoScore)
    6275
    6376#--------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.