/**
  * Constructor
  *
  * @param integer $timestamp
  * @param integer $state
  * @param integer $num_undefined
  * @param integer $num_ok
  * @param integer $num_warning
  * @param integer $num_error
  * @param mixed   $message String or tx_caretaker_ResultMessage object
  * @param array   $submessages array of tx_caretaker_ResultMessage objects
  *
  */
 public function __construct($timestamp = 0, $state = tx_caretaker_Constants::state_undefined, $num_undefined = 0, $num_ok = 0, $num_warning = 0, $num_error = 0, $message = '', $submessages = NULL)
 {
     parent::__construct($timestamp, $state, $message, $submessages);
     $this->num_UNDEFINED = $num_undefined;
     $this->num_OK = $num_ok;
     $this->num_WARNING = $num_warning;
     $this->num_ERROR = $num_error;
 }
 /**
  *
  * @param tx_caretaker_TestNode $node
  * @param tx_caretaker_NodeResult $latestTestResult
  * @param array $options
  * @return boolean
  */
 protected function shouldReturnLatestResult($node, $latestTestResult, $options)
 {
     $forceUpdate = isset($options['forceUpdate']) && $options['forceUpdate'] === TRUE;
     $returnLatestResult = FALSE;
     if (!$forceUpdate) {
         if ($latestTestResult) {
             // test is not in due state so retry
             switch ($latestTestResult->getState()) {
                 case tx_caretaker_Constants::state_due:
                     $returnLatestResult = FALSE;
                     break;
                 case tx_caretaker_Constants::state_ack:
                     $returnLatestResult = TRUE;
                     break;
                 case tx_caretaker_Constants::state_ok:
                     if ($latestTestResult->getTstamp() > time() - $node->getTestInterval()) {
                         $returnLatestResult = TRUE;
                     }
                     break;
                 case tx_caretaker_Constants::state_undefined:
                 case tx_caretaker_Constants::state_warning:
                 case tx_caretaker_Constants::state_error:
                     // if due mode is 1 than retry
                     if ($node->getTestDue() == 1) {
                         $returnLatestResult = FALSE;
                     } else {
                         if ($latestTestResult->getTstamp() > time() - $node->getTestInterval()) {
                             $returnLatestResult = TRUE;
                         }
                     }
                     break;
             }
         }
         // test should not run this hour
         if (!$returnLatestResult && ($node->getStartHour() > 0 || $node->getStopHour() > 0)) {
             $localTime = localtime(time(), TRUE);
             $localHour = $localTime['tm_hour'];
             if ($localHour < $node->getStartHour() || $localHour >= $node->getStopHour()) {
                 $returnLatestResult = TRUE;
             }
         }
     }
     return $returnLatestResult;
 }
 /**
  * Check if another tx_caretaker_AggregatorResult is different from this one
  * @param tx_caretaker_AggregatorResult $result
  * @return boolean
  */
 public function isDifferent(tx_caretaker_NodeResult $result)
 {
     if ($this->getResultHash() != $result->getResultHash()) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Add a Result to Range
  *
  * @param tx_caretaker_NodeResult $result
  */
 public function addResult($result)
 {
     $ts = (int) $result->getTstamp();
     $this->array[$ts] = $result;
     if ($ts < $this->last_timestamp) {
         ksort($this->array);
     } else {
         $this->last_timestamp = $ts;
     }
     if ($this->start_timestamp !== NULL && $ts < $this->start_timestamp) {
         $this->start_timestamp = $ts;
     }
     if ($this->end_timestamp !== NULL && $ts > $this->end_timestamp) {
         $this->end_timestamp = $ts;
     }
 }
 /**
  * Get a combined and locallized Info of message and all submessages
  * @return string
  */
 public function getLocallizedInfotext()
 {
     $result = parent::getLocallizedInfotext();
     $result = str_replace('###STATE###', $this->getLocallizedStateInfo(), $result);
     $result = str_replace('###VALUE###', $this->getValue(), $result);
     return $result;
 }