356 lines
15 KiB
PHP
356 lines
15 KiB
PHP
<?php
|
|
if (!empty($_SESSION['site201']))
|
|
{
|
|
?>
|
|
|
|
<div id='loader-wrapper'><div id='loader'></div></div>
|
|
|
|
|
|
|
|
<?php
|
|
// Load the polynomial regression class.
|
|
require_once('./polynomial/PolynomialRegression.php' );
|
|
require_once('./polynomial/uniwersalplot.php' );
|
|
|
|
$_POST['inQpump'] = getFloatValue($_POST['inQpump']);
|
|
$_POST['inHpump'] = getFloatValue($_POST['inHpump']);
|
|
|
|
|
|
// =================================================================================================== //
|
|
$imageWidth = 900;
|
|
$imageHeight = 400;
|
|
$leftMargin = 25;
|
|
$rightMargin = 50;
|
|
$topMargin = 25;
|
|
$bottomMargin = 40;
|
|
$image = @imageCreate( $imageWidth , $imageHeight )
|
|
or die( "Cannot Initialize new GD image stream" );
|
|
|
|
// =================================================================================================== //
|
|
$colorMap = array();
|
|
|
|
//$colorMap[ "Background" ] = imageColorAllocate( $image , 0xDB , 0xB3 , 0xE6 );
|
|
$colorMap[ "Background" ] = imageColorAllocate( $image , 255, 255, 255 );
|
|
// Create a standard color palette
|
|
$colorMap[ "Black" ] = imagecolorallocate( $image, 0, 0, 0 );
|
|
$colorMap[ "Red" ] = imagecolorallocate( $image, 192, 0, 0 );
|
|
$colorMap[ "Green" ] = imagecolorallocate( $image, 0, 192, 0 );
|
|
$colorMap[ "Blue" ] = imagecolorallocate( $image, 0, 0, 192 );
|
|
$colorMap[ "Brown" ] = imagecolorallocate( $image, 48, 48, 0 );
|
|
$colorMap[ "Cyan" ] = imagecolorallocate( $image, 0, 192, 192 );
|
|
$colorMap[ "Purple" ] = imagecolorallocate( $image, 192, 0, 192 );
|
|
$colorMap[ "LightGray" ] = imagecolorallocate( $image, 192, 192, 192 );
|
|
|
|
$colorMap[ "DarkGray" ] = imagecolorallocate( $image, 48, 48, 48 );
|
|
$colorMap[ "LightRed" ] = imagecolorallocate( $image, 255, 0, 0 );
|
|
$colorMap[ "LightGreen" ] = imagecolorallocate( $image, 0, 255, 0 );
|
|
$colorMap[ "LightBlue" ] = imagecolorallocate( $image, 0, 0, 255 );
|
|
$colorMap[ "Yellow" ] = imagecolorallocate( $image, 255, 255, 0 );
|
|
$colorMap[ "LightCyan" ] = imagecolorallocate( $image, 0, 255, 255 );
|
|
$colorMap[ "LightPurple" ] = imagecolorallocate( $image, 255, 0, 255 );
|
|
$colorMap[ "White" ] = imagecolorallocate( $image, 255, 255, 255 );
|
|
$colorMap[ "DarkYellow" ] = imagecolorallocate( $image, 255, 214, 0 );
|
|
|
|
$colorMap[ "Gray10" ] = imagecolorallocate( $image , 26 , 26 , 26 );
|
|
$colorMap[ "Gray20" ] = imagecolorallocate( $image , 51 , 51 , 51 );
|
|
$colorMap[ "Gray30" ] = imagecolorallocate( $image , 77 , 77 , 77 );
|
|
$colorMap[ "Gray40" ] = imagecolorallocate( $image , 102 , 102 , 102 );
|
|
$colorMap[ "Gray50" ] = imagecolorallocate( $image , 128 , 128 , 128 );
|
|
$colorMap[ "Gray60" ] = imagecolorallocate( $image , 154 , 154 , 154 );
|
|
$colorMap[ "Gray70" ] = imagecolorallocate( $image , 180 , 180 , 180 );
|
|
$colorMap[ "Gray80" ] = imagecolorallocate( $image , 205 , 205 , 205 );
|
|
$colorMap[ "Gray90" ] = imagecolorallocate( $image , 230 , 230 , 230 );
|
|
|
|
imageRectangle
|
|
(
|
|
$image,
|
|
$leftMargin,
|
|
$topMargin,
|
|
$imageWidth - $rightMargin,
|
|
$imageHeight - $bottomMargin,
|
|
$colorMap[ "LightGray" ]
|
|
);
|
|
|
|
if ($_POST['subSearchPumps']==$lab_ButtonName_Search && $_POST['inQpump']>0)
|
|
{
|
|
$xMax=0; $yMax=0;
|
|
unset($pupArray);
|
|
$pupArray = sqlGetResAsArray("select PUP_ID,PUP_H_MAX from seg_pumps where PUP_Q_MIN/60<".$_POST['inQpump']." and PUP_Q_MAX/60>".$_POST['inQpump']." order by PUP_NAME");
|
|
|
|
for ($i=0; $i<count($pupArray); $i++)
|
|
{
|
|
unset($tmpArray);
|
|
$tmpArray = sqlGetResAsArray("select (PEP_X_PARAM/60) PEP_X_PARAM,PEP_Y_PARAM from seg_pump_eng_param where PEP_TYPE='H' and PEP_PUP_ID=".$pupArray[$i]['PUP_ID']." order by PEP_X_PARAM");
|
|
$tmpVal = 0;
|
|
$tmpVal = getPolynomialValue_201($tmpArray,$_POST['inQpump']);
|
|
|
|
$tmpArrayETA = sqlGetResAsArray("select (PEP_X_PARAM/60) PEP_X_PARAM,PEP_Y_PARAM from seg_pump_eng_param where PEP_TYPE='ETA' and PEP_PUP_ID=".$pupArray[$i]['PUP_ID']." order by PEP_X_PARAM");
|
|
$tmpValETA = 0;
|
|
$tmpValETA = getPolynomialValue_201($tmpArrayETA,$_POST['inQpump']);
|
|
|
|
|
|
if ($_POST['inHpump']>0)
|
|
{
|
|
if ($_POST['inHpump']>=($tmpVal-5) && $_POST['inHpump']<=($tmpVal+8))
|
|
{
|
|
$finalArray[] = array(
|
|
'pupID' => $pupArray[$i]['PUP_ID'],
|
|
'hVal' => $tmpVal,
|
|
'etaVal' => $tmpValETA
|
|
);
|
|
|
|
$pupIDs[] = $pupArray[$i]['PUP_ID'];
|
|
|
|
|
|
// dopisuje największą wartośc dla x,y max
|
|
$tmpCount = 0; $tmpCount = count($tmpArray)-1;
|
|
if ($tmpArray[$tmpCount]['PEP_X_PARAM']>$xMax)
|
|
$xMax = $tmpArray[$tmpCount]['PEP_X_PARAM'];
|
|
if ($pupArray[$i]['PUP_H_MAX']>$yMax)
|
|
$yMax = $pupArray[$i]['PUP_H_MAX'];
|
|
// ========================================
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$finalArray[] = array(
|
|
'pupID' => $pupArray[$i]['PUP_ID'],
|
|
'hVal' => $tmpVal,
|
|
'etaVal' => $tmpValETA
|
|
);
|
|
|
|
$pupIDs[] = $pupArray[$i]['PUP_ID'];
|
|
|
|
// dopisuje największą wartośc dla x,y max
|
|
$tmpCount = 0; $tmpCount = count($tmpArray)-1;
|
|
if ($tmpArray[$tmpCount]['PEP_X_PARAM']>$xMax)
|
|
$xMax = $tmpArray[$tmpCount]['PEP_X_PARAM'];
|
|
if ($pupArray[$i]['PUP_H_MAX']>$yMax)
|
|
$yMax = $pupArray[$i]['PUP_H_MAX'];
|
|
// ========================================
|
|
}
|
|
}
|
|
unset($tmpArray);
|
|
unset($pupArray);
|
|
|
|
|
|
|
|
$yMax=ceil($yMax/10)*10;
|
|
|
|
|
|
|
|
if(count($finalArray)>0)
|
|
{
|
|
$X_MajorScale = $xMax/5;
|
|
$X_MinorScale = $X_MajorScale / 4;
|
|
$Y_MajorScale = $yMax/4;
|
|
$Y_MinorScale = $Y_MajorScale / 2;
|
|
|
|
$plot = new XY_PlotClass($image);
|
|
$plot->sizeWindow
|
|
(
|
|
$leftMargin,
|
|
$topMargin,
|
|
$imageWidth - $rightMargin,
|
|
$imageHeight - $bottomMargin
|
|
);
|
|
|
|
// =================================================================================================== //
|
|
$plot->setX_Span( 0, $xMax);
|
|
$plot->setY_Span( 0, $yMax);
|
|
plotAddScale();
|
|
|
|
$font = './fonts/verdana.ttf';
|
|
imagettftext($image, 10, 0, 10,15, $colorMap["Black"], $font, 'H[m]');
|
|
imagettftext($image, 10, 0, 830,395, $colorMap["Black"], $font, 'Q[m3/min]');
|
|
|
|
|
|
|
|
foreach ( $pupIDs as $pupID )
|
|
{
|
|
$i=0; $j=0;
|
|
$wynik = mysql_query("select (PEP_X_PARAM/60) PEP_X_PARAM,PEP_Y_PARAM,PEP_PUP_ID from seg_pump_eng_param where PEP_TYPE='H' and PEP_PUP_ID=$pupID order by PEP_X_PARAM");
|
|
if($wynik)while ($r = mysql_fetch_array($wynik))
|
|
{
|
|
$newParam[$i][$j] = $r["PEP_X_PARAM"];
|
|
$scope[] = $r["PEP_X_PARAM"];
|
|
$j++;
|
|
$newParam[$i][$j] = $r["PEP_Y_PARAM"];
|
|
$i++; $j=0;
|
|
}
|
|
|
|
$data = $newParam; unset($newParam);
|
|
bcscale( 10 );
|
|
plotRenderData( $data, $colorMap[ "Red" ] );
|
|
$plot->setX_Span( 0, $xMax);
|
|
$plot->setY_Span( 0, $yMax);
|
|
// $plot->setCircleSize( 4 );
|
|
// $plot->renderPoints();
|
|
$regression = new PolynomialRegression( 4 );
|
|
foreach ( $data as $dataPoint)
|
|
$regression->addData( $dataPoint[0], $dataPoint[1]);
|
|
$coefficients = $regression->getCoefficients();
|
|
|
|
// Plot each of the curves.
|
|
//plotRenderRegression( $regression, $coefficients, $scope[0], $scope[2], $colorMap[ "Red" ] );
|
|
plotRenderRegression( $regression, $coefficients, $scope[2], $scope[3], $colorMap[ "DarkYellow" ] );
|
|
plotRenderRegression( $regression, $coefficients, $scope[3], $scope[5], $colorMap[ "Green" ] );
|
|
plotRenderRegression( $regression, $coefficients, $scope[5], $scope[6], $colorMap[ "DarkYellow" ] );
|
|
//plotRenderRegression( $regression, $coefficients, $scope[6], $scope[7], $colorMap[ "Red" ] );
|
|
|
|
unset($regression);
|
|
unset($coefficients);
|
|
unset($data);
|
|
unset($dataPoint);
|
|
unset($scope);
|
|
|
|
}
|
|
}
|
|
else
|
|
imageString($image,5,240,190,$lab_Field_site201_006,$colorMap[ "Red" ]);
|
|
}
|
|
|
|
|
|
// Output image
|
|
$fileName1="./charts/".$_SESSION['user']."_".date("Ymd")."_".date("His")."_chart_201_01.png";
|
|
imagePNG( $image,$fileName1);
|
|
|
|
$_POST['inHpump'] = str_replace(".",",",$_POST['inHpump']);
|
|
$_POST['inQpump'] = str_replace(".",",",$_POST['inQpump']);
|
|
|
|
?>
|
|
|
|
<div class="tag100">
|
|
<div class="head_tag"><?php echo $lab_Tag_site201_001 ;?></div>
|
|
<form method="post" action="?pg=site201">
|
|
<div class="tag_center"><br/>
|
|
<table class="desc_val">
|
|
<tr>
|
|
<td class="label_gray"><?php echo $lab_Field_site201_003;?></td>
|
|
<td class="desc_value"><input class="float" type="text" name="inQpump" value="<?php echo $_POST['inQpump'];?>"> m<sup>3</sup>/min</td>
|
|
<td class="label_gray"><?php echo $lab_Field_site201_002;?></td>
|
|
<td class='desc_value'><input class="float" type="text" name="inHpump" value="<?php echo $_POST['inHpump'];?>"> m</td>
|
|
<td class="desc_value"><input class="btn btn-default btn-sm" type="submit" name="subSearchPumps" value="<?php echo $lab_ButtonName_Search; ?>" onclick="makeRequest('?pg=site401mhis');"> </td>
|
|
</tr>
|
|
</table><br/>
|
|
<img src="<?php echo $fileName1;?>">
|
|
</div>
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$_POST['inHpump'] = str_replace(",",".",$_POST['inHpump']);
|
|
$_POST['inQpump'] = str_replace(",",".",$_POST['inQpump']);
|
|
|
|
if ($_POST['inQpump']>0 && count($pupIDs)>0)
|
|
{
|
|
?>
|
|
<div class="head_tag">
|
|
<div style="display:inline-block; font-size: 14px; color: #ffffff;"><?php echo $lab_Tag_site201_002 ;?></div>
|
|
<div style="display:inline-block; float:right; padding-right: 5px;"><img style='cursor: pointer; max-width: 16px; border: 0;' src='./images/printer-icon.png' title="Drukuj" onclick="window.print();"></div>
|
|
|
|
|
|
|
|
</div>
|
|
<div class="tag_center">
|
|
<table WIDTH="100%" class="tag">
|
|
<TR>
|
|
<TD class="label">Lp.</TD>
|
|
<TD class="label"><?php echo $lab_Field_site203_001 ;?></TD>
|
|
<TD class="label"><?php echo $lab_Field_site204_001 ;?></TD>
|
|
<TD class="label">Q<sub>n</sub> [m<sup>3</sup>/min]</TD>
|
|
<TD class="label">Q<sub>sz</sub> [m<sup>3</sup>/min]</TD>
|
|
<TD class="label">H(Q<sub>sz</sub>) [m]</TD>
|
|
<TD class="label">η(Q<sub>sz</sub>)</TD>
|
|
<TD class="label"><?php echo $lab_Field_site201_009 ;?></TD>
|
|
<TD class="label"><?php echo $lab_Field_site204_002 ;?></TD>
|
|
|
|
|
|
<?php
|
|
|
|
$finalArray = sortmddata($finalArray,'etaVal','DESC','num');
|
|
|
|
// print_r($finalArray);
|
|
$counter=1;
|
|
for ($i=0; $i<count($finalArray); $i++)
|
|
{
|
|
unset($tmpArray);
|
|
$tmpArray = sqlGetResAsArray("select PUP_NAME,(PUP_Q_N/60) PUP_Q_N,ENG_ID,ENG_NAME,ENG_VOLTAGE,ENG_POWER from seg_pumps left join seg_pump_engine_rel on RPE_PUP_ID=PUP_ID left join seg_engines on RPE_ENG_ID=ENG_ID where PUP_ID=".$finalArray[$i]['pupID']." order by ENG_POWER");
|
|
|
|
for ($j=0; $j<count($tmpArray); $j++)
|
|
{
|
|
echo"
|
|
<TR STYLE='cursor: pointer;' onclick=".chr(34)."document.location.href='./?pg=site201det&pup=".$finalArray[$i]['pupID']."&eng=".$tmpArray[$j]['ENG_ID']."'".chr(34).">
|
|
<TD class='field_left'>".$counter."</TD>
|
|
<TD class='field_left'>".$tmpArray[$j]['PUP_NAME']."</TD>
|
|
<TD class='field_left'>".$tmpArray[$j]['ENG_NAME']."</TD>
|
|
<TD class='field_right'>".round($tmpArray[$j]['PUP_Q_N'],3)."</TD>
|
|
<TD class='field_right'>".str_replace(".",",",$_POST['inQpump'])."</TD>
|
|
<TD class='field_right'>".round($finalArray[$i]['hVal'],2)."</TD>
|
|
<TD class='field_right'>".round($finalArray[$i]['etaVal'],2)."</TD>
|
|
<TD class='field_right'>".$tmpArray[$j]['ENG_POWER']."</TD>
|
|
<TD class='field_right'>".$tmpArray[$j]['ENG_VOLTAGE']."</TD>
|
|
</TR>
|
|
";
|
|
$counter++;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
$l=0;
|
|
foreach ($pupIDs as $scoupeID)
|
|
{
|
|
if ($l==0) $internelSQL = $scoupeID;
|
|
else $internelSQL .= ",".$scoupeID;
|
|
$l++;
|
|
}
|
|
|
|
$wynik = mysql_query("select PUP_NAME,ENG_NAME,ENG_POWER,ENG_VOLTAGE,RPE_PUP_ID,PUF_A,PUF_B,PUF_C,PUF_D from seg_pump_engine_rel left join seg_pumps on RPE_PUP_ID=PUP_ID left join seg_engines on RPE_ENG_ID=ENG_ID left join seg_pumps_xy_formula on RPE_PUP_ID=PUF_PUP_ID where RPE_PUP_ID in ($internelSQL) and PUF_TYPE='H' order by ENG_POWER,PUP_NAME,ENG_NAME");
|
|
if($wynik)while ($r = mysql_fetch_array($wynik))
|
|
{
|
|
$sql_1 = $r["PUP_NAME"];
|
|
$sql_2 = $r["ENG_NAME"];
|
|
$sql_3 = $r["ENG_POWER"];
|
|
$sql_4 = $r["ENG_VOLTAGE"];
|
|
$sql_5 = $r["RPE_PUP_ID"];
|
|
$sql_A = $r["PUF_A"];
|
|
$sql_B = $r["PUF_B"];
|
|
$sql_C = $r["PUF_C"];
|
|
$sql_D = $r["PUF_D"];
|
|
|
|
$y = round($sql_A*$_POST['inQpump']*$_POST['inQpump']*$_POST['inQpump']+$sql_B*$_POST['inQpump']*$_POST['inQpump']+$sql_C*$_POST['inQpump']+$sql_D,2);
|
|
echo"
|
|
<TR>
|
|
<TD class='field_left'>$sql_1</TD>
|
|
<TD class='field_left'>$sql_2</TD>
|
|
<TD class='field_right'>".str_replace(".",",",$_POST['inQpump'])."</TD>
|
|
<TD class='field_right'>".str_replace(".",",",$y)."</TD>
|
|
<TD class='field_right'>".setPumpETAparameterForQ($sql_5,$_POST['inQpump'])."</TD>
|
|
<TD class='field_right'>".str_replace(".",",",$sql_3)."</TD>
|
|
<TD class='field_right'>".str_replace(".",",",$sql_4)."</TD>
|
|
</TR>
|
|
";
|
|
|
|
}
|
|
*/
|
|
?>
|
|
|
|
</TR>
|
|
</table>
|
|
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
else showFooterWarningAccessNotification($lab_FooterWarningAccessNotification_001);
|
|
?>
|