www/getispindellog.php

Wed, 04 Mar 2020 10:48:21 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 04 Mar 2020 10:48:21 +0100
changeset 622
39902353b159
parent 601
112c278be803
child 627
f1a7c14d5601
permissions
-rw-r--r--

Workaround for hang during startup. Changed order of displayed fields on the yeast tab. Tooltip text changes. More decimals on the checklist for misc ingredients. More decimals for the starter on product print.

<?php

require_once('config.php');

if (isset($_GET["code"]))
	$code = $_GET["code"] . ' ' . $_GET["name"];
else
	$code = "TB0091 Kwik";

$filename = 'log/ispindel/' . $code . '.log';
if (! file_exists($filename)) {
        header("Content-type: application/json");
        echo '{}';
        exit;
}


/*
 * 2014-11-15 18:39:12,TEMPERATURE,PLATO,SG,BATTERY,ANGLE,INVERVAL,UUID
 *          |              |         |    |    |
 * datetime +              |         |    |    |
 * temperature ------------+         |    |    |
 * density plato --------------------+    |    |
 * density sg ----------------------------+    |
 * battery ------------------------------------+
 */
$handle = @fopen($filename, "r");
if ($handle) {
	$lines = 0;
	while (($buffer = fgets($handle, 4096)) !== false) {

		$buffer = preg_replace( "/\r|\n/", "", $buffer);
		$row = explode(",", $buffer);
		$lines++;

		$logs[] = array(
			'date' => $row[0],
			'temperature' => $row[1],
			'plato' => $row[2],
			'sg' => $row[3],
			'battery' => $row[4]
		);
	}
	if (!feof($handle)) {
		echo "Error: unexpected fgets() fail\n";
	}
	fclose($handle);
}
header("Content-type: application/json");
echo json_encode($logs);

mercurial