Stop watches - reset of deadlines + overrun

SVN:trunk[2169]
This commit is contained in:
Romain Quetiez
2012-09-07 15:23:28 +00:00
parent 95785ee22d
commit 819b2663ca

View File

@@ -201,15 +201,11 @@ return false;
$sThresholdDesc = $oAttDef->SecondsToDate($aThresholdData['deadline']); $sThresholdDesc = $oAttDef->SecondsToDate($aThresholdData['deadline']);
if ($aThresholdData['triggered']) if ($aThresholdData['triggered'])
{ {
if ($aThresholdData['overrun']) $sThresholdDesc .= " <b>TRIGGERED</b>";
{ }
$sThresholdDesc .= " <b>TRIGGERED</b>, Overrun:".(int) $aThresholdData['overrun']." seconds"; if ($aThresholdData['overrun'])
} {
else $sThresholdDesc .= " Overrun:".(int) $aThresholdData['overrun']." sec.";
{
// Still active, overrun unknown
$sThresholdDesc .= " <b>TRIGGERED</b>";
}
} }
$aProperties[$iPercent.'%'] = $sThresholdDesc; $aProperties[$iPercent.'%'] = $sThresholdDesc;
} }
@@ -347,11 +343,14 @@ return false;
// The threshold is in the future, reset // The threshold is in the future, reset
$aThresholdData['passed'] = false; $aThresholdData['passed'] = false;
$aThresholdData['triggered'] = false; $aThresholdData['triggered'] = false;
$aThresholdData['overrun'] = null;
} }
else else
{ {
// The new threshold is in the past // The new threshold is in the past
$aThresholdData['passed'] = true; $aThresholdData['passed'] = true;
// Note: the overrun can be wrong, but the correct algorithm to compute
// the overrun of a deadline in the past requires that the ormStopWatch keeps track of all its history!!!
} }
} }
@@ -376,7 +375,6 @@ return false;
{ {
if (!is_null($aThresholdData['deadline']) && (time() > $aThresholdData['deadline'])) if (!is_null($aThresholdData['deadline']) && (time() > $aThresholdData['deadline']))
{ {
$aThresholdData['passed'] = true;
if ($aThresholdData['overrun'] > 0) if ($aThresholdData['overrun'] > 0)
{ {
// Accumulate from last start // Accumulate from last start
@@ -388,6 +386,8 @@ return false;
$iOverrun = $this->ComputeDuration($oObject, $oAttDef, $aThresholdData['deadline'], time()); $iOverrun = $this->ComputeDuration($oObject, $oAttDef, $aThresholdData['deadline'], time());
$aThresholdData['overrun'] = $iOverrun; $aThresholdData['overrun'] = $iOverrun;
} }
$aThresholdData['passed'] = true;
$aThresholdData['deadline'] = null;
} }
} }