added documentation

This commit is contained in:
Steffen Vogel 2010-07-22 10:32:51 +02:00
parent b1a17a044f
commit dcad7f6c80
37 changed files with 318 additions and 207 deletions

View file

@ -1,7 +1,7 @@
<?php
/**
* doctrine cli configuration and bootstrapping
*
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package doctrine
* @copyright Copyright (c) 2010, The volkszaehler.org project
@ -58,7 +58,7 @@ $cli->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
@ -76,3 +76,5 @@ $cli->addCommands(array(
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
));
$cli->run();
?>

View file

@ -1,9 +1,10 @@
<?php
/**
* backend bootstrapping entrypoint
*
*
* @author Steffen Vogel <info@steffenvogel.de>
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org

View file

@ -26,70 +26,72 @@ use Volkszaehler\Util;
/**
* data controller
*
*
* @author Steffen Vogel <info@steffenvogel.de>
* @todo call via redirect from Controller\Channel
*/
class Data extends Controller {
/**
* @todo authentification/indentification
*/
public function get() {
// TODO use uuids for groups or channels
$ids = explode(',', trim($this->view->request->getParameter('ids')));
$q = $this->em->createQuery('SELECT c FROM Volkszaehler\Model\Channel c WHERE c.id IN (' . implode(', ', $ids) . ')');
$channels = $q->execute();
$from = ($this->view->request->getParameter('from')) ? (int) $this->view->request->getParameter('from') : NULL;
$to = ($this->view->request->getParameter('to')) ? (int) $this->view->request->getParameter('to') : NULL;
$groupBy = ($this->view->request->getParameter('groupBy')) ? $this->view->request->getParameter('groupBy') : NULL; // get all readings by default
foreach ($channels as $channel) {
$interpreter = $channel->getInterpreter($this->em);
$this->view->add($channel, $interpreter->getValues($from, $to, $groupBy));
}
}
/**
*
*
*/
public function add() {
$ucid = $this->view->request->getParameter('ucid');
$channel = $this->em->getRepository('Volkszaehler\Model\Channel\Channel')->findOneBy(array('uuid' => $ucid));
$value = (float) $this->view->request->getParameter('value');
$ts = (int) $this->view->request->getParameter('timestamp');
if ($ts == 0) {
$ts = microtime(TRUE) * 1000;
}
$data = new \Volkszaehler\Model\Data($channel, $value, $ts);
$channel->addData($data);
$this->em->persist($data);
$this->em->flush();
}
/**
* prune data from database
*
*
* @todo authentification/indentification
*/
public function delete() {
$dql = 'DELETE FROM \Volkszaehler\Model\Data WHERE channel_id = ' . $this->id;
if ($this->view->request->getParameter('from')) {
$dql .= ' && timestamp > ' . (int) $this->view->request->getParameter('from');
}
if ($this->view->request->getParameter('to')) {
$dql .= ' && timestamp < ' . $this->view->request->getParameter('to');
}
$q = $em->createQuery($dql);
$q->execute();
}
}
}
?>

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -31,6 +32,7 @@ use Volkszaehler\Util;
*
* this class acts as a frontcontroller to route incomming requests
*
* @package default
* @author Steffen Vogel <info@steffenvogel.de>
*/
class Dispatcher {

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package data
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -22,7 +23,8 @@
namespace Volkszaehler\Interpreter;
/**
*
*
* @package data
* @author Steffen Vogel <info@steffenvogel.de>
*
*/
@ -35,16 +37,16 @@ interface InterpreterInterface {
/**
* interpreter superclass for all interpreters
*
*
* @author Steffen Vogel <info@steffenvogel.de>
*
*/
abstract class Interpreter implements InterpreterInterface {
protected $channel;
protected $em;
/**
*
*
* @param $channel
* @param $em
*/
@ -52,9 +54,9 @@ abstract class Interpreter implements InterpreterInterface {
$this->channel = $channel;
$this->em = $em;
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
* @param mixed $groupBy
@ -86,7 +88,7 @@ abstract class Interpreter implements InterpreterInterface {
case 'minute':
$sqlGroupBy = 'YEAR(' . $ts . '), DAYOFYEAR(' . $ts . '), HOUR(' . $ts . '), MINUTE(' . $ts . ')';
break;
case 'second':
$sqlGroupBy = 'YEAR(' . $ts . '), DAYOFYEAR(' . $ts . '), HOUR(' . $ts . '), MINUTE(' . $ts . '), SECOND(' . $ts . ')';
break;
@ -104,11 +106,11 @@ abstract class Interpreter implements InterpreterInterface {
$sql = 'SELECT';
$sql .= ($sqlGroupBy === FALSE) ? ' timestamp, value' : ' MAX(timestamp) AS timestamp, SUM(value) AS value, COUNT(timestamp) AS count';
$sql .= ' FROM data WHERE channel_id = ' . (int) $this->channel->getId();
if (isset($from)) {
$sql .= ' && timestamp > ' . $from;
}
if (isset($to)) {
$sql .= ' && timestamp < ' . $to;
}
@ -116,21 +118,21 @@ abstract class Interpreter implements InterpreterInterface {
if ($sqlGroupBy !== FALSE) {
$sql .= ' GROUP BY ' . $sqlGroupBy;
}
$sql .= ' ORDER BY timestamp DESC';
$rsm = new \Doctrine\ORM\Query\ResultsetMapping;
$rsm->addScalarResult('timestamp', 'timestamp');
$rsm->addScalarResult('value', 'value');
if ($sqlGroupBy) {
$rsm->addScalarResult('count', 'count');
}
$query = $this->em->createNativeQuery($sql, $rsm);
$result = $query->getResult();
$totalCount = count($result);
if (is_int($groupBy) && $groupBy < $totalCount) { // return $groupBy values
$packageSize = floor($totalCount / $groupBy);
$packageCount = $groupBy;

View file

@ -1,7 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package channel
* @package data
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -24,15 +24,16 @@ namespace Volkszaehler\Interpreter;
/**
* meter interpreter
*
*
* @package data
* @author Steffen Vogel (info@steffenvogel.de)
*
*/
class Meter extends Interpreter {
/**
* calculates the consumption for interval speciefied by $from and $to
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
@ -48,15 +49,15 @@ class Meter extends Interpreter {
return $result['count'] / $this->resolution / 1000; // returns Wh
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
public function getMin($from = NULL, $to = NULL) {
$data = $this->getData($from, $to);
$min = current($data);
foreach ($data as $reading) {
if ($reading['value '] < $min['value']) {
@ -65,15 +66,15 @@ class Meter extends Interpreter {
}
return $min;
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
public function getMax($from = NULL, $to = NULL) {
$data = $this->getData($from, $to);
$min = current($data);
foreach ($data as $reading) {
if ($reading['value '] > $min['value']) {
@ -82,44 +83,44 @@ class Meter extends Interpreter {
}
return $min;
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
* @todo calculate timeinterval if no params were given
*/
public function getAverage($from = NULL, $to = NULL) {
public function getAverage($from = NULL, $to = NULL) {
return $this->getConsumption($from, $to) / ($to - $from) / 1000; // return W
}
/**
* just a passthru of raw data
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
public function getPulses($from = NULL, $to = NULL, $groupBy = NULL) {
return parent::getData($from, $to, $groupBy);
}
/**
* raw pulses to power conversion
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
public function getValues($from = NULL, $to = NULL, $groupBy = NULL) {
$pulses = parent::getData($from, $to, $groupBy);
$pulseCount = count($pulses);
for ($i = 1; $i < $pulseCount; $i++) {
$delta = $pulses[$i]['timestamp'] - $pulses[$i-1]['timestamp'];
$pulses[$i]['timestamp'] -= $delta/2;
$pulses[$i]['value'] *= 3600000/(($this->channel->getResolution() / 1000) * $delta); // TODO untested
}
return $pulses; // returns W
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package channel
* @package data
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -24,53 +24,54 @@ namespace Volkszaehler\Interpreter;
/**
* sensor interpreter
*
*
* @package data
* @author Steffen Vogel <info@steffenvogel.de>
*/
class Sensor extends Interpreter {
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*/
public function getValues($from = NULL, $to = NULL, $groupBy = NULL) {
$data = parent::getData($from, $to, $groupBy);
array_walk($data, function(&$reading) {
$reading['value'] /= $reading['count']; // calculate average (ungroup the sql sum() function)
});
return $data;
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*
*
* @todo untested
*/
public function getMin($from = NULL, $to = NULL) {
return $this->dbh->query('SELECT value, timestamp FROM data WHERE channel_id = ' . (int) $this->id . self::buildFilterTime($from, $to) . ' ORDER BY value ASC', 1)->current();
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*
*
* @todo untested
*/
public function getMax($from = NULL, $to = NULL) { // TODO untested
return $this->dbh->query('SELECT value, timestamp FROM data WHERE channel_id = ' . (int) $this->id . self::buildFilterTime($from, $to) . ' ORDER BY value DESC', 1)->current();
}
/**
*
*
* @param integer $from timestamp in ms since 1970
* @param integer $to timestamp in ms since 1970
*
*
* @todo untested
*/
public function getAverage($from = NULL, $to = NULL) { // TODO untested

View file

@ -1,7 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package channel
* @package data
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -23,15 +23,16 @@
namespace Volkszaehler\Logger;
/**
* logger for the Flukso.net api
*
* logger for the Flukso.net API
*
* @package data
* @link http://www.flukso.net
* @link http://github.com/icarus75/flukso
* @author Steffen Vogel <info@steffenvogel.de>
* @todo to be implemented
*/
class Flukso implements Logger {
}
?>

View file

@ -1,7 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package channel
* @package data
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -28,6 +28,7 @@ use Volkszaehler\View\HTTP;
* interface for parsing diffrent logging APIs (google, flukso etc..)
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package data
* @todo to be implemented
*/
interface Logger {

View file

@ -28,7 +28,8 @@ use Doctrine\Common\Collections\ArrayCollection;
* Channel entity
*
* @author Steffen Vogel <info@steffenvogel.de>
*
* @package channel
*
* @Entity
* @Table(name="channels")
*/
@ -38,7 +39,7 @@ class Channel extends Entity {
/** @Column(type="string") */
protected $description;
/** @Column(type="string") */
protected $indicator;
@ -46,13 +47,13 @@ class Channel extends Entity {
* @OneToMany(targetEntity="Data", mappedBy="channel"), cascade={"remove"}
*/
protected $data = NULL;
/** @Column(type="integer") */
protected $resolution;
/** @Column(type="decimal", precision="5", scale="2") */
protected $cost;
/**
* indicator => interpreter, unit mapping
*/
@ -64,21 +65,21 @@ class Channel extends Entity {
'pressure' => array('sensor', 'hPa'),
'humidity' => array('sensor', '%')
);
/**
* constructor
*/
public function __construct($indicator) {
parent::__construct();
if (!in_array($indicator, self::$indicators)) {
throw new \InvalidArgumentException($indicator . ' is no known indicator');
}
$this->indicator = $indicator;
$this->data = new ArrayCollection();
}
/**
* add a new data to the database
* @todo move to Logger\Logger?
@ -86,7 +87,7 @@ class Channel extends Entity {
public function addData(\Volkszaehler\Model\Data $data) {
$this->data->add($data);
}
/**
* obtain channels data interpreter to calculate statistical information
*/
@ -97,7 +98,7 @@ class Channel extends Entity {
}
return new $interpreterClassName($this, $em);
}
/**
* getter & setter
*/
@ -111,4 +112,6 @@ class Channel extends Entity {
public function setResolution($resolution) { $this->resolution = $resolution; }
public function getCost() { return $this->cost; }
public function setCost($cost) { $this->cost = $cost; }
}
}
?>

View file

@ -26,16 +26,17 @@ use Doctrine\Common\Collections\ArrayCollection;
/**
* Data entity
*
*
* @author Steffen Vogel <info@steffenvogel.de>
*
* @package data
*
* @Entity
* @Table(name="data")
*/
class Data {
/**
* ending timestamp of period in ms since 1970
*
*
* @Id
* @Column(type="bigint")
*/
@ -53,13 +54,13 @@ class Data {
* @JoinColumn(name="channel_id", referencedColumnName="id")
*/
protected $channel;
public function __construct(Channel\Channel $channel, $value, $timestamp) {
$this->channel = $channel;
$this->value = $value;
$this->timestamp = $timestamp;
}
/**
* setter & getter
*/

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -25,9 +26,10 @@ use Volkszaehler\Util;
/**
* entity superclass for all models with database persistance
*
*
* @author Steffen Vogel <info@steffenvogel.de>
*
* @package default
*
* @MappedSuperclass
*/
abstract class Entity {
@ -37,17 +39,19 @@ abstract class Entity {
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/** @Column(type="string", length=36) */
protected $uuid;
public function __construct() {
$this->uuid = Util\Uuid::mint();
}
/**
* getter & setter
*/
public function getId() { return $this->id; } // read only
public function getUuid() { return $this->uuid; } // read only
}
}
?>

View file

@ -26,19 +26,20 @@ use Doctrine\Common\Collections\ArrayCollection;
/**
* Group entity
*
*
* @author Steffen Vogel <info@steffenvogel.de>
*
* @package group
*
* @Entity
* @Table(name="groups")
*/
class Group extends Entity {
/** @Column(type="string") */
protected $name;
/** @Column(type="string") */
protected $description;
/**
* @ManyToMany(targetEntity="Channel")
* @JoinTable(name="groups_channel",
@ -47,7 +48,7 @@ class Group extends Entity {
* )
*/
protected $channels = NULL;
/**
* @ManyToMany(targetEntity="Group")
* @JoinTable(name="groups_groups",
@ -62,11 +63,11 @@ class Group extends Entity {
*/
public function __construct() {
parent::__construct();
$this->channels = new ArrayCollection();
$this->children = new ArrayCollection();
}
/**
* getter & setter
*/

View file

@ -28,6 +28,7 @@ namespace Volkszaehler\Util;
*
* namespace is mapped to the filesystem structure
*
* @package util
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php Lesser GNU Public License
*/
@ -209,4 +210,5 @@ class ClassLoader {
return NULL;
}
}
}
?>

View file

@ -25,6 +25,7 @@ namespace Volkszaehler\Util;
/**
* static configuration class for loading and storing the configuration to the disk
*
* @package util
* @author Steffen Vogel <info@steffenvogel.de>
*/
class Configuration {

View file

@ -27,6 +27,7 @@ use Doctrine\DBAL\Logging;
/**
* static debugging class
*
* @package util
* @author Steffen Vogel <info@steffenvogel.de>
*/
class Debug implements Logging\SQLLogger {
@ -152,4 +153,4 @@ class Debug implements Logging\SQLLogger {
public function getMessages() { return $this->messages; }
}
?>
?>

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package util
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -27,6 +28,7 @@ class Exception extends \Exception {}
* DrUUID RFC4122 library for PHP5
*
* @author J. King
* @package util
* @link http://jkingweb.ca/code/php/lib.uuid/
* @license Licensed under MIT license
*
@ -326,3 +328,6 @@ class UUID {
return base64_decode(self::$randomSource->GetRandom($bytes,0)); // straight binary mysteriously doesn't work, hence the base64
}
}
?>

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -25,12 +26,13 @@ use Volkszaehler\View\HTTP;
use Volkszaehler\View;
use Volkszaehler\Util;
/*
/**
* CSV view
*
* also used for data
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package default
*/
abstract class CSV extends View\View {
protected $csv = array();

View file

@ -24,10 +24,14 @@ namespace Volkszaehler\View\CSV;
/**
* CSV data view
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package data
*/
class Data extends CSV {
public function add($obj, $data) {
$this->csv = array_merge($this->csv, $data);
}
}
}
?>

View file

@ -28,6 +28,7 @@ namespace Volkszaehler\View\HTTP;
* also used for data
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package http
*/
class Request {
protected $headers;
@ -67,3 +68,5 @@ class Request {
return (isset($this->parameters[$method][$name])) ? $this->parameters[$method][$name] : NULL;
}
}
?>

View file

@ -1,12 +1,7 @@
<?php
/**
* HTTP request
*
* also used for data
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package http
* @author Steffen Vogel <info@steffenvogel.de>
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -28,7 +23,12 @@
namespace Volkszaehler\View\HTTP;
/**
* HTTP request
*
* simple class to control the output buffering
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package http
*/
class Response {
protected $headers = array();
@ -113,3 +113,4 @@ class Response {
}
}
?>

View file

@ -28,6 +28,7 @@ namespace Volkszaehler\View\JSON;
* also used for data
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package channel
*/
class Channel extends JSON {

View file

@ -26,6 +26,7 @@ namespace Volkszaehler\View\JSON;
* JSON group view
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package group
*/
class Group extends JSON {
@ -45,3 +46,6 @@ class Group extends JSON {
$this->json['groups'][] = $group;
}
}
?>

View file

@ -1,11 +1,7 @@
<?php
/**
* JSON view
*
* also used for data
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @author Steffen Vogel <info@steffenvogel.de>
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -31,6 +27,14 @@ use Volkszaehler\View\HTTP;
use Volkszaehler\View;
use Volkszaehler\Util;
/**
* JSON view
*
* also used for data
*
* @package default
* @author Steffen Vogel <info@steffenvogel.de>
*/
abstract class JSON extends View\View {
protected $json = array();

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -30,6 +31,7 @@ require_once \Volkszaehler\BACKEND_DIR . '/lib/vendor/JpGraph/jpgraph_date.php';
*
* this view uses the JpGraph PHP5 plotting library
*
* @package default
* @author Steffen Vogel <info@steffenvogel.de>
* @link http://jpgraph.net/
* @todo add caching

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -27,6 +28,7 @@ use Volkszaehler\Util;
/**
* superclass for all view classes
*
* @package default
* @author Steffen Vogel <info@steffenvogel.de>
*
*/
@ -73,4 +75,6 @@ abstract class View {
public function addDebug(Util\Debug $debug) {
}
}
}
?>

View file

@ -30,6 +30,7 @@ use Volkszaehler\View\HTTP;
* also used for data
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package channel
*/
class Channel extends XML {
@ -74,4 +75,6 @@ class Channel extends XML {
parent::render();
}
}
}
?>

View file

@ -28,6 +28,7 @@ use Volkszaehler\View\HTTP;
* XML group view
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package group
*/
class Group extends XML {
protected $xml;
@ -54,4 +55,6 @@ class Group extends XML {
parent::render();
}
}
}
?>

View file

@ -1,9 +1,7 @@
<?php
/**
* XML view
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @author Steffen Vogel <info@steffenvogel.de>
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org
@ -28,6 +26,12 @@ use Volkszaehler\View\HTTP;
use Volkszaehler\View;
use Volkszaehler\Util;
/**
* XML view
*
* @author Steffen Vogel <info@steffenvogel.de>
* @package default
*/
abstract class XML extends View\View {
protected $xmlDoc;
@ -107,4 +111,4 @@ abstract class XML extends View\View {
}
}
?>
?>

View file

@ -1,12 +1,13 @@
<?php
/**
* configuration template
*
*
* you should use this file to obtain your custom configuration
* new parameters should be documented
*
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @author Steffen Vogel <info@steffenvogel.de>
* @package default
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This file is part of volkzaehler.org

View file

@ -1,22 +1,25 @@
<?php
/*
* Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
/**
* a simple test for Volkszaehler\Util\Configuration
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (either version 2 or
* version 3) as published by the Free Software Foundation.
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tests
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*
* This program is distributed in the hope that it will be useful,
* 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
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
use Volkszaehler\Util;

View file

@ -1,6 +1,6 @@
<?php
/*
/**
* That's the volkszaehler.org configuration file.
* Please take care of the following rules:
* - you are allowed to edit it by your own

View file

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (either version 2 or
# version 3) as published by the Free Software Foundation.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# For more information on the GPL, please go to:
# http://www.gnu.org/copyleft/gpl.html
#
# This is simple bash script to update the project documentation
# based on PHPDocumentor. It's used to be invoked by post-commit hooks
# of GitHub or the release script.
#
# change directory
cd /var/www/vz/github/
# update git
git pull
cd /var/www/vz/
# update dokumentation
phpdoc/phpdoc --directory github --target docs \
--title "volkszaehler.org Documentation" \
--output HTML:frames:phpedit \
--ignoresymlinks \
--ignore backend/lib/vendor/,backend/lib/Model/Proxies/

View file

@ -1,26 +1,25 @@
<?php
/*
* Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (either version 2 or
* version 3) as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
*/
/*
/**
* simple script to import demo pulses
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.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 <http://www.gnu.org/licenses/>.
*/
$sql = '';
@ -40,32 +39,32 @@ $fd = fopen('/home/steffen/Desktop/testdaten_nicht_veroeffentlichen.sql', 'r');
if ($fd) {
while (!feof($fd)) {
$line = fgets($fd);
// $matches index 1 2 3 4 5 6 7 8
if (preg_match('/^\((\d), \'(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\', (\d)/', $line, $matches)) {
$ts = mktime($matches[5], $matches[6], $matches[7], $matches[3], $matches[4], $matches[2]) * 1000;
$value = $matches[8];
$channel = $mapping[$matches[1]];
if ($ts > 0) {
$pulses[] = '(' . $channel . ', ' . $ts . ', ' . $value . ')';
}
if (count($pulses) % 1000 == 0) {
$sql = 'INSERT INTO data (channel_id, timestamp, value) VALUES ' . implode(', ', $pulses);
if (!mysql_query($sql)){
echo mysql_error();
}
echo 'Rows inserted: ' . mysql_affected_rows() . '<br />';
flush();
$pulses = array();
}
}
};
fclose($fd);
}

View file

@ -1,48 +1,46 @@
<?php
/*
* Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (either version 2 or
* version 3) as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
*/
/*
/**
* simple script to import demo pulses
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
* @todo adapt to doctrine dal or use native mysql
*
* 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 <http://www.gnu.org/licenses/>.
*/
// TODO adapt to doctrine dal or use native mysql
$sql = '';
$fd = fopen('../docs/developer/pulses.dummy.copy', 'r');
if ($fd) {
while (!feof($fd)) {
$buffer = explode("\t", fgets($fd));
$ts = parsePgSqlTimestamp($buffer[0]);
if ($ts > 0)
$pulses[] = '(' . (int) ($buffer[2] + 1) . ', ' . $ts . ', 1)';
};
fclose($fd);
$sql = 'INSERT INTO data (channel_id, timestamp, value) VALUES ' . implode(', ', $pulses);
$dbh->execute($sql);
echo 'Imported rows: ' . $dbh->affectedRows();
}
else {
@ -52,7 +50,7 @@ else {
function parsePgSqlTimestamp($timestamp) {
$unix = strtotime($timestamp);
$ms = substr($timestamp, strrpos($timestamp, '.') + 1);
return $unix + $ms/pow(10, strlen($ms));
}

View file

@ -1,22 +1,27 @@
<?php
/*
* Copyright (c) 2010 by Justin Otherguy <justin@justinotherguy.org>
/**
* install script
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (either version 2 or
* version 3) as published by the Free Software Foundation.
* for creating/updating of the configuration/database
*
* This program is distributed in the hope that it will be useful,
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.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
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
?>
@ -37,7 +42,7 @@ switch (@$_GET['step']) {
case '1':
echo 'bla';
break;
default:
echo '<p>welcome to the installation of your volkszaehler backend!</p>
<p>lets proceed with the <a href="?step=1">next step</a></p>';