diff --git a/misc/controller/php/channel.php b/misc/controller/php/channel.php deleted file mode 100644 index f820fdb..0000000 --- a/misc/controller/php/channel.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Copyright (c) 2010, The volkszaehler.org project - * @package controller - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - */ -/* - * This file is part of volkzaehler.org - * - * volkzaehler.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * volkzaehler.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with volkszaehler.org. If not, see . - */ - -header('Content-type: application/json'); - -define('FILE', 'channels.csv'); - -$methodMapping = array( - 'POST' => 'add', - 'DELETE' => 'delete', - 'GET' => 'get' -); - -$channels = array(); - -$operation = (isset($_GET['operation'])) ? $_GET['operation'] : $methodMapping[$_SERVER['REQUEST_METHOD']]; - -// create file if it doesnt exist -touch(FILE); - -// read channels -$fd = fopen(FILE, 'r') or die('cant open file'); -while (($data = fgetcsv($fd, 100, ';')) !== FALSE) { - $channels[] = array_combine(array('uuid', 'type', 'port', 'last_value', 'last_timestamp'), $data); -} -fclose($fd); - -if ($operation == 'add') { - // TODO check for duplicate uuid - // TODO validate input - $channels[] = array( - 'uuid' => $_GET['uuid'], - 'type' => $_GET['type'], - 'port' => $_GET['port'], - 'value' => '', - 'timestamp' => '' - ); -} -elseif ($operation == 'delete') { - $channels = array_filter($channels, function($channel) { - return $channel['uuid'] != $_GET['uuid']; - }); -} - -// save channels -if (in_array($operation, array('delete', 'add'))) { - $fd = fopen(FILE, 'w') or die('cant open file'); - foreach ($channels as $channel) { - fputcsv($fd, $channel, ';'); - } - fclose($fd); -} - -// return all channels as JSON -echo json_encode($channels); - -?> \ No newline at end of file diff --git a/misc/controller/php/log.php b/misc/controller/php/log.php deleted file mode 100644 index 084e709..0000000 --- a/misc/controller/php/log.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Copyright (c) 2010, The volkszaehler.org project - * @package controller - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - */ -/* - * This file is part of volkzaehler.org - * - * volkzaehler.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * volkzaehler.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with volkszaehler.org. If not, see . - */ - -if (php_sapi_name() != 'cli') { - header('HTTP/1.1 405 Method Not Allowed'); - die(); -} - -// read channels -$fd = fopen(FILE, 'r') or die('cant open file'); -while (($data = fgetcsv($fd, 100, ';')) !== FALSE) { - $channels[] = array_combine(array('uuid', 'type', 'port', 'last_value', 'last_timestamp'), $data); -} -fclose($fd); - -// log data -foreach ($channels as $channel) { - // TODO log data according to type and port -} - -// save channels -$fd = fopen(FILE, 'w') or die('cant open file'); -foreach ($channels as $channel) { - fputcsv($fd, $channel, ';'); -} -fclose($fd); - -?> \ No newline at end of file diff --git a/misc/controller/vzlogger/README b/misc/controller/vzlogger/README new file mode 100644 index 0000000..4d02c16 --- /dev/null +++ b/misc/controller/vzlogger/README @@ -0,0 +1,7 @@ +vzlogger is a tiny command line utility to log sensors/meters against the volkszaehler.org middleware. +It's designed to run linux machines as well as embedded systems (routers, etc..). + +Feel free to add your own hardware ;) + +More information are available in our wiki: +http://wiki.volkszaehler.org/software/controller/vzlogger