Beispiel #1
0
$conf_arr["COLOR_PROGRAM_GRAPH"] = array("update_conf" => "0", "var" => "color_program");
foreach ($conf_arr as $key => $value) {
    ${$value['var']} = get_configuration($key, $main_error);
}
// Build array for y axis
$yaxis_array = array();
$yaxis_array[0] = programs\get_curve_information('temperature');
$yaxis_array[1] = programs\get_curve_information('humidity');
$yaxis_array[2] = programs\get_curve_information('water');
$yaxis_array[3] = programs\get_curve_information('level');
$yaxis_array[4] = programs\get_curve_information('ph');
$yaxis_array[5] = programs\get_curve_information('ec');
$yaxis_array[6] = programs\get_curve_information('od');
$yaxis_array[7] = programs\get_curve_information('orp');
$yaxis_array[8] = programs\get_curve_information('power');
$yaxis_array[9] = programs\get_curve_information('program');
// Used to alert user if export is could be done
$check_log = logs\check_export_table_csv("logs", $main_error);
$check_power = logs\check_export_table_csv("power", $main_error);
$sd_card = $GLOBALS['CULTIPI_CONF_TEMP_PATH'];
//More default values:
if (!isset($startday) || empty($startday) || $reload_import) {
    $startday = programs\get_last_day_with_logs();
}
$startday = str_replace(' ', '', "{$startday}");
if ($startday == "") {
    $startday = date('Y') . "-" . date('m') . "-" . date('d');
    $fake_log = true;
} else {
    if (!check_format_date($startday, "days")) {
        $startday = date('Y') . "-" . date('m') . "-" . date('d');
Beispiel #2
0
        $retarray['plug_1']['yaxis'] = $retInfo['yaxis'];
        $retarray['plug_1']['curveType'] = $retInfo['curveType'];
        $retarray['plug_1']['unit'] = $retInfo['unit'];
        $retarray['plug_1']['fake_log'] = "0";
        break;
    case "logs":
        if ($_GET['month'] == "day") {
            $endDay = strtotime("+1 day", strtotime($_GET['startDate']));
        }
        // Gets type of each sensor logged
        $db_sensors = logs\get_sensor_db_type($_GET['sensor'], $GLOBALS['SENSOR_DEFINITION']);
        // Retrieve logs curve
        $logsValue = logs\get_sensor_log($_GET['sensor'], $startDay, $endDay, $_GET['month'], $db_sensors[0]['ratio'], $db_sensors[0]['display']);
        // Search if there are fake
        $fake = logs\are_fake_logs($_GET['sensor'], $startDay, $endDay, $_GET['month']);
        // Read information about this sensor
        // Todo : Super moche
        $retInfo = programs\get_curve_information($db_sensors[0]['type'] . "1", $_GET['sensor'] - 1);
        $retarray['sensor_1']['data'] = $logsValue[0];
        // Init return array
        $retarray['sensor_1']['name'] = $retInfo['name'] . " (" . __('SENSOR') . " " . $_GET['sensor'] . " )";
        $retarray['sensor_1']['color'] = $retInfo['color'];
        $retarray['sensor_1']['legend'] = $retInfo['legend'];
        $retarray['sensor_1']['yaxis'] = $retInfo['yaxis'];
        $retarray['sensor_1']['curveType'] = $retInfo['curveType'];
        $retarray['sensor_1']['unit'] = $retInfo['unit'];
        $retarray['sensor_1']['fake_log'] = $fake;
        break;
}
// Encode in JSON format and return array
echo json_encode($retarray);