本文整理汇总了PHP中jeedom::getUsbMapping方法的典型用法代码示例。如果您正苦于以下问题:PHP jeedom::getUsbMapping方法的具体用法?PHP jeedom::getUsbMapping怎么用?PHP jeedom::getUsbMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jeedom
的用法示例。
在下文中一共展示了jeedom::getUsbMapping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runDeamon
public static function runDeamon($_debug = false)
{
if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) {
return;
}
try {
self::stopDeamon();
} catch (Exception $e) {
}
log::add('openzwave', 'info', 'Lancement du démon openzwave');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port, true);
if (@(!file_exists($port))) {
throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__));
}
exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = realpath(dirname(__FILE__) . '/../../ressources/zwaveserver');
$config_path = realpath(dirname(__FILE__) . '/../../ressources/openzwave/config');
$log = $_debug ? 'Debug' : 'Info';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py --pidfile=/tmp/openzwave.pid --device=' . $port . ' --log=' . $log . ' --port=' . $port_server . ' --config=' . $config_path;
log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwave', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
if (self::deamonRunning()) {
break;
}
sleep(1);
$i++;
}
if ($i >= 30) {
log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwave', 'info', 'Démon openzwave lancé');
}
示例2: foreach
<label class="col-lg-4 control-label">{{Dépendance OpenZwave locale}}</label>
<div class="col-lg-3">
<a class="btn btn-warning bt_installDeps"><i class="fa fa-check"></i> {{Installer/Mettre à jour}}</a>
</div>
</div>';
} else {
echo '<div class="alert alert danger">{{Jeedom n\'a pas les droits sudo sur votre système, il faut lui ajouter pour qu\'il puisse installer le démon openzwave, voir <a target="_blank" href="https://jeedom.fr/doc/documentation/installation/fr_FR/doc-installation.html#autre">ici</a> partie 1.7.4}}</div>';
}
?>
<div class="form-group">
<label class="col-sm-4 control-label">{{Port clé Z-Wave}}</label>
<div class="col-sm-4">
<select class="configKey form-control" data-l1key="port">
<option value="none">{{Aucun}}</option>
<?php
foreach (jeedom::getUsbMapping('', true) as $name => $value) {
echo '<option value="' . $name . '">' . $name . ' (' . $value . ')</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{{Port du Serveur (laisser vide par défault)}}</label>
<div class="col-sm-2">
<input class="configKey form-control" data-l1key="port_server" placeholder="8083" />
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{{Mode "direct push" (recommandé)}}</label>
<div class="col-sm-2">
示例3: runDeamon
public static function runDeamon($_debug = false)
{
if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) {
return;
}
try {
self::stop();
self::stopDeamon();
} catch (Exception $e) {
}
log::add('openzwave', 'info', 'Lancement du démon openzwave');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port, true);
if (@(!file_exists($port))) {
throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__));
}
exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1');
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
$serverId = config::byKey('jeeNetwork::slave::id');
$callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('jeeNetwork::master::apikey');
} else {
$serverId = 0;
$callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('api');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
$config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
$data_path = dirname(__FILE__) . '/../../data';
if (!file_exists($data_path)) {
exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
}
$log = $_debug ? 'Debug' : 'Error';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
$cmd .= ' --pidfile=/tmp/openzwave.pid';
$cmd .= ' --device=' . $port;
$cmd .= ' --log=' . $log;
$cmd .= ' --port=' . $port_server;
$cmd .= ' --config_folder=' . $config_path;
$cmd .= ' --data_folder=' . $data_path;
$cmd .= ' --callback=' . $callback;
$cmd .= ' --apikey=' . $apikey;
$cmd .= ' --serverId=' . $serverId;
log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwave', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
if (self::deamonRunning()) {
break;
}
sleep(1);
$i++;
}
if ($i >= 10) {
log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwave', 'info', 'Démon openzwave lancé');
}
示例4: isset
if ($jsonrpc->getMethod() == 'message::removeAll') {
message::removeAll();
$jsonrpc->makeSuccess('ok');
}
if ($jsonrpc->getMethod() == 'message::all') {
$jsonrpc->makeSuccess(utils::o2a(message::all()));
}
/* * ************************Interact*************************** */
if ($jsonrpc->getMethod() == 'interact::tryToReply') {
$jsonrpc->makeSuccess(interactQuery::tryToReply($params['query']));
}
/* * ************************USB mapping*************************** */
if ($jsonrpc->getMethod() == 'jeedom::getUsbMapping') {
$name = isset($params['name']) ? $params['name'] : '';
$gpio = isset($params['gpio']) ? $params['gpio'] : false;
$jsonrpc->makeSuccess(jeedom::getUsbMapping($name, $gpio));
}
/* * ************************Plugin*************************** */
if ($jsonrpc->getMethod() == 'plugin::install') {
try {
$market = market::byId($params['plugin_id']);
} catch (Exception $e) {
$market = market::byLogicalId($params['plugin_id']);
}
if (!is_object($market)) {
throw new Exception(__('Impossible de trouver l\'objet associé : ', __FILE__) . $params['plugin_id']);
}
if (!isset($params['version'])) {
$params['version'] = 'stable';
}
$market->install($params['version']);
示例5: deamon_start
public static function deamon_start($_debug = false)
{
self::deamon_stop();
$deamon_info = self::deamon_info();
if ($deamon_info['launchable'] != 'ok') {
throw new Exception(__('Veuillez vérifier la configuration', __FILE__));
}
log::remove('openzwavecmd');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port);
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
$serverId = config::byKey('jeeNetwork::slave::id');
$callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('jeeNetwork::master::apikey');
} else {
$serverId = 0;
$callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('api');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
$config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
$data_path = dirname(__FILE__) . '/../../data';
if (!file_exists($data_path)) {
exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
}
$log = $_debug ? 'Debug' : 'Error';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
$cmd .= ' --pidfile=/tmp/openzwave.pid';
$cmd .= ' --device=' . $port;
$cmd .= ' --log=' . $log;
$cmd .= ' --port=' . $port_server;
$cmd .= ' --config_folder=' . $config_path;
$cmd .= ' --data_folder=' . $data_path;
$cmd .= ' --callback=' . $callback;
$cmd .= ' --apikey=' . $apikey;
$cmd .= ' --serverId=' . $serverId;
log::add('openzwavecmd', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwavecmd') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwavecmd', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
$deamon_info = self::deamon_info();
if ($deamon_info['state'] == 'ok') {
break;
}
sleep(1);
$i++;
}
if ($i >= 30) {
log::add('openzwavecmd', 'error', 'Impossible de lancer le démon openzwave, relancer le démon en debug et vérifiez la log', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwavecmd', 'info', 'Démon openzwave lancé');
}
示例6: runDeamon
public static function runDeamon()
{
log::add('mySensors', 'info', 'Lancement du démon mySensors');
$modem_serie_addr = config::byKey('usbGateway', 'mySensors');
if ($modem_serie_addr == "serie") {
$usbGateway = config::byKey('modem_serie_addr', 'mySensors');
} else {
$usbGateway = jeedom::getUsbMapping(config::byKey('usbGateway', 'mySensors'));
}
if ($modem_serie_addr == "network") {
$gateMode = "Network";
$netAd = explode(":", config::byKey('gateway_addr', 'mySensors'));
$usbGateway = $netAd[0];
$gatePort = $netAd[1];
} else {
$gateMode = "Serial";
$gatePort = "";
}
if ($usbGateway == '') {
throw new Exception(__('Le port : ', __FILE__) . $port . __(' n\'éxiste pas', __FILE__));
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
//Je suis l'esclave
$url = 'http://' . config::byKey('jeeNetwork::master::ip') . '/core/api/jeeApi.php?api=' . config::byKey('jeeNetwork::master::apikey');
} else {
if (stripos(config::byKey('internalAddr'), 'jeedom') !== FALSE) {
//on est pas sur une Mini
$jeeurl = "http://127.0.0.1/jeedom";
} else {
$jeeurl = "http://127.0.0.1";
}
$url = $jeeurl . '/core/api/jeeApi.php?api=' . config::byKey('api');
}
$sensor_path = realpath(dirname(__FILE__) . '/../../node');
$cmd = 'nice -n 19 node ' . $sensor_path . '/mysensors.js ' . $url . ' ' . $usbGateway . ' ' . $gateMode . ' ' . $gatePort;
log::add('mySensors', 'info', 'Lancement démon mySensors : ' . $cmd);
$result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('mySensors') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('mySensors', 'error', $result);
return false;
}
sleep(2);
if (!self::deamonRunning()) {
sleep(10);
if (!self::deamonRunning()) {
log::add('mySensors', 'error', 'Impossible de lancer le démon mySensors, vérifiez le port', 'unableStartDeamon');
return false;
}
}
message::removeAll('mySensors', 'unableStartDeamon');
log::add('mySensors', 'info', 'Démon mySensors lancé');
}