当前位置: 首页>>代码示例>>PHP>>正文


PHP jeedom::evaluateExpression方法代码示例

本文整理汇总了PHP中jeedom::evaluateExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP jeedom::evaluateExpression方法的具体用法?PHP jeedom::evaluateExpression怎么用?PHP jeedom::evaluateExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jeedom的用法示例。


在下文中一共展示了jeedom::evaluateExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute($_options = array())
 {
     $replace = array();
     switch ($this->getSubType()) {
         case 'slider':
             $replace['#slider#'] = $_options['slider'];
             break;
         case 'color':
             $replace['#color#'] = $_options['color'];
             break;
         case 'message':
             $replace['#title#'] = $_options['title'];
             $replace['#message#'] = $_options['message'];
             break;
     }
     $eqLogic = $this->getEqLogic();
     $url = 'https://maker.ifttt.com/trigger/' . $this->getConfiguration('event', 'jeedom') . '/with/key/' . $eqLogic->getConfiguration('key') . '?';
     if ($this->getConfiguration('value1') != '') {
         $url .= 'value1=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value1')))) . '&';
     }
     if ($this->getConfiguration('value2') != '') {
         $url .= 'value2=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value2')))) . '&';
     }
     if ($this->getConfiguration('value3') != '') {
         $url .= 'value3=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value3')))) . '&';
     }
     $url = trim($url, '&');
     $request_http = new com_http($url);
     $request_http->exec(5, 3);
 }
开发者ID:jeedom,项目名称:plugin-ifttt,代码行数:30,代码来源:ifttt.class.php

示例2: checkCmdAlert

 public function checkCmdAlert($_value)
 {
     if ($this->getConfiguration('jeedomCheckCmdOperator') == '' || $this->getConfiguration('jeedomCheckCmdTest') == '' || $this->getConfiguration('jeedomCheckCmdTime') == '' || is_nan($this->getConfiguration('jeedomCheckCmdTime'))) {
         return;
     }
     $check = jeedom::evaluateExpression($_value . $this->getConfiguration('jeedomCheckCmdOperator') . $this->getConfiguration('jeedomCheckCmdTest'));
     if ($check == 1 || $check || $check == '1') {
         if ($this->getConfiguration('jeedomCheckCmdTime') == 0) {
             $this->executeAlertCmdAction();
             return;
         }
         $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId())));
         if (!is_object($cron)) {
             $cron = new cron();
         }
         $cron->setClass('cmd');
         $cron->setFunction('cmdAlert');
         $cron->setOnce(1);
         $cron->setOption(array('cmd_id' => intval($this->getId())));
         $next = strtotime('+ ' . ($this->getConfiguration('jeedomCheckCmdTime') + 1) . ' minutes ' . date('Y-m-d H:i:s'));
         $schedule = date('i', $next) . ' ' . date('H', $next) . ' ' . date('d', $next) . ' ' . date('m', $next) . ' * ' . date('Y', $next);
         $cron->setSchedule($schedule);
         $cron->setLastRun(date('Y-m-d H:i:s'));
         $cron->save();
     } else {
         $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId())));
         if (is_object($cron)) {
             $cron->remove();
         }
     }
 }
开发者ID:jimibi,项目名称:core,代码行数:31,代码来源:cmd.class.php

示例3: toHtml

 public function toHtml($_version = 'dashboard')
 {
     if ($this->getIsEnable() != 1) {
         return '';
     }
     if (!$this->hasRight('r')) {
         return '';
     }
     $_version = jeedom::versionAlias($_version);
     $background = $this->getBackgroundColor($_version);
     $replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#eqLink#' => $this->getLinkToConfiguration(), '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', '200px'), '#temperature_airneufexterieur#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufexterieur')), '#temperature_airneufinsuflé#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufinsuflé')), '#temperature_airvicie#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicie')), '#temperature_airvicierejete#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicierejete')));
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     $html = template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'vmc'));
     return $html;
 }
开发者ID:GaelGRIFFON,项目名称:Plugin-VMC,代码行数:20,代码来源:vmc.class.php

示例4: execute

 public function execute(&$_scenario)
 {
     if ($this->getType() == 'if') {
         if ($this->getSubElement('if')->execute($_scenario)) {
             if ($this->getSubElement('if')->getOptions('allowRepeatCondition', 0) == 1) {
                 if ($this->getSubElement('if')->getOptions('previousState', -1) != 1) {
                     $this->getSubElement('if')->setOptions('previousState', 1);
                     $this->getSubElement('if')->save();
                 } else {
                     $_scenario->setLog(__('Non exécution des actions pour cause de répétition', __FILE__));
                     return;
                 }
             }
             return $this->getSubElement('then')->execute($_scenario);
         }
         if (!is_object($this->getSubElement('else'))) {
             return;
         }
         if ($this->getSubElement('if')->getOptions('allowRepeatCondition', 0) == 1) {
             if ($this->getSubElement('if')->getOptions('previousState', -1) != 0) {
                 $this->getSubElement('if')->setOptions('previousState', 0);
                 $this->getSubElement('if')->save();
             } else {
                 $_scenario->setLog(__('Non exécution des actions pour cause de répétition', __FILE__));
                 return;
             }
         }
         return $this->getSubElement('else')->execute($_scenario);
     } else {
         if ($this->getType() == 'action') {
             return $this->getSubElement('action')->execute($_scenario);
         } else {
             if ($this->getType() == 'code') {
                 return $this->getSubElement('code')->execute($_scenario);
             } else {
                 if ($this->getType() == 'for') {
                     $for = $this->getSubElement('for');
                     $limits = $for->getExpression();
                     $limits = intval(jeedom::evaluateExpression($limits[0]->getExpression()));
                     if (!is_numeric($limits)) {
                         $_scenario->setLog(__('[ERREUR] La condition pour une boucle doit être numérique : ', __FILE__) . $limits);
                         throw new Exception(__('La condition pour une boucle doit être numérique : ', __FILE__) . $limits);
                     }
                     $return = false;
                     for ($i = 1; $i <= $limits; $i++) {
                         $return = $this->getSubElement('do')->execute($_scenario);
                     }
                     return $return;
                 } else {
                     if ($this->getType() == 'in') {
                         $in = $this->getSubElement('in');
                         $in = $in->getExpression();
                         $time = ceil(str_replace('.', ',', jeedom::evaluateExpression($in[0]->getExpression())));
                         if (!is_numeric($time) || $time < 0) {
                             $time = 0;
                         }
                         if ($time == 0) {
                             $cmd = '/usr/bin/php ' . dirname(__FILE__) . '/../../core/php/jeeScenario.php ';
                             $cmd .= ' scenario_id=' . $_scenario->getId();
                             $cmd .= ' scenarioElement_id=' . $this->getId();
                             $cmd .= ' >> ' . log::getPathToLog('scenario_element_execution') . ' 2>&1 &';
                             exec($cmd);
                         } else {
                             $crons = cron::searchClassAndFunction('scenario', 'doIn', '"scenarioElement_id":' . $this->getId());
                             if (is_array($crons)) {
                                 foreach ($crons as $cron) {
                                     if ($cron->getState() != 'run') {
                                         $cron->remove();
                                     }
                                 }
                             }
                             $cron = new cron();
                             $cron->setClass('scenario');
                             $cron->setFunction('doIn');
                             $cron->setOption(array('scenario_id' => intval($_scenario->getId()), 'scenarioElement_id' => intval($this->getId()), 'second' => date('s')));
                             $cron->setLastRun(date('Y-m-d H:i:s'));
                             $cron->setOnce(1);
                             $next = strtotime('+ ' . $time . ' min');
                             $cron->setSchedule(date('i', $next) . ' ' . date('H', $next) . ' ' . date('d', $next) . ' ' . date('m', $next) . ' * ' . date('Y', $next));
                             $cron->save();
                             $_scenario->setLog(__('Tâche : ', __FILE__) . $this->getId() . __(' programmé à : ', __FILE__) . date('Y-m-d H:i:00', $next) . ' (+ ' . $time . ' min)');
                         }
                         return true;
                     } else {
                         if ($this->getType() == 'at') {
                             $at = $this->getSubElement('at');
                             $at = $at->getExpression();
                             $next = jeedom::evaluateExpression($at[0]->getExpression());
                             if ($next % 100 > 59) {
                                 if (strpos($at[0]->getExpression(), '-') !== false) {
                                     $next -= 40;
                                 } else {
                                     $next += 40;
                                 }
                             }
                             if (!is_numeric($next) || $next < 0) {
                                 $_scenario->setLog(__('Erreur dans bloc (type A) : ', __FILE__) . $this->getId() . __(', heure programmée invalide : ', __FILE__) . $next);
                             }
                             if ($next < date('Gi') + 1) {
                                 if (strlen($next) == 3) {
//.........这里部分代码省略.........
开发者ID:GaelGRIFFON,项目名称:core,代码行数:101,代码来源:scenarioElement.class.php

示例5: execute

 public function execute($_options = null)
 {
     switch ($this->getType()) {
         case 'info':
             if ($this->getConfiguration('virtualAction', 0) == '0') {
                 try {
                     $result = jeedom::evaluateExpression($this->getConfiguration('calcul'));
                     if ($this->getSubType() == 'numeric') {
                         if (is_numeric($result)) {
                             $result = number_format($result, 2);
                         } else {
                             $result = str_replace('"', '', $result);
                         }
                         if (strpos($result, '.') !== false) {
                             $result = str_replace(',', '', $result);
                         } else {
                             $result = str_replace(',', '.', $result);
                         }
                     }
                     return $result;
                 } catch (Exception $e) {
                     log::add('virtual', 'info', $e->getMessage());
                     return jeedom::evaluateExpression(str_replace('"', '', cmd::cmdToValue($this->getConfiguration('calcul'))));
                 }
             }
             break;
         case 'action':
             $virtualCmd = virtualCmd::byId($this->getConfiguration('infoId'));
             if (!is_object($virtualCmd)) {
                 $cmds = explode('&&', $this->getConfiguration('infoName'));
                 if (is_array($cmds)) {
                     foreach ($cmds as $cmd_id) {
                         $cmd = cmd::byId(str_replace('#', '', $cmd_id));
                         $cmd->execCmd($_options);
                     }
                     return;
                 } else {
                     $cmd = cmd::byId(str_replace('#', '', $this->getConfiguration('infoName')));
                     return $cmd->execCmd($_options);
                 }
             } else {
                 if ($virtualCmd->getEqType() != 'virtual') {
                     throw new Exception(__('La cible de la commande virtuel n\'est pas un équipement de type virtuel', __FILE__));
                 }
                 if ($this->getSubType() == 'slider') {
                     $value = $_options['slider'];
                 } else {
                     if ($this->getSubType() == 'color') {
                         $value = $_options['color'];
                     } else {
                         $value = $this->getConfiguration('value');
                     }
                 }
                 $result = jeedom::evaluateExpression($value);
                 if ($this->getSubtype() == 'message') {
                     $result = $_options['title'] . ' ' . $_options['message'];
                 }
                 $virtualCmd->event($result);
             }
             break;
     }
 }
开发者ID:GaelGRIFFON,项目名称:plugin-virtual,代码行数:62,代码来源:virtual.class.php

示例6: execute

 public function execute($_options = null)
 {
     //file_put_contents("/tmp/arduidom2", time() . " :  arduidom_execute" . "\n", FILE_APPEND);
     //$results = print_r($_options, true);
     //log::add('arduidom', 'debug', 'execute(' . $results . ') called');
     //exec('echo "execute 2" >> /tmp/arduidom');
     if ($this->getType() == 'action') {
         try {
             //exec('echo "execute 3" >> /tmp/arduidom');
             //log::add('arduidom', 'debug', 'execute() called on type action');
             //exec('echo "execute 4" >> /tmp/arduidom');
             //log::add('arduidom','info','subTYPE=' . $this->getSubType());
             $subType = $this->getSubType();
             if ($subType == 'slider') {
                 $value = str_replace('#slider#', $_options['slider'], $this->getConfiguration('value'));
                 return arduidom::setPinValue($this->getLogicalId(), $value);
             }
             if ($subType == 'color') {
                 $value = str_replace('#color#', $_options['color'], $this->getConfiguration('value'));
                 return arduidom::setPinValue($this->getLogicalId(), $value);
             }
             if ($subType == 'other') {
                 //GROS LAG RETIRE ICI - VERIFIER QUE CA N'A PAS D'INCIDENCE SUR LES FORMULES EN VALEURS//
                 $value = $this->getConfiguration('value');
                 if ($value != 0 || $value != 1 || $value != "0" || $value != "1") {
                     $value = jeedom::evaluateExpression($value);
                 }
                 return arduidom::setPinValue($this->getLogicalId(), $value);
             }
         } catch (Exception $e) {
             //exec('echo "execute 5" >> /tmp/arduidom');
             //log::add('arduidom', 'debug', 'execute() ' . $e);
             return "bad";
         }
     }
     /*if ($this->getType() == 'info') {
           try{
               //exec('echo "execute 6" >> /tmp/arduidom');
               //log::add('arduidom', 'debug', 'execute() called on type info');
               return arduidom::getPinValue($this->getLogicalId());
           } catch (Exception $e) {
               //exec('echo "execute 7" >> /tmp/arduidom');
               //log::add('arduidom', 'debug', 'execute() ' . $e);
               return "bad";
           }
       }*/
     /*
     
     throw new Exception(__("Erreur: XXXXXXXXXXXXXXXXX", __FILE__));
     log::add('arduidom', 'debug', 'foreach.....................');
     foreach (eqLogic::byType('arduidom') as $eqLogic){
         log::add('arduidom', 'debug', 'by type arduidom');
         foreach ($eqLogic->getCmd('info') as $cmd) {
             log::add('arduidom', 'debug', 'getCmd info');
             if (array_key_exists($cmd->getConfiguration('value'), $_GET)) {
                 log::add('arduidom', 'debug', 'with value');
                 log::add('arduidom', 'debug', 'Mise à jour de : ' . $cmd->getConfiguration('value') . ':'. $_GET[$cmd->getConfiguration('value')]);
                 $cmd->setValue($_GET[$cmd->getConfiguration('value')]);
                 $cmd->event($_GET[$cmd->getConfiguration('value')]);
                 $cmd->save();
             }
         }
         log::add('arduidom', 'event', 'Mise à jour de ' . $eqLogic->getHumanName() . ' terminée');
     }
     */
     return "BAD";
 }
开发者ID:bobox59,项目名称:arduidom,代码行数:67,代码来源:arduidom.class.php


注:本文中的jeedom::evaluateExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。