<?php
//var_dump($_GET);





$sensor=$_GET['sensor'];
$number=$_GET['positionnumber'];
$shuter=$_GET['shutterTime'];

set_time_limit(0);
ob_end_clean();//清空（擦除）缓冲区并关闭输出缓冲
ob_implicit_flush(1);//将打开或关闭绝对（隐式）刷送。绝对（隐式）刷送将导致在每次输出调用后有一次刷送操作，以便不再需要对 flush() 的显式调用
system("sudo gpio mode 1 out");
system("sudo gpio write 1 1");
 system("sudo killall Mywathdog.sh");
system("sudo killall TowerOptoSifAndSpectral");
system("sudo pkill shutter_calibrate");


$cmd = 'sudo /home/pi/bin/shutter_calibrate '.$sensor." ".$number.' '.$shuter;
echo $cmd.'<br>';

while(@ ob_end_flush());

$proc = popen($cmd, 'r');


while(!feof($proc)){
    echo fread($proc, 4096);
    @ flush();
}
echo "<br>";
echo "finish";

echo '<a href=/config/position.html>回到首页</a>';

$file=fopen('/home/data/test.csv','r');

while ($data = fgetcsv($file)) { //每次读取CSV里面的一行内容
//print_r($data); //此为一个数组，要获得每一个数据，访问数组下标即可
    $goods_list[] = $data;
}

//var_dump($goods_list[0]);
$hang=count($goods_list);
$x=$goods_list[0][2];
$y=$goods_list[0][1];;
for($i=1;$i<$hang;$i++)
{
    $x=$x.','.$goods_list[$i][2];
    $y=$y.','.$goods_list[$i][1];
}
echo '<div id="main" style="width: 600px;height:400px;"></div> ';

echo ' <script src="/config/js/echarts.js"></script>';
echo '<script>var xx=['.$x.']; var yy=['.$y.']; </script>';
echo '<script src="/config/js/printercaliresult.js"></script>';