move files to data folder
--- a/calls.json.php
+++ b/calls.json.php
@@ -1,35 +1,8 @@
<?php
-function view($sensorID) {
- $data = Array("sensorID" => $sensorID,
- );
- $timefrom = 1;
- $timeto = 1;
- $years = $this->Sensor_model->getSensorDataYears($sensorID, $timefrom, $timeto);
- foreach ($years as $year) {
- $yearsItem[] = Array("title" => $year['year'], "link" => "#",
- "onclick" => "getData('$sensorID'," . mktime(0, 0, 0, 1, 1, $year['year']) . "," . mktime(0, 0, 0, 12, 31, $year['year']) . ");");
- }
- $months = $this->Sensor_model->getSensorDataMonths($sensorID, $timefrom, $timeto);
- foreach ($months as $month) {
- $monthsItem[] = Array("title" => date("F", mktime(0, 0, 0, $month['month'], 10)) . ' ' . $month['year'], "link" => "#",
- "onclick" => "getData('$sensorID'," . mktime(0, 0, 0, $month['month'], 1, $month['year']) . "," . strtotime("+1 month", mktime(0, 0, 0, $month['month'], 1, $month['year'])) . ");");
- }
- $days = $this->Sensor_model->getSensorDataDays($sensorID, $timefrom, $timeto);
- foreach ($days as $day) {
- $daysItem[] = Array("title" => date("jS F", mktime(0, 0, 0, $day['month'], $day['day'])), "link" => "#",
- "onclick" => "getData('$sensorID'," . mktime(0, 0, 0, $day['month'], $day['day'], $day['year']) . "," . mktime(23, 59, 59, $day['month'], $day['day'], $day['year']) . ");");
- }
-
- $data['sidebar'] = Array("years" => $yearsItem, "months" => $monthsItem, "days" => $daysItem
- );
- $this->javascript = Array("flot/jquery.flot.min.js", "flot/jquery.flot.resize.min.js", "flot/jquery.flot.crosshair.min.js");
- $this->content = $this->load->view('pages/sensor/view', $data, true);
- $this->render_page();
-}
function json_graph($sensorID, $timefrom, $timeto) {
- $values = $this->Sensor_model->getSensorValuesByHour($sensorID, $timefrom, $timeto);
+ $values = getSensorValuesByHour($sensorID, $timefrom, $timeto);
$label = $sensorID;
$data = Array();
$tzoffset = $this->get_timezone_offset("UTC");
@@ -53,15 +26,13 @@
function json_data_description($sensorID, $timefrom, $timeto) {
$timefrom = strtotime($timefrom);
$timeto = strtotime($timeto);
- $years = $this->Sensor_model->getSensorDataYears($sensorID, $timefrom, $timeto);
+ $years = getSensorDataYears($sensorID, $timefrom, $timeto);
- $months = $this->Sensor_model->getSensorDataMonths($sensorID, $timefrom, $timeto);
- $days = $this->Sensor_model->getSensorDataDays($sensorID, $timefrom, $timeto);
+ $months = getSensorDataMonths($sensorID, $timefrom, $timeto);
+ $days = getSensorDataDays($sensorID, $timefrom, $timeto);
- $this->output
- ->set_content_type('application/json')
- ->set_output(json_encode(Array("years" => $years, "months" => $months, "days" => $days
- )));
+ return json_encode(Array("years" => $years, "months" => $months, "days" => $days
+ ));
}
?>
--- a/common.inc.php
+++ b/common.inc.php
@@ -1,6 +1,7 @@
<?php
date_default_timezone_set("Australia/Sydney");
$basePath = "";
+$DATA_DIR = "./data";
/** Returns the offset from the origin timezone to the remote timezone, in seconds.
* @param $remote_tz;
@@ -22,9 +23,8 @@
}
function getSensorValuesByHour($sensorID, $timeFrom, $timeTo) {
- $sql = 'select min(time) as time, min(value), max(value), avg(value), stddev(value) from sensor_values where sensor_id = ?
- and extract(epoch from time) > ? and extract(epoch from time) < ?
- group by sensor_id, date_trunc(\'hour\', time) order by time';
+ $sql = 'select min(call_timestamp) as time, count(*), min(length), max(length), avg(length), stddev(length) from recordings
+ group by tgid, date_trunc(\'hour\', call_timestamp) order by time';
$query = $this->db->query($sql, Array($sensorID, $timeFrom, $timeTo));
return $query->result_array();
@@ -39,7 +39,7 @@
}
function getSensorDataYears($sensorID, $timeFrom, $timeTo) {
- $sql = "select distinct extract('year' from time) as year from sensor_values where sensor_id = ? order by year";
+ $sql = "select distinct extract('year' from call_timestamp) as year from recordings where tgid = ? order by year";
$query = $this->db->query($sql, Array($sensorID));
return $query->result_array();
--- a/scannr.py
+++ b/scannr.py
@@ -64,7 +64,7 @@
print str(len(data))
if len(data) > MIN_LENGTH:
data = snd.pack('<' + ('h'*len(data)), *data)
- path = filename
+ path = "./data/"+filename
dispatcher.send( signal='FILE_CREATED', sender=filename, filename=filename, length=len(data))
wf = wave.open(path, 'wb')
wf.setnchannels(1)
--- a/viewcalls.php
+++ b/viewcalls.php
@@ -1,3 +1,7 @@
+<?php
+include('common.inc.php');
+$tgid = 1;
+?>
<div class="span12">
<table width="100%" height="375px"><tr><td valign="middle"><span class="arrow-w" style="font-size:2em;"></span></td><td width="95%"><div id="placeholder" style="width:100%;height:375px;"></div></td><td valign="middle"><span class="arrow-e" style="font-size:2em;"></span></td></tr></table>
@@ -48,7 +52,7 @@
});
- getData('<?php echo $sensorID; ?>','<?php echo strtotime("12/1/2010") ?>','<?php echo strtotime("12/2/2010") ?>');
+ getData('<?php echo $tgid; ?>','<?php echo strtotime("10/10/2012") ?>','<?php echo strtotime("12/10/2012") ?>');
};
@@ -60,7 +64,7 @@
}
function getData(sensorID,from,to) {
$.ajax({
- url: "<?php echo base_url(); ?>/sensor/json_graph/"+sensorID+"/"+from+"/"+to,
+ url: "<?php echo $basePath; ?>/calls.json.php?"+sensorID+"/"+from+"/"+to,
method: 'GET',
dataType: 'json',
success: onDataReceived