Initial commit

This commit is contained in:
2026-09-03 11:24:19 +02:00
commit 6ed3153f36
1897 changed files with 538007 additions and 0 deletions
+265
View File
@@ -0,0 +1,265 @@
<?php
if (file_exists('./polynomial/math.php'))
require_once('./polynomial/math.php');
else
require_once('../polynomial/math.php');
// Moc - stacja prób
// ========================================================== //// ========================================================== //
function createPeTestChart($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, 'Pe[kW]');
// ========================================================================================================================
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);
// ========================================================================================================================
// 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);
elseif ($point==4)
{
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $background_color);
imageellipse($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $black);
}
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //
// Moc - wizard (kreator doboru)
// ========================================================== //// ========================================================== //
function createPePumpWizardChart($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, 'Pe[kW]');
// ========================================================================================================================
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).'; Pe='.round($qyVal,2).')');
$xPos = ($imgWidth-47) - ($right - $left);
imagettftext($im, 10, 0, $xPos, 17,$bool, $font, '(Q='.round($qVal*$m3h,$ilosc_po_przecinku).'; Pe='.round($qyVal,2).')');
}
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //