require_once '../../libs/utilfunc.php'; require_once '../../libs/utilfunc_sd_card.php'; require_once '../../libs/debug.php'; } $action = ""; if (isset($_GET['action']) && !empty($_GET['action'])) { $action = $_GET['action']; } if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } $ret_array = array(); switch ($action) { case "getSensors": bulcky\check_db(); $ret_array = configuration\getConfElem("NB_PLUGS"); break; case "getPlugs": echo "i égal 1"; break; case "deleteElement": $id = ""; if (isset($_POST['id']) && !empty($_POST['id'])) { $id = $_POST['id']; } bulcky\deleteElementInSynoptic($id); break; case "addElementOther": $image = ""; if (isset($_POST['image']) && !empty($_POST['image'])) { $image = $_POST['image'];
function getPlugOfSynoptic() { $ret_array = array(); // Read nb plug in database $plugNB = \configuration\getConfElem("NB_PLUGS"); // Read plug parameters $plugParam = \plugs\getDB(); // foreach sensor, get type and position for ($i = 1; $i <= $plugNB["NB_PLUGS"] && $i <= 100; $i++) { // Read parameters in db and add it to return array $sensorParameters = getSynopticDBElemByname("plug", $i); // If empty create them if (empty($sensorParameters)) { switch ($plugParam[$i - 1]["PLUG_TYPE"]) { case "lamp": $image = "lampe_OFF.png"; break; case "extractor": case "intractor": case "ventilator": $image = "lampe_OFF.png"; break; case "pump": case "pumpfilling": case "pumpempting": $image = "pompe_OFF.png"; break; case "co2": $image = "CO2_OFF.png"; break; default: if ($plugParam[$i - 1]["PLUG_POWER_MAX"] == "1000") { $image = "1000W_OFF.png"; } else { $image = "3500W_OFF.png"; } break; } addElementInSynoptic("plug", $i, $image); $sensorParameters = getSynopticDBElemByname("plug", $i); $sensorParameters["PLUG_NAME"] = $plugParam[$i - 1]["PLUG_NAME"]; $ret_array[] = $sensorParameters; } else { $sensorParameters["PLUG_NAME"] = $plugParam[$i - 1]["PLUG_NAME"]; $ret_array[] = $sensorParameters; } } return $ret_array; }