Ejemplo n.º 1
0
 public static function event($_event)
 {
     scenario::check($_event);
 }
Ejemplo n.º 2
0
 public function event($_value, $_loop = 1)
 {
     if (trim($_value) === '' && $_value !== false || $_loop > 4 || $this->getType() != 'info') {
         return;
     }
     $value = $this->formatValue($_value);
     if ($this->getSubType() == 'numeric' && $value > $this->getConfiguration('maxValue', $value) && $value < $this->getConfiguration('minValue', $value) && strpos($value, 'error') === false) {
         return;
     }
     $eqLogic = $this->getEqLogic();
     if (!is_object($eqLogic) || $eqLogic->getIsEnable() == 0) {
         return;
     }
     $collectDate = $this->getCollectDate() != '' ? $this->getCollectDate() : date('Y-m-d H:i:s');
     $valueDate = $collectDate;
     if ($this->execCmd(null, 2) == $value) {
         if (strpos($value, 'error') === false) {
             $eqLogic->setStatus('lastCommunication', $collectDate);
         }
         if ($this->getConfiguration('doNotRepeatEvent', 0) == 1) {
             return;
         }
         $valueDate = $this->getValueDate();
     }
     $_loop++;
     $this->setCollectDate($collectDate);
     $this->setValueDate($valueDate);
     log::add('event', 'event', __('Evènement sur la commande ', __FILE__) . $this->getHumanName() . __(' valeur : ', __FILE__) . $value);
     cache::set('cmd' . $this->getId(), $value, $this->getCacheLifetime(), array('collectDate' => $this->getCollectDate(), 'valueDate' => $this->getValueDate()));
     scenario::check($this);
     $this->setCollect(0);
     $eqLogic->emptyCacheWidget();
     $nodeJs = array(array('cmd_id' => $this->getId()));
     $foundInfo = false;
     foreach (self::byValue($this->getId(), null, true) as $cmd) {
         if ($cmd->getType() == 'action') {
             $nodeJs[] = array('cmd_id' => $cmd->getId());
         } else {
             if ($_loop > 1) {
                 $cmd->event($cmd->execute(), $_loop);
             } else {
                 $foundInfo = true;
             }
         }
     }
     nodejs::pushUpdate('eventCmd', $nodeJs);
     if ($foundInfo) {
         listener::backgroundCalculDependencyCmd($this->getId());
     }
     listener::check($this->getId(), $value);
     if (strpos($value, 'error') === false) {
         $eqLogic->setStatus('lastCommunication', $collectDate);
         $this->addHistoryValue($value, $this->getCollectDate());
     } else {
         $this->addHistoryValue(null, $this->getCollectDate());
     }
     $this->checkReturnState($value);
     $this->checkCmdAlert($value);
     $this->pushUrl($value);
 }