. */ namespace Volkszaehler\View\JSON; /** * JSON channel view * * also used for data * * @author Steffen Vogel * @package channel */ class JSONChannelView extends JSONView { public function add(\Volkszaehler\Model\Channel $obj, array $data = NULL) { $channel['uuid'] = (string) $obj->getUuid(); $channel['indicator'] = $obj->getIndicator(); $channel['unit'] = $obj->getUnit(); $channel['name'] = $obj->getName(); $channel['description'] = $obj->getDescription(); // TODO adapt to new indicator style if (is_subclass_of($obj, '\Volkszaehler\Model\Channel\Meter')) { $channel['resolution'] = (int) $obj->getResolution(); $channel['cost'] = (float) $obj->getCost(); } if (isset($data)) { $channel['data'] = array(); foreach ($data as $reading) { $channel['data'][] = array($reading['timestamp'], $reading['value'], $reading['count']); } } $this->json['channels'][] = $channel; } } ?>