function install() { $sql = file_get_contents(dirname(__FILE__) . '/install.sql'); DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW); $energy = new energy(); $energy->setEqLogic_id(-1); $energy->save(); }
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception('401 Unauthorized'); } if (init('action') == 'get') { $return = array(); $eqLogic = eqLogic::byId(init('id')); if (!is_object($eqLogic)) { throw new Exception('Equipement non trouvé vérifiez l\'id : ' . init('id')); } $return['eqLogic'] = utils::o2a($eqLogic); $energy = energy::byEqLogic_id($eqLogic->getId()); $return['energy'] = is_object($energy) ? jeedom::toHumanReadable(utils::o2a($energy)) : array('eqLogic_id' => $eqLogic->getId(), 'id' => ''); ajax::success($return); } if (init('action') == 'save') { $energy_json = json_decode(init('energy'), true); $energy = energy::byId($energy_json['id']); if (!is_object($energy)) { $energy = new energy(); } utils::a2o($energy, jeedom::fromHumanReadable($energy_json)); $energy->save(); ajax::success(); } throw new Exception('Aucune methode correspondante'); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
if (!isConnect()) { throw new Exception('401 - Unauthorized access to page'); } if (init('object_id') == '') { $_GET['object_id'] = $_SESSION['user']->getOptions('defaultDashboardObject', 'global'); } $object = object::byId(init('object_id')); if (!is_object($object)) { $object = object::rootObject(); } if (!is_object($object)) { throw new Exception('Aucun objet racine trouvé'); } $energy = energy::getObjectData($object->getId()); sendVarToJs('datas', energy::sanitizeForChart($energy)); ?> <div class="row"> <div class="col-lg-2"> <div class="bs-sidebar affix"> <ul id="ul_object" class="nav nav-list bs-sidenav"> <li class="nav-header">Liste objects </li> <li class="filter" style="margin-bottom: 5px;"><input class="form-control" class="filter form-control" placeholder="Rechercher" style="width: 100%"/></li> <?php if (init('object_id') == 'global') { echo '<li class="cursor li_object active"><a href="index.php?v=d&m=energy&p=panel&object_id=global">Global</a></li>'; } else { echo '<li class="cursor li_object"><a href="index.php?v=d&m=energy&p=panel&object_id=global">Global</a></li>'; } $allObject = object::buildTree();
$this->v0 = sqrt(5 * $this->g * $this->r); } function __destruct() { echo "2:结果是:" . $this->v0 . "<br>"; } } $resultB = new Balance(); $resultB->HandleB(10, 1); /** 一倾斜角为30°的斜面,动摩擦因数u = 0.5; h = 5m;g = 10N/kg;求物体下落到底的速度 */ class energy { private $g; private $h; private $u = 0.5; private $v; function HandleC($h, $g) { $this->g = $g; $this->h = $h; $this->v = sqrt(2 * $this->g * $this->h - $this->u * $this->g * $this->h * 3 / 2); } function __destruct() { echo "3:结果是:" . $this->v . "<br>"; } } $resultC = new energy(5, 10); $resultC->HandleC(5, 10);