Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions web/data/torque_keys.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
id,Device ID
k03,Fuel Status
k04,Engine Load
k05,Engine Coolant Temperature
k06,Fuel Trim Bank 1 Short Term
k07,Fuel Trim Bank 1 Long Term
k08,Fuel Trim Bank 2 Short Term
k09,Fuel Trim Bank 2 Long Term
k0a,Fuel pressure
k0b,Intake Manifold Pressure
k0c,Engine RPM
k0d,Speed (OBD)
k0e,Timing Advance
k0f,Intake Air Temperature
k10,Mass Air Flow Rate
k11,Throttle Position(Manifold)
k12,Air Status
Expand Down
6 changes: 3 additions & 3 deletions web/get_sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require("./creds.php");

session_start();
$timezone = $_SESSION['time'];
$timezone = ini_get('date.timezone');

// Connect to Database
$con = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
Expand All @@ -19,10 +19,10 @@
while($row = mysql_fetch_assoc($sessionqry)) {
$session_size = $row["Session Size"];
// Drop sessions smaller than 60 data points
if ($session_size >= 60) {
if ($session_size >= 10) {
$sid = $row["session"];
$sids[] = preg_replace('/\D/', '', $sid);
$seshdates[$sid] = date("F d, Y h:ia", substr($sid, 0, -3));
$seshdates[$sid] = date("Y-m-d D h:ia", substr($sid, 0, -3));
}
else {}
}
Expand Down
55 changes: 46 additions & 9 deletions web/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
<meta name="author" content="Matt Nicklay">
<!--<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">-->
<link rel="stylesheet" href="static/css/bootstrap.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.0/chosen.min.css">
<link rel="stylesheet" href="static/css/chosen.min.css">
<link rel="stylesheet" href="static/css/torque.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
if("<?php echo $timezone; ?>".length==0){
Expand All @@ -115,10 +115,13 @@
}
});
</script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>

<script language="javascript" type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript" src="static/js/jquery.peity.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.1.0/chosen.jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="static/js/date.format.js"></script>
<script language="javascript" type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

<script language="javascript" type="text/javascript">
Expand All @@ -141,7 +144,7 @@ function initialize() {
style: google.maps.NavigationControlStyle.ZOOM_PAN
},
scaleControl: true,
disableDoubleClickZoom: false,
disableDoubleClickZoom: true,
draggable: true,
streetViewControl: true,
draggableCursor: 'move'
Expand Down Expand Up @@ -206,9 +209,46 @@ function(event) {
strokeWeight: 4
});
line.setMap(map);

google.maps.event.addListener(map, 'dblclick', function(event){
var d = {
id : "<?php echo $session_id;?>",
lat : event.latLng.lat(),
lng : event.latLng.lng()
};
$.ajax({
type: "GET",
url: "session_speed.php",
data: d,
success: function(data) {
var titletext = "<pre>"
+ "Error: " + data.dist + "\n"
+ "Time: " + new Date(data.time * 1).format('Y-m-d H:i:s') + "\n"
+ "Engine RPM: " + data.kc + "\n"
+ "Speed OBD: " + data.kd + "\n"
+ "Speed GPS: " + data.kff1001 + "</pre>";

if (marker == null) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(data.kff1006, data.kff1005),
map: map,
icon: "static/css/small_red.png"
});
infowin = new google.maps.InfoWindow();
} else {
marker.setPosition(new google.maps.LatLng(data.kff1006, data.kff1005));
}
infowin.setContent(titletext);
infowin.open(map, marker);
},
dataType: "json"
});
});
};

google.maps.event.addDomListener(window, 'load', initialize);
var marker = null;
var infowin = null;
</script>

<?php if ($setZoomManually === 0) { ?>
Expand Down Expand Up @@ -255,7 +295,7 @@ function doPlot(position) {
backgroundOpacity: 0.1,
margin: 0
},
//selection: { mode: "xy" },
// selection: { mode: "xy" },
grid: {
hoverable: false,
clickable: true
Expand Down Expand Up @@ -373,7 +413,6 @@ function doPlot(position) {
<th>25th Pcnt</th>
<th>75th Pcnt</th>
<th>Mean</th>
<th>Sparkline</th>
</tr>
</thead>
<tbody>
Expand All @@ -383,15 +422,13 @@ function doPlot(position) {
<td><?php echo $pcnt25data1; ?></td>
<td><?php echo $pcnt75data1; ?></td>
<td><?php echo $avg1; ?></td>
<td><span class="line"><?php echo $sparkdata1; ?></span></td>
</tr>
<tr>
<td><strong><?php echo substr($v2_label, 1, -1); ?></strong></td>
<td><?php echo $min2.'/'.$max2; ?></td>
<td><?php echo $pcnt25data2; ?></td>
<td><?php echo $pcnt75data2; ?></td>
<td><?php echo $avg2; ?></td>
<td><span class="line"><?php echo $sparkdata2; ?></span></td>
</tr>
</tbody>
</table>
Expand Down
44 changes: 44 additions & 0 deletions web/session_speed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

ini_set('memory_limit', '-1');
require ("./creds.php");
require ("./get_sessions.php");
require ("./get_columns.php");
require ("./plot.php");

foreach ($_GET as $key => $value) {
if (! isset($_POST[$key]))
$_POST[$key] = $value;
}

foreach ($_COOKIE as $key => $value) {
if (! isset($_POST[$key]))
$_POST[$key] = $value;
}

$_SESSION['recent_session_id'] = strval(max($sids));

// Connect to Database
$con = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysql_select_db($db_name, $con) or die(mysql_error());

if (! isset($_POST["id"])) die("no session_id");
if (! isset($_POST["lat"])) die("no latitude");
if (! isset($_POST["lng"])) die("no longitude");

$session_id = preg_replace('/\D/', '', $_POST['id']);
$lat = sprintf("%1.10f", doubleval($_POST["lat"]));
$lng = sprintf("%1.10f", doubleval($_POST["lng"]));

$speedinfo = mysql_query("
SELECT
abs( kff1005 - $lng ) + abs( kff1006 - $lat ) dist,
kff1005, kff1006, time, kff1001, kc, kd
FROM $db_table
WHERE session=$session_id
ORDER BY dist ASC
LIMIT 1", $con) or die(mysql_error());

$speedinfo_array = mysql_fetch_array($speedinfo, MYSQL_ASSOC);
echo json_encode($speedinfo_array);
?>
159 changes: 159 additions & 0 deletions web/static/css/chosen.bootstrap.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/* Bootstrap-like base style obtained from https://gist.github.com/koenpunt/6424137 */

select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
background-image:none;
}

select.form-control + .chosen-container.chosen-container-single .chosen-single div {
top:4px;
color:#000;
}

select.form-control + .chosen-container .chosen-drop {
background-color: #FFF;
border: 1px solid #CCC;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box;
margin: 2px 0 0;
}

select.form-control + .chosen-container .chosen-search input[type=text] {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #FFF;
border: 1px solid #CCC;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
background-image:none;
}

select.form-control + .chosen-container .chosen-results {
margin: 2px 0 0;
padding: 5px 0;
font-size: 14px;
list-style: none;
background-color: #fff;
margin-bottom: 5px;
}

select.form-control + .chosen-container .chosen-results li ,
select.form-control + .chosen-container .chosen-results li.active-result {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #333;
white-space: nowrap;
background-image:none;
}
select.form-control + .chosen-container .chosen-results li:hover,
select.form-control + .chosen-container .chosen-results li.active-result:hover,
select.form-control + .chosen-container .chosen-results li.highlighted
{
color: #FFF;
text-decoration: none;
background-color: #0094bb;
background-image:none;
}

select.form-control + .chosen-container-multi .chosen-choices {
display: block;
width: 100%;
min-height: 34px;
padding: 6px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
background-image:none;
}

select.form-control + .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
height:auto;
padding:5px 0;
}

select.form-control + .chosen-container-multi .chosen-choices li.search-choice {
background-image: none;
padding: 3px 24px 3px 5px;
margin: 0 6px 0 0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid #ccc;
border-radius: 4px;
color: #666;
background-color: #E5F1FC;
border-color: #BCD8F3;
}

select.form-control + .chosen-container-multi .chosen-choices li.search-choice:hover {
background-color: #D7EAFB;
}

select.form-control + .chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
top:8px;
right:6px;
}

select.form-control + .chosen-container-multi.chosen-container-active .chosen-choices,
select.form-control + .chosen-container.chosen-container-single.chosen-container-active .chosen-single,
select.form-control + .chosen-container .chosen-search input[type=text]:focus{
border-color: #66AFE9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(102, 175, 233, 0.6);
}

select.form-control + .chosen-container-multi .chosen-results li.result-selected{
display: list-item;
color: #ccc;
cursor: default;
background-color: white;
}

li.group-result {
font-weight:bold !important;
padding-left:5px !important;
font-size:16px !important;
}

2 changes: 1 addition & 1 deletion web/static/css/chosen.css
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@

/* @end */
/* @group Retina compatibility */
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dppx) {
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
.chosen-rtl .chosen-search input[type="text"],
.chosen-container-single .chosen-single abbr,
.chosen-container-single .chosen-single div b,
Expand Down
Loading