$endDateEp) {
echo "" .
"End date must be after begin date.
";
} elseif ($beginDateEp < $firstDP || $endDateEp > $lastDP) {
echo "" .
"Date range must be between " .
date('m / d / Y', $firstDP) . " and " .
date('m / d / Y', $lastDP) . ".
";
} else {
createChart('custom_signal', 'S', 'dBm',
'RSSI', $beginDateEp, $endDateEp,
0, 0, 2, false);
createChart('custom_snr', 'SNR', 'dBm',
'S/N', $beginDateEp, $endDateEp,
0, 0, 2, false);
if ($_DEBUG) {
echo "Date range: " . $beginDateEp . " thru " .
$endDateEp . "
";
}
echo "" .
"
" .
"
";
echo "" .
"
" .
"
";
}
function createChart($chartFile, $dataItem, $label, $title, $begin,
$end, $lower, $upper, $addTrend, $autoScale) {
/*
Uses rrdtool to create a chart of specified aredn node data item.
Parameters:
fileName - name of the created chart file
dataItem - data item to be charted
label - string containing a label for the item to be charted
title - string containing a title for the chart
begin - beginning time of the chart data
end - ending time of the data to be charted
lower - lower bound for chart ordinate #NOT USED
upper - upper bound for chart ordinate #NOT USED
addTrend - 0, show only chart data
1, show only a trend line
2, show a trend line and the chart data
autoScale - if True, then use vertical axis auto scaling
(lower and upper parameters are ignored), otherwise use
lower and upper parameters to set vertical axis scale
Returns: True if successful, False otherwise
*/
global $_DEBUG, $_GRAPH_DIRECTORY, $_GRAPH_WIDTH,
$_GRAPH_HEIGHT, $_RRD_FILE;
$chartPath = $_GRAPH_DIRECTORY . $chartFile . ".png";
# Format the rrdtool chart command.
# Set chart start time, height, and width.
$cmdfmt = "rrdtool graph %s -a PNG -s %s -e %s -w %s -h %s ";
$cmd = sprintf($cmdfmt, $chartPath, $begin, $end, $_GRAPH_WIDTH,
$_GRAPH_HEIGHT);
$cmdfmt = "-l %s -u %s -r ";
if ($lower < $upper) {
$cmd .= sprintf($cmdfmt, $lower, $upper);
} elseif ($autoScale) {
$cmd .= "-A ";
}
$cmd .= "-Y ";
# Set the chart ordinate label and chart title.
$cmdfmt = "-v %s -t %s ";
$cmd .= sprintf($cmdfmt, $label, $title);
# Show the data, or a moving average trend line over
# the data, or both.
$trendWindow = floor(($end - $begin) / 12);
$cmdfmt = "DEF:dSeries=%s:%s:LAST ";
$cmd .= sprintf($cmdfmt, $_RRD_FILE, $dataItem);
if ($addTrend == 0) {
$cmd .= "LINE1:dSeries#0400ff ";
} elseif ($addTrend == 1) {
$cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE3:smoothed#ff0000 ";
$cmd .= sprintf($cmdfmt, $trendWindow);
} elseif ($addTrend == 2) {
$cmd .= "LINE1:dSeries#0400ff ";
$cmdfmt = "CDEF:smoothed=dSeries,%s,TREND LINE3:smoothed#ff0000 ";
$cmd .= sprintf($cmdfmt, $trendWindow);
}
if ($_DEBUG) {
echo "chart command:
" . $cmd . "
";
}
$result = shell_exec($cmd . "2>&1");
if ($_DEBUG == true) {
echo "result:
" . $result . "
";
}
}
?>