本文整理汇总了PHP中event::add方法的典型用法代码示例。如果您正苦于以下问题:PHP event::add方法的具体用法?PHP event::add怎么用?PHP event::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类event
的用法示例。
在下文中一共展示了event::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($_options = array())
{
$array = utils::o2a($this);
if (isset($_options['utid'])) {
$array['utid'] = $_options['utid'];
}
if ($this->getLogicalId() == 'close') {
event::add('clink::close', $array);
} else {
event::add('clink::open', $array);
}
}
示例2: add
/**
* Add a timer.
* @param int $time_interval
* @param callback $func
* @param mix $args
* @return void
*/
public static function add($time_interval, $func, $args = array(), $persistent = true)
{
if ($time_interval <= 0) {
echo new Exception("bad time_interval");
return false;
}
if (self::$_event) {
return self::$_event->add($time_interval, $persistent ? EventInterface::EV_TIMER : EventInterface::EV_TIMER_ONCE, $func, $args);
}
if (!is_callable($func)) {
echo new Exception("not callable");
return false;
}
if (empty(self::$_tasks)) {
pcntl_alarm(1);
}
$time_now = time();
$run_time = $time_now + $time_interval;
if (!isset(self::$_tasks[$run_time])) {
self::$_tasks[$run_time] = array();
}
self::$_tasks[$run_time][] = array($func, (array) $args, $persistent, $time_interval);
return true;
}
示例3: array
case 5:
# STATE_AWAKED = 7
event::add('jeedom::alert', array('level' => 'danger', 'page' => 'openzwave', 'message' => __('Le réseaux Z-Wave est actif sur le serveur ', __FILE__) . $server['name']));
break;
}
if ($controlerState === 0) {
echo '<div id="div_inclusionAlert' . $id . '"></div>';
}
if ($controlerState === 1) {
echo '<div class="alert jqAlert alert-warning" id="div_inclusionAlert' . $id . '" style="margin : 0px 5px 15px 15px; padding : 7px 35px 7px 15px;">{{Vous êtes en mode inclusion sur ' . $server['name'] . '. Cliquez à nouveau sur le bouton d\'inclusion pour sortir de ce mode}}</div>';
}
if ($controlerState === 5) {
echo '<div class="alert jqAlert alert-warning" id="div_inclusionAlert' . $id . '" style="margin : 0px 5px 15px 15px; padding : 7px 35px 7px 15px;">{{Vous êtes en mode exclusion sur ' . $server['name'] . '. Cliquez à nouveau sur le bouton d\'exclusion pour sortir de ce mode}}</div>';
}
if ($controlerState === null) {
event::add('jeedom::alert', array('level' => 'danger', 'page' => 'openzwave', 'message' => __('Impossible de contacter le serveur Z-wave ', __FILE__) . $server['name']));
}
}
}
$eqLogics = eqLogic::byType('openzwave');
$tags = array();
if (is_array($eqLogics)) {
foreach ($eqLogics as $eqLogic) {
$tags[$eqLogic->getConfiguration('serverID', 0) . ':' . $eqLogic->getLogicalId()] = $eqLogic->getHumanName(true);
}
}
sendVarTojs('eqLogic_human_name', $tags);
?>
<div class="row row-overflow">
<div class="col-lg-2 col-md-3 col-sm-4">
示例4: array
$jeeNetwork = jeeNetwork::byId($results['serverId']);
if (is_object($jeeNetwork) || $results['serverId'] == 0) {
event::add('zwave::controller.data.controllerState', array('name' => $results['serverId'] == 0 ? 'local' : $jeeNetwork->getName(), 'state' => $results['controller']['state']['value'], 'serverId' => $results['serverId']));
}
}
if (isset($results['controller']['excluded'])) {
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Un périphérique Z-Wave est en cours d\'exclusion. Logical ID : ', __FILE__) . $results['controller']['excluded']['value']));
sleep(2);
openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['excluded']['value']);
}
if (isset($results['controller']['included'])) {
for ($i = 0; $i < 10; $i++) {
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Nouveau module Z-Wave détecté. Début de l\'intégration.Pause de ', __FILE__) . (10 - $i) . __(' pour synchronisation avec le module', __FILE__)));
sleep(1);
}
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Inclusion en cours...', __FILE__)));
openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['included']['value']);
}
}
if (isset($results['message'])) {
log::add('openzwave', 'error', $results['message']);
}
if (isset($results['alert'])) {
switch ($results['alert']['type']) {
case 'node_dead':
$eqLogic = openzwave::getEqLogicByLogicalIdAndServerId($results['alert']['id'], $results['alert']['serverId']);
if (is_object($eqLogic)) {
$message = __('Le noeud', __FILE__) . ' ' . $eqLogic->getHumanName() . ' (' . $results['alert']['id'] . ') ' . __('est présumé mort', __FILE__);
} else {
$message = __('Le noeud', __FILE__) . ' ' . $results['alert']['id'] . ' ' . __('est présumé mort', __FILE__);
}
示例5: array
break;
case 3:
# STATE_RESET = 3
event::add('jeedom::alert', array('level' => 'danger', 'page' => 'openzwave', 'message' => __('Le réseaux Z-Wave est remis à zéro sur le serveur ', __FILE__) . openzwave::getNetworkNameByServerId($results['serverId'])));
break;
case 5:
# STATE_STARTED = 5
event::add('jeedom::alert', array('level' => 'warning', 'page' => 'openzwave', 'message' => __('Le réseaux Z-Wave est en cours de démarrage sur le serveur ', __FILE__) . openzwave::getNetworkNameByServerId($results['serverId'])));
break;
case 7:
# STATE_AWAKED = 7
event::add('jeedom::alert', array('level' => 'warning', 'page' => 'openzwave', 'message' => ''));
break;
case 10:
# STATE_READY = 10
event::add('jeedom::alert', array('level' => 'warning', 'page' => 'openzwave', 'message' => ''));
break;
}
}
}
if (isset($results['message'])) {
log::add('openzwave', 'error', $results['message']);
}
if (isset($results['alert'])) {
switch ($results['alert']['type']) {
case 'node_dead':
$eqLogic = openzwave::getEqLogicByLogicalIdAndServerId($results['alert']['id'], $results['alert']['serverId']);
if (is_object($eqLogic)) {
$message = __('Le noeud', __FILE__) . ' ' . $eqLogic->getHumanName() . ' (' . $results['alert']['id'] . ') ' . __('est présumé mort', __FILE__);
} else {
$message = __('Le noeud', __FILE__) . ' ' . $results['alert']['id'] . ' ' . __('est présumé mort', __FILE__);
示例6: createCommand
public function createCommand($_update = false, $_data = null)
{
$return = array();
if (!is_numeric($this->getLogicalId())) {
return;
}
if (is_file(dirname(__FILE__) . '/../config/devices/' . $this->getConfFilePath())) {
$this->loadCmdFromConf($_update);
return;
}
if (class_exists('event')) {
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Création des commandes en mode automatique', __FILE__)));
} else {
nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Création des commandes en mode automatique', __FILE__)));
}
if ($_data == null) {
$results = self::callOpenzwave('/ZWaveAPI/Run/devices[' . $this->getLogicalId() . ']', $this->getConfiguration('serverID', 1));
} else {
$results = $_data;
}
if (isset($results['instances']) && is_array($results['instances'])) {
foreach ($results['instances'] as $instanceID => $instance) {
if (isset($instance['commandClasses']) && is_array($instance['commandClasses'])) {
foreach ($instance['commandClasses'] as $ccId => $commandClasses) {
if (isset($commandClasses['data']) && is_array($commandClasses['data'])) {
foreach ($commandClasses['data'] as $index => $data) {
if (isset($data['genre']) && $data['genre'] != 'Config' && $data['genre'] != 'System') {
$cmd_info = null;
$cmd = null;
if (count($results['instances']) > 2) {
$cmd_name_number = $instanceID + 1;
$cmd_name = $data['name'] . ' ' . $index . ' ' . $cmd_name_number;
} else {
$cmd_name = $data['name'] . ' ' . $index;
}
if (strpos($cmd_name, 'Unknown') !== false || strpos($cmd_name, 'Unused') !== false) {
continue;
}
if (!$data['write_only']) {
$cmd_info = new openzwaveCmd();
$cmd_info->setType('info');
$cmd_info->setEqLogic_id($this->getId());
$cmd_info->setUnite($data['units']);
if ($data['read_only']) {
$cmd_info->setName($cmd_name);
} else {
$cmd_info->setName('Info ' . $cmd_name);
}
$cmd_info->setConfiguration('instanceId', $instanceID);
$cmd_info->setConfiguration('class', $ccId);
$cmd_info->setConfiguration('value', 'data[' . $index . '].val');
switch ($data['type']) {
case 'bool':
$cmd_info->setSubType('binary');
break;
case 'int':
$cmd_info->setSubType('numeric');
$cmd_info->setIsHistorized(1);
break;
case 'float':
$cmd_info->setSubType('numeric');
$cmd_info->setIsHistorized(1);
break;
default:
$cmd_info->setSubType('string');
break;
}
$cmd_info->save();
}
if (!$data['read_only']) {
switch ($data['type']) {
case 'bool':
$cmd = new openzwaveCmd();
$cmd->setSubType('other');
$cmd->setType('action');
$cmd->setEqLogic_id($this->getId());
$cmd->setConfiguration('instanceId', $instanceID);
$cmd->setConfiguration('class', $ccId);
if ($data['typeZW'] == 'Button') {
$cmd->setName($cmd_name);
$cmd->setConfiguration('value', 'data[' . $index . '].PressButton()');
} else {
$cmd->setName($cmd_name . ' On');
$cmd->setConfiguration('value', 'data[' . $index . '].Set(255)');
}
if (is_object($cmd_info)) {
$cmd->setValue($cmd_info->getId());
$cmd->setTemplate('dashboard', 'light');
$cmd->setTemplate('mobile', 'light');
$cmd_info->setIsVisible(0);
$cmd_info->save();
}
$cmd->save();
$cmd = new openzwaveCmd();
$cmd->setSubType('other');
$cmd->setType('action');
$cmd->setEqLogic_id($this->getId());
$cmd->setConfiguration('instanceId', $instanceID);
$cmd->setConfiguration('class', $ccId);
if ($data['typeZW'] == 'Button') {
//.........这里部分代码省略.........
示例7: Exception
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
*/
if (!isConnect('admin')) {
throw new Exception('401 Unauthorized');
}
//if (config::byKey('enableLogging', 'arduidom', 0) == 0) {
// echo '<div class="alert alert-danger">{{Vous n\'avez pas activé l\'enregistrement de tous les messages : allez dans Générale -> Plugin puis rfxcom et coché la case correspondante}}</div>';
//}
if (arduidom::get_daemon_mode() != "OK") {
if (substr(jeedom::version(), 0, 1) == 2) {
event::add('jeedom::alert', array('level' => 'error', 'message' => __("Action Impossible : Le démon ne fonctionne pas !", __FILE__)));
}
}
?>
<pre id='pre_ardulog' style='overflow: auto; height: 95%;width:90%;'></pre>
<script>
getArduLog(1);
function getArduLog(_autoUpdate) {
$.ajax({
type: 'POST',
url: 'core/ajax/log.ajax.php',
示例8: sendtoArduino
public static function sendtoArduino($_tcpmsg, $_AID)
{
$General_Debug = config::byKey('generalDebug', 'arduidom', 0, true);
if ($_AID == 0) {
$General_Debug = 0;
}
// Pas de log sur démon direct, trop bavard...
if ($General_Debug) {
log::add('arduidom', 'debug', "^--------------------------------------------------------------------------------------");
}
if ($General_Debug) {
log::add('arduidom', 'debug', 'sendtoArduino(' . $_tcpmsg . ',' . $_AID . ') called');
}
$func_start_time = getmicrotime(true);
$daemonmode = self::get_daemon_mode();
if ($daemonmode == "FLASHING") {
log::add("arduidom", "debug", "sendtoArduino impossible, arduino en cours de flashage...");
return "DAEMON_NOT_OK";
}
$port = config::byKey('A' . $_AID . '_port', 'arduidom', 'none', true);
$ip = config::byKey('A' . $_AID . '_daemonip', 'arduidom', '127.0.0.1', true);
if ($port != 'none' && $port != "" || $_AID == 0) {
if (file_exists($port) || $port == 'Network' || $_AID == 0) {
if ($port != 'Network') {
//if ($General_Debug) log::add('arduidom', 'debug', 'Le démon ' . $_AID . ' est un démon python');
if ($General_Debug) {
log::add('arduidom', 'debug', 'IP: ' . $ip . ":" . (58200 + intval($_AID)));
}
$fp = fsockopen($ip, 58200 + intval($_AID), $errno, $errstr, 10);
} else {
//if ($General_Debug) log::add('arduidom', 'debug', 'Le démon ' . $_AID . ' est un arduino Réseau (IP:' . $ip . ")");
if ($General_Debug) {
log::add('arduidom', 'debug', 'IP: ' . $ip . ":58174");
}
$fp = fsockopen($ip, 58174, $errno, $errstr, 1);
}
if (!$fp) {
if ($_AID == 0) {
log::add('arduidom', 'error', "Le démon " . $_AID . " n'est pas connecté ! (errstr:" . $errstr . ")");
if ($General_Debug) {
log::add('arduidom', 'debug', "v--------------------------------------------------------------------------------------");
}
} else {
log::add('arduidom', 'error', "L'Arduino " . $_AID . " n'est pas connecté ! (errstr:" . $errstr . ")");
if ($General_Debug) {
log::add('arduidom', 'debug', "v--------------------------------------------------------------------------------------");
}
}
return $errstr;
} else {
stream_set_timeout($fp, 10);
if ($_AID == 0) {
if ($General_Debug) {
log::add('arduidom', 'debug', "Le démon " . $_AID . " est connecté, envoi...");
}
} else {
if ($General_Debug) {
log::add('arduidom', 'debug', "L'Arduino " . $_AID . " est connecté, envoi...");
}
}
if ($port == "Network") {
$_tcpmsg = $_tcpmsg . "\n";
}
// ajout d'une fin de ligne pour shield ethernet
fwrite($fp, $_tcpmsg);
$start_time = time();
$resp = "";
if ($port == "Network") {
if ($General_Debug) {
log::add('arduidom', 'debug', "Attente de la réponse de l'arduino " . $_AID . " ...");
}
while (!feof($fp)) {
$resp = $resp . fgets($fp);
if (time() - $start_time > 10) {
// Time out de 10 secondes pour le check du démon
log::add('arduidom', 'error', "Erreur: TIMEOUT sur attente de réponse de l'arduino " . $_AID);
if (substr(jeedom::version(), 0, 1) == 2) {
event::add('jeedom::alert', array('level' => 'error', 'message' => __("Erreur: TIMEOUT sur attente de réponse de l'arduino " . $_AID, __FILE__)));
}
if ($General_Debug) {
log::add('arduidom', 'debug', "v--------------------------------------------------------------------------------------");
}
return "TIMEOUT";
}
}
$resp = str_replace("\r", '', $resp);
$resp = str_replace("\n", '', $resp);
if ($General_Debug) {
log::add('arduidom', 'debug', 'Réponse TCP recue = ' . $resp);
}
if (time() - $start_time > 10) {
// Time out de 10 secondes pour le check du démon
log::add('arduidom', 'error', "Erreur: TIMEOUT sur Réponse de l'arduino " . $_AID);
if (substr(jeedom::version(), 0, 1) == 2) {
event::add('jeedom::alert', array('level' => 'error', 'message' => __("Erreur: TIMEOUT sur Réponse de l'arduino " . $_AID, __FILE__)));
}
if ($General_Debug) {
log::add('arduidom', 'debug', "v--------------------------------------------------------------------------------------");
}
return "TIMEOUT";
//.........这里部分代码省略.........