840 lines
35 KiB
PHP
840 lines
35 KiB
PHP
<?php
|
|
|
|
if (file_exists('./polynomial/math.php'))
|
|
require_once('./polynomial/math.php');
|
|
else
|
|
require_once('../polynomial/math.php');
|
|
|
|
|
|
|
|
|
|
// Podnoszenie
|
|
// site 401
|
|
// ========================================================== //// ========================================================== //
|
|
function createHpChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0, $point=0)
|
|
{
|
|
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
|
|
|
|
$polynomial = new zc_math_polynomial($tstData);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($tstData); $i++)
|
|
{
|
|
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
|
|
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
|
|
}
|
|
|
|
$max_XVal = $max_XVal;
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
// $font = './fonts/calibri.ttf';
|
|
// $fontBold = './fonts/Calibri_b.ttf';
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
/*
|
|
// rysuje pionową kreskę dla Q
|
|
// ========================================================================================================================
|
|
if ($qVal>0)
|
|
imageline($im, 40+$wspX*$qVal, ($imgHeight-30), 40+$wspX*$qVal, 30, $blue);
|
|
// ========================================================================================================================
|
|
*/
|
|
|
|
// rysuje punkty
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<count($tstData); $i++)
|
|
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
//$step = round(1/$wspX,2);
|
|
$step = (1/$wspX);
|
|
if ($step>0)
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
if ($i<=$pupData[2]) $color = $red;
|
|
else if ($i>$pupData[2] && $i<=$pupData[3]) $color = $yellow;
|
|
else if ($i>$pupData[3] && $i<=$pupData[5]) $color = $green;
|
|
else if ($i>$pupData[5] && $i<=$pupData[6]) $color = $yellow;
|
|
else $color = $red;
|
|
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje kropk�
|
|
// 0 nie rysuje, 1 - zielona, 2 - ��ta, 3 - czerwona, 4 - bia�a
|
|
// ========================================================================================================================
|
|
if ($point==1)
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $green);
|
|
elseif ($point==2)
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-28)-$wspY*$polynomial->get_y($qVal), 10, 10, $yellow);
|
|
elseif ($point==3)
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-25)-$wspY*$polynomial->get_y($qVal), 10, 10, $red);
|
|
else
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $dark_gray);
|
|
|
|
// ========================================================================================================================
|
|
imagettftext($im, 10, 0, $imgWidth-60, 12,$blue, $font, 'Q='.round($qVal/60,3));
|
|
|
|
return imagepng($im,$imgFileName);
|
|
|
|
}
|
|
// ========================================================== //// ========================================================== //
|
|
|
|
|
|
// Podnoszenie - Lift
|
|
// site 401lift
|
|
// ========================================================== //// ========================================================== //
|
|
function createLiftChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0, $currentHp)
|
|
{
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
|
|
$polynomial = new zc_math_polynomial($tstData);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($tstData); $i++)
|
|
{
|
|
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
|
|
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
|
|
}
|
|
|
|
$max_XVal = $max_XVal;
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje punkty
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<count($tstData); $i++)
|
|
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
//$step = round(1/$wspX,2);
|
|
$step = (1/$wspX);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
if ($i<=$pupData[2]) $color = $red;
|
|
else if ($i>$pupData[2] && $i<=$pupData[3]) $color = $yellow;
|
|
else if ($i>$pupData[3] && $i<=$pupData[5]) $color = $green;
|
|
else if ($i>$pupData[5] && $i<=$pupData[6]) $color = $yellow;
|
|
else $color = $red;
|
|
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje kropk�
|
|
// powyżej wykresu
|
|
// ========================================================================================================================
|
|
if ($currentHp>$polynomial->get_y($qVal)+6)
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal)-6, 8, 8, $red);
|
|
else
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$currentHp, 8, 8, $blue);
|
|
// ========================================================================================================================
|
|
|
|
return imagepng($im,$imgFileName);
|
|
}
|
|
// ========================================================== //// ========================================================== //
|
|
|
|
|
|
// Podnoszenie - stacja pr�b
|
|
// ========================================================== //// ========================================================== //
|
|
function createHpTestChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
|
|
{
|
|
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
|
|
$polynomial = new zc_math_polynomial($tstData);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($tstData); $i++)
|
|
{
|
|
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
|
|
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
|
|
}
|
|
|
|
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
|
|
imagefilledrectangle($im, 40, 30, 40+$wspX*$pupData[2], $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[2], 30, 40+$wspX*$pupData[3], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[3], 30, 40+$wspX*$pupData[5], $imgHeight-30, imagecolorallocatealpha($im, 0, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[5], 30, 40+$wspX*$pupData[6], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[6], 30, $imgWidth-30, $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
$step = round(1/$wspX,2);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $black);
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// rysuje punkty
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<count($tstData); $i++)
|
|
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 7, 7, $blue);
|
|
// ========================================================================================================================
|
|
|
|
|
|
return imagepng($im,$imgFileName);
|
|
|
|
}
|
|
// ========================================================== //// ========================================================== //
|
|
|
|
|
|
// Podnoszenie - wizard (kreator doboru)
|
|
// ========================================================== //// ========================================================== //
|
|
function createHpPumpWizardChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
|
|
{
|
|
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
|
|
$polynomial = new zc_math_polynomial($tstData);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($tstData); $i++)
|
|
{
|
|
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
|
|
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
|
|
}
|
|
|
|
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
//$bool = imagecolorallocate($im, 185, 0, 0);
|
|
$bool = imagecolorallocate($im, 0, 128, 255);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
|
|
imagefilledrectangle($im, 40, 30, 40+$wspX*$pupData[2], $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[2], 30, 40+$wspX*$pupData[3], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[3], 30, 40+$wspX*$pupData[5], $imgHeight-30, imagecolorallocatealpha($im, 0, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[5], 30, 40+$wspX*$pupData[6], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
|
|
imagefilledrectangle($im, 40+$wspX*$pupData[6], 30, $imgWidth-30, $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
$step = round(1/$wspX,2);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $black);
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// rysuje punkty
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<count($tstData); $i++)
|
|
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje kropk� + opis
|
|
// ========================================================================================================================
|
|
if ($qVal>0)
|
|
{
|
|
$qyVal = $polynomial->get_y($qVal);
|
|
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$qyVal, 9, 9, $bool);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, '(Q='.round($qVal*$m3h,$ilosc_po_przecinku).'; H='.round($qyVal,2).')');
|
|
$xPos = ($imgWidth-47) - ($right - $left);
|
|
imagettftext($im, 10, 0, $xPos, 17,$bool, $font, '(Q='.round($qVal*$m3h,$ilosc_po_przecinku).'; H='.round($qyVal,2).')');
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
return imagepng($im,$imgFileName);
|
|
|
|
}
|
|
// ========================================================== //// ========================================================== //
|
|
|
|
|
|
// Podnoszenie - wyszukiwarka Wyb�r agregatu pompowego (site 201)
|
|
// ========================================================== //// ========================================================== //
|
|
function createSearchPumpsChart($inPupArray, $qVal, $hVal, $imgFileName, $imgWidth=900, $imgHeight=400, $xDiv=10, $yDiv=10, $m3min=0)
|
|
{
|
|
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
unset($outArray);
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($inPupArray); $i++)
|
|
{
|
|
if ($inPupArray[$i]['PUP_Q_MAX']>$max_XVal) $max_XVal=$inPupArray[$i]['PUP_Q_MAX'];
|
|
if ($inPupArray[$i]['PUP_H_MAX']>$max_YVal) $max_YVal=$inPupArray[$i]['PUP_H_MAX'];
|
|
}
|
|
|
|
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
$bool = imagecolorallocate($im, 185, 0, 0);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
//rysuje poszczeg�lne wykresy dla pomp
|
|
for($p=0; $p<count($inPupArray); $p++)
|
|
{
|
|
unset($dataP); unset($dataH); unset($dataEta);
|
|
$wynik = mysql_query("select tb1.PEP_X_PARAM X, tb1.PEP_Y_PARAM Y1, tb2.PEP_Y_PARAM Y2 from (select PEP_X_PARAM,PEP_Y_PARAM from seg_pump_eng_param where PEP_PUP_ID=".$inPupArray[$p]['PUP_ID']." and PEP_TYPE='H') tb1,(select PEP_X_PARAM,PEP_Y_PARAM from seg_pump_eng_param where PEP_PUP_ID=".$inPupArray[$p]['PUP_ID']." and PEP_TYPE='ETA') tb2 where tb1.PEP_X_PARAM=tb2.PEP_X_PARAM order by X");
|
|
if($wynik)while ($r = mysql_fetch_array($wynik))
|
|
{
|
|
$dataP[] = $r["X"];
|
|
$dataH[] = array(
|
|
getFloatValue($r["X"]),
|
|
getFloatValue($r["Y1"])
|
|
);
|
|
$dataEta[] = array(
|
|
getFloatValue($r["X"]),
|
|
getFloatValue($r["Y2"])
|
|
);
|
|
}
|
|
|
|
unset($polynomial);
|
|
$polynomial = new zc_math_polynomial($dataH);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
unset($polynomialEta);
|
|
$polynomialEta = new zc_math_polynomial($dataEta);
|
|
$polynomialEta->calculate_coefficients();
|
|
|
|
// wyszukuje pomp spe�niaj�cych za�o�enia
|
|
$hTmp = 0;
|
|
$hTmp = $polynomial->get_y($qVal);
|
|
|
|
|
|
// dla podanej wysoko�ci H
|
|
if ($hVal>0 )
|
|
{
|
|
if ($hTmp>=$hVal-5 && $hTmp<=$hVal+8)
|
|
{
|
|
$outArray[] = array(
|
|
'pupID' => $inPupArray[$p]['PUP_ID'],
|
|
'qVal' => $qVal,
|
|
'hVal' => round($hTmp,2),
|
|
'etaVal' => round($polynomialEta->get_y($qVal),2)
|
|
);
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
$step = round(1/$wspX,2);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
|
|
if ($i<=$dataP[2]) $color = $red;
|
|
else if ($i>$dataP[2] && $i<=$dataP[3]) $color = $yellow;
|
|
else if ($i>$dataP[3] && $i<=$dataP[5]) $color = $green;
|
|
else if ($i>$dataP[5] && $i<=$dataP[6]) $color = $yellow;
|
|
else $color = $red;
|
|
|
|
if ($color==$yellow || $color==$green)
|
|
{
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
|
}
|
|
}
|
|
// ========================================================================================================================
|
|
}
|
|
}
|
|
//rszta
|
|
else
|
|
{
|
|
$outArray[] = array(
|
|
'pupID' => $inPupArray[$p]['PUP_ID'],
|
|
'qVal' => $qVal,
|
|
'hVal' => round($hTmp,2),
|
|
'etaVal' => round($polynomialEta->get_y($qVal),2)
|
|
);
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
$step = round(1/$wspX,2);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
|
|
if ($i<=$dataP[2]) $color = $red;
|
|
else if ($i>$dataP[2] && $i<=$dataP[3]) $color = $yellow;
|
|
else if ($i>$dataP[3] && $i<=$dataP[5]) $color = $green;
|
|
else if ($i>$dataP[5] && $i<=$dataP[6]) $color = $yellow;
|
|
else $color = $red;
|
|
|
|
if ($color==$yellow || $color==$green)
|
|
{
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
|
}
|
|
}
|
|
// ========================================================================================================================
|
|
}
|
|
|
|
}
|
|
|
|
imagesetstyle($im, Array($bool,$bool,$bool,$bool,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT));
|
|
imagedashedline($im, 40+$wspX*$qVal, 30, 40+$wspX*$qVal, $imgHeight-30, IMG_COLOR_STYLED);
|
|
|
|
imagepng($im,$imgFileName);
|
|
|
|
unset($resArray);
|
|
$resArray = array(
|
|
'file' => $imgFileName,
|
|
'pump' => $outArray
|
|
);
|
|
|
|
return $resArray;
|
|
|
|
}
|
|
// ========================================================== //// ========================================================== //
|
|
|
|
|
|
// Podnoszenie - pompy stacjonarne
|
|
// site 406
|
|
// ========================================================== //// ========================================================== //
|
|
function createRoomHpChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0, $hz=50, $pointColor)
|
|
{
|
|
|
|
$max_XVal=0;
|
|
$max_YVal=0;
|
|
|
|
$polynomial = new zc_math_polynomial($tstData);
|
|
$polynomial->calculate_coefficients();
|
|
|
|
// ustanawia najwy�sza� warto�� dla X i Y
|
|
for($i=0; $i<count($tstData); $i++)
|
|
{
|
|
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
|
|
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
|
|
}
|
|
|
|
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
|
|
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
|
|
|
|
|
//sprawdza, czy m3/min, czy m3/h
|
|
if ($m3min==1)
|
|
{
|
|
$m3h = 1/60;
|
|
$ilosc_po_przecinku = 3;
|
|
$m3Desc = 'Q[m3/min]';
|
|
}
|
|
else
|
|
{
|
|
$m3h = 1;
|
|
$ilosc_po_przecinku = 2;
|
|
$m3Desc = 'Q[m3/h]';
|
|
}
|
|
|
|
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
|
|
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
|
|
|
|
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
|
|
$background_color = imagecolorallocate($im, 255, 255, 255);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$gray = imagecolorallocate($im, 200, 200, 200);
|
|
$dark_gray = imagecolorallocate($im, 180, 180, 180);
|
|
$red = imagecolorallocate($im, 235, 0, 0);
|
|
$yellow = imagecolorallocate($im, 240, 240, 0);
|
|
$green = imagecolorallocate($im, 34, 177, 76);
|
|
$blue = imagecolorallocate($im, 0, 0, 200);
|
|
|
|
$wspX = ($imgWidth-70)/$max_XVal;
|
|
$wspY = ($imgHeight-60)/$max_YVal;
|
|
|
|
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
|
|
|
|
// pionowa skala [X]
|
|
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
|
|
// ========================================================================================================================
|
|
// ========================================================================================================================
|
|
for ($i=1; $i<$xDiv; $i++)
|
|
{
|
|
$szer=(($imgWidth-70)/$xDiv)*$i;
|
|
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
|
|
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
$xMove = 15 + ($right - $left)/2;
|
|
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
// pozioma skala [Y]
|
|
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'H[m]');
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<=$yDiv; $i++)
|
|
{
|
|
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
|
|
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
$xPos = 36 - ($right - $left);
|
|
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
|
|
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje punkty
|
|
// ========================================================================================================================
|
|
for ($i=0; $i<count($tstData); $i++)
|
|
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
|
|
// ========================================================================================================================
|
|
|
|
|
|
// rysuje linie
|
|
// ========================================================================================================================
|
|
$step = round(1/$wspX,2);
|
|
for ($i=0; $i<$max_XVal; $i+=$step)
|
|
{
|
|
if ($hz<50) $color = $dark_gray;
|
|
else $color = $blue;
|
|
|
|
$yLineTo = $polynomial->get_y($i+$step);
|
|
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
|
|
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
|
}
|
|
// ========================================================================================================================
|
|
|
|
|
|
|
|
// rysuje kropk�
|
|
// ========================================================================================================================
|
|
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, imagecolorallocate($im, $pointColor['R'], $pointColor['G'], $pointColor['B']));
|
|
// ========================================================================================================================
|
|
|
|
return imagepng($im,$imgFileName);
|
|
|
|
}
|
|
// ========================================================== //// ========================================================== //
|