DIR : /home/kozerus/public_html/ko_center/function_ko_plans.php
/home/kozerus/public_html/ko_center
function sqlq( $dbfile, $sql, $fld ) {
/// printf( "MSG_2380: sqlq: dbfile=[$dbfile] sql=[$sql] fld=[$fld]<br>\n" );
$pdo = newpdo( $dbfile );
// $sql = "select * from $tblname where rpt_code='$rpt_code'";
$output = "";
$pdo = newpdo($dbfile);
foreach( $pdo->query($sql) as $row ) {
/// printf( "BUGS_2390: val=[$val] fld=[$fld] row=[$row]<br>\n" );
$val=$row[$fld];
$output .= "$val ";
}
$pdo=null;
return($output);
}
function ko_plans($options) {
$dbfile="ko_plans.db3";
$planid="plan1";
$cabtop_pngfil="./images/cab/cabtop.png";
$cabbottom_pngfil="./images/cab/cabbottom.png";
$cabtop_pngfil="./images/cab/tn/tn_cabtop.png";
$cabbottom_pngfil="./images/cab/tn/tn_cabbottom.png";
$output = "<h2>ko_plans_2380: dbfile=[$dbfile] planid=[$planid] cab=[$cab]</h2>\n";
$output .= "<hr>\n";
$items_flag="true";
$step=0;
$steplim=5;
$sql_maxamp = "select val maxamp from cfg where fld=='maxamp'";
$maxamp = sqlq( $dbfile, $sql_maxamp, "maxamp" );
// printf( "MSG_2011: maxamp=[$maxamp] sql_maxamp=[$sql_maxamp] dbfile=[$dbfile]<br>\n" );
$sql_minamp = "select val minamp from cfg where fld=='minamp'";
$minamp = sqlq( $dbfile, $sql_minamp, "minamp" );
// printf( "MSG_2012: maxamp=[$maxamp] sql_minamp=[$sql_minamp] dbfile=[$dbfile]<br>\n" );
$sql_cab1="select distinct(cab1) cab1, group_concat( item, ' ' ) items, sum(amps) samps from ko_plans where planid == 'plan1' group by cab1";
$output = "";
$cab1_output .= "<hr><h1>cab1</h1><hr>\n";
$pdo = newpdo( $dbfile );
$j=0; $cab1_tot_samps=0; $cab1_pnglist="";
foreach( $pdo->query( $sql_cab1) as $row ) {
$j++;
foreach( $row as $key=>$val ) {
if( is_numeric( $key )) { continue; }
if( $key == 'cab1' ) { $cab1=$val; }
if( $key == 'items' ) { $cab1_items=$val; }
if( $key == 'samps' ) { $samps=$val; }
}
// printf( "$j cab1=[$cab1] cab1_items=[$cab1_items] cab1_samps=[$cab1_samps] cab1_pngfil=[$cab1_pngfil]<br>\n" );
$im_cmd = "convert $cabtop_pngfil ";
$items=explode( " ", $cab1_items );
foreach( $items as $item ) {
$item_pngfil="./images/cab/$item.png";
$item_pngfil="./images/cab/tn/tn_$item.png";
$im_cmd .= " $item_pngfil";
//// if( file_exists( $item_pngfil )) {
//// printf( "MSG_2421: FOUND cab1 item=[$item] item_pngfil=[$item_pngfil]<br>\n" );
//// }
//// else {
//// printf( "MSG_2421: NOTFOUND cab1 item=[$item] item_pngfil=[$item_pngfil]<br>\n" );
//// }
}
$cab1_pngfil=sprintf( "./ko_plans/images/%s_cab1_%s_%03d_%03d.png", $planid, $cab1, $step, $samps );
$cab1_pngfiles .= " $cab1_pngfil";
$cab1_tot_samps += $samps;
// printf( "bugs_2425: cab1_tot_samps=[$cab1_tot_samps] samps=[$samps]<br>\n" );
$im_cmd .= " $cabbottom_pngfil -append $cab1_pngfil ";
$im_cmd_status="";
$status=exec($im_cmd,$im_cmd_status);
if( $items_flag == "true" ) {
$cab1_output .= "<img src=$cab1_pngfil> $cab1_pngfil $samps<br>\n";
// printf( "MSG_2481: status=[$status] im_cmd=[$im_cmd] cab2_tot_samps=[$cab2_tot_samps]<hr>\n" );
}
}
$pdo=null;
$cab1beg_pngfile=sprintf( "./ko_plans/images/%s_cab1beg_%03d_%04d.png", $planid, $setp, $cab1_tot_samps );
// floats to top
// $im_cmd = "convert $cab1_pngfiles +append -gravity north $cab1beg_pngfile";
$im_cmd = "convert $cab1_pngfiles +append -gravity north $cab1beg_pngfile";
//// printf( "MSG_2432: cab1_tot_samps=[$cab1_tot_samps] im_cmd=[$im_cmd] cab1beg_pngfil=[$cab1beg_pngfil]<hr>\n" );
$status=exec($im_cmd,$im_cmd_status);
$cab1_output .= "MSG_2441: <img src=$cab1beg_pngfile border=0 alt=$cab1beg_pngfile><hr>cab1beg_pngfile=[$cab1beg_pngfile] cab1_tot_samps=[$cab1_tot_samps]<br>\n";
$cab1_output .= "<hr><h2>cab1</h2><hr>\n";
// $sql_cab="select distinct(cab) cab, group_concat( item, ' ' ) items, sum(amps) samps from ko_plans where planid == 'plan1' group by cab";
$sql_cab2="select distinct(cab2) cab2, group_concat( item, ' ' ) items, sum(amps) samps from ko_plans where planid == 'plan1' group by cab2";
$cab2_output = "<hr><h1>cab2</h1><hr>\n";
$pdo = newpdo( $dbfile );
$j=0; $cab2_tot_samps=0; $cab2_pnglist="";
foreach( $pdo->query( $sql_cab2) as $row ) {
$j++;
foreach( $row as $key=>$val ) {
if( is_numeric( $key )) { continue; }
if( $key == 'cab2' ) { $cab2=$val; }
if( $key == 'items' ) { $cab2_items=$val; }
if( $key == 'samps' ) { $samps=$val; }
}
/// printf( "MSG_2460: $j cab2=[$cab2] cab2_items=[$cab2_items] cab2_samps=[$cab2_samps] cab2_pngfil=[$cab2_pngfil]<br>\n" );
$im_cmd = "convert $cabtop_pngfil ";
$items=explode( " ", $cab2_items );
foreach( $items as $item ) {
$item_pngfil="./images/cab/$item.png";
$item_pngfil="./images/cab/tn/tn_$item.png";
$im_cmd .= " $item_pngfil";
//// if( file_exists( $item_pngfil )) {
//// printf( "MSG_2422: FOUND cab2 item=[$item] item_pngfil=[$item_pngfil]<br>\n" );
//// }
//// else {
//// printf( "MSG_2422: NOTFOUND cab2 item=[$item] item_pngfil=[$item_pngfil]<br>\n" );
//// }
}
$cab2_pngfil=sprintf( "./ko_plans/images/%s_cab2_%s_%03d_%03d.png", $planid, $cab2, $step, $samps );
$cab2_pngfiles .= " $cab2_pngfil";
$cab2_tot_samps += $samps;
/// printf( "bugs_1234 tot_samps=[$cab2_tot_samps] samps=[$samps]<br>\n" );
$im_cmd .= " $cabbottom_pngfil -append $cab2_pngfil ";
$im_cmd_status="";
$status=exec($im_cmd,$im_cmd_status);
if( $items_flag == 'true' ) {
$cab2_output .= "<img src=$cab2_pngfil> $cab2_pngfil $samps<br>\n";
/// printf( "MSG_2482: status=[$status] im_cmd=[$im_cmd] cab2_tot_samps=[$cab2_tot_samps]<hr>\n" );
}
}
$pdo=null;
$cab2beg_pngfile=sprintf( "./ko_plans/images/%s_cab2beg_%03d_%04d.png", $planid, $step, $cab2_tot_samps );
$im_cmd = "convert $cab2_pngfiles +append -gravity north $cab2beg_pngfile";
/// printf( "MSG_2432: cab2_tot_samps=[$cab2_tot_samps] im_cmd=[$im_cmd] cab2beg_pngfil=[$cab2beg_pngfil]<hr>\n" );
$status=exec($im_cmd,$im_cmd_status);
$cab2_output .= "<img src=$cab2beg_pngfile border=0 alt=$cab2beg_pngfile><hr>cab2beg_pngfile=[$cab2beg_pngfile] cab2_tot_samps=[$cab2_tot_samps]<br>\n";
$cab2_output .= "<hr><h2>cab2</h2><hr>\n";
$setup_output = "maxamp=[$maxamp] minamp=[$minamp]<hr>\n";
$output = $setup_output . cab1_output . $cab2_output;
return( $output );
}
function ko_dcall($options) {
$output = "<h2>ko_plans</h2>\n";
$output .= "<hr>\n";
return( $output );
}
function ko_leds($options) {
$output = "<h2>ko_plans</h2>\n";
$output .= "<hr>\n";
return( $output );
}
function ko_pchart_pie($options) {
$output = "<h2>ko_pchart_pie</h2>\n";
$output .= "<hr>\n";
include("../pcharts/class/pData.class.php");
include("../pcharts/class/pDraw.class.php");
include("../pcharts/class/pPie.class.php");
include("../pcharts/class/pImage.class.php");
$q=$_REQUEST['q'];
$options=split( "/", $_REQUEST['q'] );
$option0=$options[0];
$option1=$options[1];
$option2=$options[2];
$option3=$options[3];
$option4=$options[4];
$size="10";
$used="5";
$rptcode=$option3;
$progid="ko_plans";
$dttm=date('Ymd_His');
$series_code="df_size";
$series_desc="dv_size";
$labels_list=array();
$labels_list[0]="used";
$labels_list[1]="free";
$labels_list[3]="other";
$series_values=array();
$series_values[0]="25";
$series_values[1]="50";
$series_values[2]="25";
// printf( "<hr>\n" );
// $last_line=passthru( 'df|grep var', $retval );
// $last_line=system( 'df|grep var', $retval );
// $path="/tmp";
// if( $option1 == "" ) { $option1=$path; };
// $path=$option1;
// $syscmd="df|grep '/var' 2>&1";
// $syscmd="df|grep '/tmp'";
// $syscmd="df|grep '/home' 2>&1";
// $syscmd="df|grep '/var'";
// $syscmd="df | grep '/var'";
// $syscmd="df | grep '/tmp'";
// $syscmd="df | grep ' $option1'";
// $last_line=passthru( $syscmd, $retval );
// $last_line=system( "df|grep var", $retval );
// $last_line_system=system( $syscmd, $retval );
/// $last_line_passthru=passthru( $syscmd, $retval );
// $last_line_exec=exec( $syscmd, $retval );
//// exec( $syscmd, $syslines, $retval );
//// $sysline=$syslines[0];
// $args=split( " ", $sysline );
// print_r( $args );
// $explode_text=explode($sysline);
// $args=preg_split('/ +/', $sysline );
// $total=$args[1];
// $used=$args[2];
// $avail=$args[3];
// $perc=$args[4];
// $path=$args[5];
//
// $host=$option1;
// $path=$option2;
// $used=$option3;
// $free=$option4;
$series_values[0]=$used;
$series_values[1]=$free;
$chart_title="$dttm $host /$path used=$used free=$free";
$dbfile="ko_plans.db3";
$pngfil="../images/pchart/ko_pchart_pie.png";
$sql="select distinct(cab1) from ko_plans where planid == 'plan1' limit 5";
$pdo = newpdo( $dbfile );
$j=0;
foreach( $pdo->query( $sql) as $row ) {
$j++;
foreach( $row as $key=>$val ) {
$series_values[$j]=$j;
$labels_list[$j]=$val;
// print( "$j row=[$row] key=[$key] val=[$val] labels_list=[$labels_list[$j]] [$series_values[$j]]<br>\n" );
}
}
$pdo=null;
// $jlim=$j;
// printf( "MSG_2490: pchart_pie pngfil=[$pngfil] chart_title=[$chart_title]<hr>\n" );
// printf( "MSG_2490: pchart_pie jlim=[$jlim] labels_list[$j] series_values=[$series_values]<hr>\n" );
// for( $j=0; $j<$jlim; $j++ ) {
// printf( "MSG_2491: pchart_pie j=[$j] series_values=[$series_values[$j]]<hr>\n" );
// printf( "MSG_2492: pchart_pie j=[$j] labels_list=[$labels_list[$j]] [$series_values[$j]]<hr>\n" );
// }
// return;
// $j=0;
// $testlines=split( '\n', $syslines );
// printf( "testcount=[$testcount]<br>\n" );
// foreach( $testlines as $sysline ) {
// $j++;
// printf( "$j sysline=[$sysline]<br>\n" );
// }
//
// print_r( $syslines );
/* Create and populate the pData object */
$MyData = new pData();
// $MyData->addPoints(array(50,2,3,4,7,10,25,48,41,10,100,200,500),"ScoreA");
// $MyData->addPoints(array(0,2,3,4,7,10),"ko_ScoreA");
// $MyData->setSerieDescription("ko_ScoreA","ko_Application A");
// $MyData->addPoints(array(0,2,3,4,7,10),"$series_code");
// $MyData->addPoints(array(0,2,3,4,7,10),"$series_code");
$MyData->addPoints($series_values,"$series_code");
$MyData->setSerieDescription("$series_code","$series_desc");
/* Define the absissa serie */
// $MyData->addPoints(array("A0","B1","C2","D3","E4","K5","J9"),"Labels");
// $labels_list=array("total", "used", "other" );
// printf( "BUGS_1234 labels_list=[$labels_list]<hr>\n" );
// print_r( $labels_list );
// return;
$MyData->addPoints($labels_list,"Labels");
/// $MyData->addPoints(array( "ab01", "ab02", "ab03", "ab04", "ab05"),"Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(300,260,$MyData);
/* Draw a solid background */
$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
$myPicture->drawFilledRectangle(0,0,300,300,$Settings);
/* Overlay with a gradient */
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,300,260,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,300,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,299,259,array("R"=>0,"G"=>0,"B"=>0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>"../pChart/fonts/Silkscreen.ttf","FontSize"=>6));
$myPicture->drawText(10,13,$chart_title,array("R"=>255,"G"=>255,"B"=>255));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>"../pChart/fonts/Forgotte.ttf","FontSize"=>10,"R"=>80,"G"=>80,"B"=>80));
/* Create the pPie object */
$PieChart = new pPie($myPicture,$MyData);
/* Draw an AA pie chart */
$PieChart->draw3DPie(160,140,array("Radius"=>70,"DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE));
/* Write the legend box */
$myPicture->setShadow(FALSE);
$PieChart->drawPieLegend(15,40,array("Alpha"=>20));
/* Render the picture (choose the best way) */
// $myPicture->autoOutput("$pngfil");
$myPicture->autoOutput($pngfil);
return( $output );
}
//
koh5_pano
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer