File: C:/xampp/htdocs/FograCT1/ReportLight.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gray finder Check</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #ffffff;
margin: 0; /* 比較好的做法是將 Body 元素的邊界與欄位間隔調整為零,以處理不同的瀏覽器預設值 */
padding: 0;
text-align: center; /* 這樣會讓容器在 IE 5* 瀏覽器內置中對齊。然後,文字會在 #container 選取器中設定為靠左對齊預設值 */
color: #000000;
}
.oneColElsCtr #container {
width: 46em;
background: #FFFFFF;
margin: 0 auto; /* 自動邊界 (搭配寬度) 會讓頁面置中對齊 */
border: 0px solid #000000;
text-align: left; /* 這樣做會覆寫 Body 元素上的 text-align: center。 */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* 請記住,欄位間隔就是 Div 方塊內部的空間,而邊界就是 Div 方塊外部的空間 */
}
-->
</style></head>
<body class="oneColElsCtr">
<?php
include 'sp38XYZ.php';
include 'xyz2lab01.php';
include 'xyz2lab.php';
//error_reporting(0);
$company=$_GET['company'];
$light=$_GET["fileLT"];
echo "Light:".$light;
$contents = file("upload/".$light);
$stringC = implode($contents);
$string = implode($contents);
$dot = explode("_", $string);
//print_r($dot);
$snstring=$dot[0];
echo "sn:".$snstring;
$LightX=sp38XYZ("X",($dot[1]*1),($dot[2]*1),($dot[3]*1),($dot[4]*1),($dot[5]*1),($dot[6]*1),($dot[7]*1),($dot[8]*1),($dot[9]*1),($dot[10]*1),($dot[11]*1),($dot[12]*1),($dot[13]*1),($dot[14]*1),($dot[15]*1),($dot[16]*1),($dot[17]*1),($dot[18]*1),($dot[19]*1),($dot[20]*1),($dot[21]*1),($dot[22]*1),($dot[23]*1),($dot[24]*1),($dot[25]*1),($dot[26]*1),($dot[27]*1),($dot[28]*1),($dot[29]*1),($dot[30]*1),($dot[31]*1),($dot[32]*1),($dot[33]*1),($dot[34]*1),($dot[35]*1),($dot[36]*1));
$LightY=sp38XYZ("Y",($dot[1]*1),($dot[2]*1),($dot[3]*1),($dot[4]*1),($dot[5]*1),($dot[6]*1),($dot[7]*1),($dot[8]*1),($dot[9]*1),($dot[10]*1),($dot[11]*1),($dot[12]*1),($dot[13]*1),($dot[14]*1),($dot[15]*1),($dot[16]*1),($dot[17]*1),($dot[18]*1),($dot[19]*1),($dot[20]*1),($dot[21]*1),($dot[22]*1),($dot[23]*1),($dot[24]*1),($dot[25]*1),($dot[26]*1),($dot[27]*1),($dot[28]*1),($dot[29]*1),($dot[30]*1),($dot[31]*1),($dot[32]*1),($dot[33]*1),($dot[34]*1),($dot[35]*1),($dot[36]*1));
$LightZ=sp38XYZ("Z",($dot[1]*1),($dot[2]*1),($dot[3]*1),($dot[4]*1),($dot[5]*1),($dot[6]*1),($dot[7]*1),($dot[8]*1),($dot[9]*1),($dot[10]*1),($dot[11]*1),($dot[12]*1),($dot[13]*1),($dot[14]*1),($dot[15]*1),($dot[16]*1),($dot[17]*1),($dot[18]*1),($dot[19]*1),($dot[20]*1),($dot[21]*1),($dot[22]*1),($dot[23]*1),($dot[24]*1),($dot[25]*1),($dot[26]*1),($dot[27]*1),($dot[28]*1),($dot[29]*1),($dot[30]*1),($dot[31]*1),($dot[32]*1),($dot[33]*1),($dot[34]*1),($dot[35]*1),($dot[36]*1));
//echo "XYZ:".$LightX.",".$LightY.",".$LightZ;
$Xn=$LightX/($LightX+$LightY+$LightZ);
$Yn=$LightY/($LightX+$LightY+$LightZ);
$Zn=$LightZ/($LightX+$LightY+$LightZ);
//echo "XnYnZn:".$Xn.",".$Yn.",".$Zn;
$Lxn=($LightX*100)/$LightY;
$Lzn=($LightZ*100)/$LightY;
$Lyn=($LightY*100)/$LightY;
//echo "<br>xyY:".$Lxn.",".$Lyn.",".$Lzn;
$Lx=$Lxn/($Lxn+$Lyn+$Lzn);
$Ly=$Lyn/($Lxn+$Lyn+$Lzn);
//echo "<br>xy:".$Lx.",".$Ly;
$x=$Xn/($Xn+$Yn+$Zn);
$y=$Yn/($Xn+$Yn+$Zn);
//echo "<br>nxy:".$x.",".$y;
//echo "<br>xy:".$dot[1].",".$dot[2];
$n=($dot[37]-0.332)/($dot[38]-0.1858);
$n2=($Lx-0.332)/($Ly-0.1858);
$Lux=$dot[39];
$cct= (-449*pow($n,3)) + (3525*pow($n,2)) - 6823.3*$n + 5520.33;
$cct2=(-449*pow($n2,3)) + (3525*pow($n2,2)) - 6823.3*$n2 + 5520.33;
$cct=round($cct,0);
$cct2=round($cct2,0);
//echo "<br>CCT:".$cct."cct2:".$cct2.",__Lux=".$Lux;
$dtime=time();
$dStr=substr($dtime,7,9);
$myFile ="data.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
//fwrite($fh, $p);
$viHead=$dot[4-3]." ".$dot[5-3]." ".$dot[6-3]." ".$dot[7-3]." ".$dot[8-3]." ".$dot[9-3]." ".$dot[10-3]." ".$dot[11-3]." ".$dot[12-3]." ".$dot[13-3]." ".$dot[14-3]." ".$dot[15-3]." ".$dot[16-3]." ".$dot[17-3]." ".$dot[18-3]." ".$dot[19-3]." ".$dot[20-3]." ".$dot[21-3]." ".$dot[22-3]." ".$dot[23-3]." ".$dot[24-3]." ".$dot[25-3]." ".$dot[26-3]." ".$dot[27-3]." ".$dot[28-3]." ".$dot[29-3]." ".$dot[30-3]." ".$dot[31-3]." ".$dot[32-3]." ".$dot[33-3]." ".$dot[34-3]." ".$dot[35-3]." ".$dot[36-3]." ".$dot[37-3]." ".$dot[38-3]." ".$dot[39-3];
fwrite($fh, $viHead);
fclose($fh);
sleep(0.5);
exec('echo . | "C:\Program Files\R\R-4.4.0\bin\Rscript" appi1MxNoUi.R');
sleep(0.5);
$cctFile = file("output.txt");
$stringCCT = implode($cctFile);
//echo $stringCCT;
?>
<table width="300" border="1" align="center">
<tr>
<td bgcolor="#cccccc"> CCT:</td><td><?php echo $cct;?></td><td bgcolor="#cccccc">Lux</td><td><?php echo (round($Lux,0));?></td></td></td>
</tr>
<tr>
<td bgcolor="#cccccc"> SSI:</td><td><?php echo $stringCCT;?></td>
</tr>
</table>
<?php
$contentD = file("D50data.txt");
$stringD = implode($contentD);
$dotT = explode("\t", $stringD);
//print_r($dot);
unlink('splineC.png');
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_line.php');
require_once ('../jpgraph/jpgraph_scatter.php');
require_once ('../jpgraph/jpgraph_mgraph.php');
require_once ('../jpgraph/jpgraph_regstat.php');
//echo "dot39:". floatval($dot[39]);
//print_r($dotT);
$xdata = array(380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550,560,570,580,590,600,610,620,630,640,650,660,670,680,690,700,710,720,730);
$ydata = array($dot[4-3]/$dot[22-3],$dot[5-3]/$dot[22-3],$dot[6-3]/$dot[22-3],$dot[7-3]/$dot[22-3],$dot[8-3]/$dot[22-3],$dot[9-3]/$dot[22-3],$dot[10-3]/$dot[22-3],$dot[11-3]/$dot[22-3],$dot[12-3]/$dot[22-3],$dot[13-3]/$dot[22-3],$dot[14-3]/$dot[22-3],$dot[15-3]/$dot[22-3],$dot[16-3]/$dot[22-3],$dot[17-3]/$dot[22-3],$dot[18-3]/$dot[22-3],$dot[19-3]/$dot[22-3],$dot[20-3]/$dot[22-3],$dot[21-3]/$dot[22-3],$dot[22-3]/$dot[22-3],$dot[23-3]/$dot[22-3],$dot[24-3]/$dot[22-3],$dot[25-3]/$dot[22-3],$dot[26-3]/$dot[22-3],$dot[27-3]/$dot[22-3],$dot[28-3]/$dot[22-3],$dot[29-3]/$dot[22-3],$dot[30-3]/$dot[22-3],$dot[31-3]/$dot[22-3],$dot[32-3]/$dot[22-3],$dot[33-3]/$dot[22-3],$dot[34-3]/$dot[22-3],$dot[35-3]/$dot[22-3],$dot[36-3]/$dot[22-3],$dot[37-3]/$dot[22-3],$dot[38-3]/$dot[22-3], floatval($dot[39-3])/$dot[22-3]);
$xdata2 = array(380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550,560,570,580,590,600,610,620,630,640,650,660,670,680,690,700,710,720,730);
$ydata2 = array($dotT[0],$dotT[1],$dotT[2], floatval($dotT[3]),$dotT[4],$dotT[5],$dotT[6],$dotT[7],$dotT[8],$dotT[9],$dotT[10],$dotT[11],$dotT[12],$dotT[13],$dotT[14],$dotT[15],$dotT[16],$dotT[17],$dotT[18],$dotT[19],$dotT[20],$dotT[21],$dotT[22],$dotT[23],$dotT[24],$dotT[25],$dotT[26],$dotT[27],$dotT[28],$dotT[29],$dotT[30],$dotT[31],$dotT[32],$dotT[33],$dotT[34],floatval($dotT[35]));
// Get the interpolated values by creating
// a new Spline object.
$spline = new Spline($xdata,$ydata);
$spline2 = new Spline($xdata2,$ydata2);
// For the new data set we want 40 points to
// get a smooth curve.
list($newx,$newy) = $spline->Get(50);
list($newx2,$newy2) = $spline2->Get(50);
//echo "<br>nex2:".$newx2;
//print_r($newx2);
// Create the graph
$g = new Graph(380,250);
$g->SetMargin(30,20,40,30);
//$g->title->Set("Curve C");
$g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$g->subtitle->Set('Test in Green (D50 in Blue)');
//$g->subtitle->SetColor('darkred');
$g->SetMarginColor('lightgreen');
//$g->img->SetAntiAliasing();
// We need a linlin scale since we provide both
// x and y coordinates for the data points.
$g->SetScale('linlin');
// We want 1 decimal for the X-label
$g->xaxis->SetLabelFormat('%1.1f');
// We use a scatterplot to illustrate the original
// contro points.
$splot = new ScatterPlot($ydata,$xdata);
$splot2 = new ScatterPlot($ydata2,$xdata2);
//
$splot->mark->SetFillColor('[email protected]');
$splot->mark->SetColor('[email protected]');
$splot2->mark->SetFillColor('[email protected]');
$splot2->mark->SetColor('[email protected]');
// And a line plot to stroke the smooth curve we got
// from the original control points
$lplot = new LinePlot($newy,$newx);
$g->Add($lplot);
$lplot->SetColor('darkgreen');
$lplot2 = new LinePlot($newy2,$newx2);
$g->Add($lplot2);
$lplot2->SetColor('[email protected]');
$g->Add($splot);
$g->Add($splot2);
$g->Stroke('splineC.png');
?>
<table border="1" align='center'>
<tr>
<td><img src="splineC.png?nocache=<?php echo time(); ?>"></td>
</tr>
</table>
<br>
<tr><td>
<a href="rankLight.php?company=<?php echo $company;?>">List.</a>
</td></tr>
<br>
<br><br>
<tr>
<td align="center"><font size="-2"> © <a href="mailto:[email protected]">Fred Kuo</a>, 2024. All rights reserved.<br><a href="http://www.pbn.com.tw/wordpress">Read more.</a><br>
</td>
</tr>
</body>
</html>