<?php

$ct_flag_file_path = "/www/gps_socket/backhoeCt/ct_start_flag.txt";
$ct_start_file_name = "/www/gps_socket/backhoeCt/ct_start_filename.txt";

$ct_flag = file_get_contents($ct_flag_file_path);
$ct_file_name = explode("," , file_get_contents($ct_start_file_name));

if($ct_file_name[0])
{
	$view_flag = 1;
	$read_file = "/www/gps_socket/backhoeCt/data/" .$ct_file_name[0];
	$ct_start_date = substr($ct_file_name[0],0,4) ."-" .substr($ct_file_name[0],4,2) ."-" .substr($ct_file_name[0],6,2) ." " .substr($ct_file_name[0],8,2) .":" .substr($ct_file_name[0],10,2) .":" .substr($ct_file_name[0],12,2);
	$ct = exec('/bin/cat ' .$read_file .' | wc -l');
}



$ct_file_azimuth = ($ct_file_name[3])?number_format($ct_file_name[3], 2, '.', ''):"";

// ===============================================
// GD処理準備
// ===============================================
$x_size = 300;
$y_size = 100;

$img = imagecreatetruecolor($x_size,$y_size);
$font1 = "/www/ansys/config/fonts/ipam.ttf";

$ct_data = file_get_contents("ct.txt");

// 使用色の準備
$Black = imagecolorallocate($img, 0,0,0);
$White = imagecolorallocate($img, 255, 255, 255);
$Red =  imagecolorallocate($img, 255, 0, 0);
$Green =  imagecolorallocate($img, 0, 128, 0);
$Blue = imagecolorallocate($img, 0, 0, 255);
$LightBlue = imagecolorallocate($img, 0, 191, 255);
$Orange = imagecolorallocate($img, 255, 165, 0);

imagefilledrectangle($img,0,0,$x_size,$y_size,$White);

if($ct_flag && $view_flag)
{
//		$datetime = date("Y-m-d H:i:s" ,time());
//		$ct = 1;方位角
	ImageTTFText ($img, 11, 0,10, 20, $Black, $font1, "カウント開始日時:" .$ct_start_date);
	ImageTTFText ($img, 11, 0,10, 45, $Black, $font1, "開始方位　　　　:" .$ct_file_azimuth);
	ImageTTFText ($img, 11, 0,10, 70, $Black, $font1, "カウント数　　　:   " .$ct);
}

header('Content-Type: image/png');

imagepng($img);
imagedestroy($img);
?>
