From e5559022c15640d75b46fd7eb5f173ae8d59415e Mon Sep 17 00:00:00 2001 From: surfrock66 Date: Sat, 2 Feb 2019 22:53:08 -0800 Subject: [PATCH] This is a major, structural change which represents a new release. The entire structure of the data storage has been changed. Instead of a single raw_logs table, it's now broken into months. Additionally, session information has been broken out of the raw_logs and is solely stored in the sessions table. In order to accomplish this, there is a MAJOR database restructuring, requiring the execution of 'db_upgrade.php' which can take HOURS to run depending on how much data you have. PLEASE BACK UP YOUR DATABASE BEFORE RUNNING THAT. PLEASE LOOK AT THE ACTUAL CODE I AM RUNNING and consider running it manually. The most important user-facing changes...1) session filtering is now Year_Month instead of year AND month. 2) The GPS coordinates have been changed from float to Double, making the lines smoother. 3) You can now select favorite PIDs in the PID Edit page, and those are now auto-selected to be populated for plotting when the app loads. --- README.md | 7 + scripts/create_torque_keys_table.sql | 299 ++++++++++++++------------- scripts/create_torque_log_table.sql | 20 +- web/db_upgrade.php | 49 +++++ web/del_session.php | 9 +- web/export.php | 5 +- web/get_columns.php | 4 +- web/get_sessions.php | 51 ++--- web/merge_sessions.php | 6 +- web/pid_commit.php | 28 ++- web/pid_edit.php | 11 +- web/plot.php | 5 +- web/session.php | 89 +++----- web/static/css/torque.css | 2 +- web/static/js/torquehelpers.js | 12 +- web/upload_data.php | 207 ++++++++++++++----- web/url.php | 25 +-- 17 files changed, 477 insertions(+), 352 deletions(-) create mode 100644 web/db_upgrade.php diff --git a/README.md b/README.md index 54adda8b..e78d853d 100644 --- a/README.md +++ b/README.md @@ -136,3 +136,10 @@ LimitRequestLine 15000 * Email-receiver for this? LONG SHOT, but have the server read an email address so you can email tracks from the app * Ian Hawkins has a google map pin show up when hovering over his graphs on his reference viewer...different system, but it'd be cool to implement. * Idea: speed heatmap for the map track. (Google Maps iOS API has gradient polylines, javascript API does not...may not be possible for now). + +### Credits and Thanks ### + +* [Ian Hawkins](http://ian-hawkins.com/) - Creator of the Torque app, none of this happens without that +* [Matt Nicklay/econpy](https://github.com/econpy) - This is the project I forked from, so all credit where credit is due +* [Takashi Saito/takashisite](https://github.com/takashisite) - Spawn for the patch to change the GPS from float to double; I didn't take his pull request because it came with a greater structural update, but he deserves credit for pointing it out +* [marvinwankersteen](https://github.com/marvinwankersteen) - Gave me the idea to implement the "favorite variables" system. diff --git a/scripts/create_torque_keys_table.sql b/scripts/create_torque_keys_table.sql index 2b3e718c..b2d41f21 100644 --- a/scripts/create_torque_keys_table.sql +++ b/scripts/create_torque_keys_table.sql @@ -20,155 +20,160 @@ CREATE TABLE `torque_keys` ( `description` varchar(255) COMMENT 'Description', `type` varchar(255) NOT NULL DEFAULT 'varchar(255)' COMMENT 'Variable Type', `units` varchar(255) COMMENT 'Units', - `populated` boolean NOT NULL DEFAULT '0' COMMENT 'Is This Variable Populated?', + `populated, favorite` boolean NOT NULL DEFAULT '0' COMMENT 'Is This Variable Populated?', + `favorite` boolean NOT NULL DEFAULT '0' COMMENT 'Pre-select this variable for plotting?', `min` float COMMENT 'Minimum Value', `max` float COMMENT 'Maximum Value', KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff122e','0-100kph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff124f','0-200kph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1277','0-30mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff122d','0-60mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff122f','1/4 mile Time','float','s',1,0,30); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1230','1/8 mile Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1264','100-0kph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1260','40-60mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1265','60-0mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff125e','60-120mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1276','60-130mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff125f','60-80mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1261','80-100mph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1275','80-120kph Time','float','s',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k47','Absolute Throttle Position B','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1223','Acceleration Sensor (Total)','float','g',1,-1,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1220','Acceleration Sensor (X Axis)','float','g',1,-1,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1221','Acceleration Sensor (Y Axis)','float','g',1,-1,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1222','Acceleration Sensor (Z Axis)','float','g',1,-1,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k49','Accelerator Pedal Position D','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k4a','Accelerator Pedal Position E','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k4b','Accelerator Pedal Position F','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, populated, min, max) VALUES ('kff124d','Air Fuel Ratio (Commanded)','float',1,0,30); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('kff1249','Air Fuel Ratio (Measured)','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k12','Air Status','float',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k46','Ambient Air Temp','float','°C',1,-40,50); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1263','Average Trip Speed (Whilst Moving Only)','float','km/h',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1272','Average Trip Speed (Whilst Stopped or Moving)','float','km/h',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1270','Barometer (On Android device)','float','mb',1,800,1100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k33','Barometric Pressure (From Vehicle)','float','kPa',1,0,255); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k3c','Catalyst Temperature (Bank 1 Sensor 1)','float','°C',1,0,60); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k3e','Catalyst Temperature (Bank 1 Sensor 2)','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k3d','Catalyst Temperature (Bank 2 Sensor 1)','float','°C',1,0,60); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k3f','Catalyst Temperature (Bank 2 Sensor 2)','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1258','CO2 (Average)','float','g/km',1,0,120); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1257','CO2 (Instantaneous)','float','g/km',1,0,120); -INSERT INTO torque_keys (id, description, type, populated, min, max) VALUES ('k44','Commanded Equivalence Ratio (lambda)','float',1,0,2); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff126d','Cost per mile/km (Instant)','float','$/km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff126e','Cost per mile/km (Trip)','float','$/km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff126a','Distance to empty (Estimated)','float','km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k31','Distance Travelled Since Codes Cleared','float','km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k21','Distance Travelled With MIL/CEL Lit','float','km',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k2c','EGR Commanded','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k2d','EGR Error','float',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k5','Engine Coolant Temperature','float','°C',1,-40,120); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1273','Engine kW (At the Wheels)','float','kW',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k4','Engine Load','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k43','Engine Load (Absolute)','float','%',1,0,20000); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k5c','Engine Oil Temperature','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kc','Engine RPM','float','rpm',1,0,10000); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k52','Ethanol Fuel %','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k32','Evap System Vapor Pressure','float','Pa',1,0,1000); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k78','Exhaust Gas Temperature 1','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k79','Exhaust Gas Temperature 2','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff125c','Fuel Cost (Trip)','float','$',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff125d','Fuel Flow Rate/Hour','float','l/hr',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff125a','Fuel Flow Rate/Minute','float','cc/min',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k2f','Fuel Level (From Engine ECU)','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('ka','Fuel Pressure','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k23','Fuel Rail Pressure','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k22','Fuel Rail Pressure (Relative to Manifold Vacuum)','float',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff126b','Fuel Remaining (Calculated From Vehicle Profile)','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k3','Fuel Status','float',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k7','Fuel Trim Bank 1 Long Term','float','%',1,-25,25); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k14','Fuel Trim Bank 1 Sensor 1','float','%',1,-100,100); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k15','Fuel Trim Bank 1 Sensor 2','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k16','Fuel Trim Bank 1 Sensor 3','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k17','Fuel Trim Bank 1 Sensor 4','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k6','Fuel Trim Bank 1 Short Term','float','%',1,-25,25); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k9','Fuel Trim Bank 2 Long Term','float','%',1,-25,25); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k18','Fuel Trim Bank 2 Sensor 1','float','%',1,-100,100); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k19','Fuel Trim Bank 2 Sensor 2','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k1a','Fuel Trim Bank 2 Sensor 3','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k1b','Fuel Trim Bank 2 Sensor 4','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k8','Fuel Trim Bank 2 Short Term','float','%',1,-25,25); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1271','Fuel Used (Trip)','float','l',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1239','GPS Accuracy','float','m',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1010','GPS Altitude','float','m',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff123b','GPS Bearing','float','°',1,0,360); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1006','GPS Latitude','float','°',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1005','GPS Longitude','float','°',1,0,100); -INSERT INTO torque_keys (id, description, type, populated, min, max) VALUES ('kff123a','GPS Satellites','float',1,0,10); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1237','GPS vs OBD Speed Difference','float','km/h',1,0,10); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1226','Horsepower (At the Wheels)','float','hp',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kf','Intake Air Temperature','float','°C',1,-40,60); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kb','Intake Manifold Pressure','float','kPa',1,0,255); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1203','Kilometers Per Litre (Instant)','float','kpl',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff5202','Kilometers Per Litre (Long Term Average)','float','kpl',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1207','Litres Per 100 Kilometer (Instant)','float','l/100km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff5203','Litres Per 100 Kilometer (Long Term Average)','float','l/100km',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k10','Mass Air Flow Rate','float',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1201','Miles Per Gallon (Instant)','float','mpg',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff5201','Miles Per Gallon (Long Term Average)','float','mpg',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k24','O2 Sensor1 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k34','O2 Sensor1 Equivalence Ratio (Alternate)','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1240','O2 Sensor1 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k25','O2 Sensor2 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1241','O2 Sensor2 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k26','O2 Sensor3 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1242','O2 Sensor3 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k27','O2 Sensor4 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1243','O2 Sensor4 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k28','O2 Sensor5 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1244','O2 Sensor5 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k29','O2 Sensor6 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1245','O2 Sensor6 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k2a','O2 Sensor7 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1246','O2 Sensor7 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('k2b','O2 Sensor8 Equivalence Ratio','float',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1247','O2 Sensor8 Wide-range Voltage','float','V',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1214','O2 Volts Bank 1 Sensor 1','float','V',1,0,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1215','O2 Volts Bank 1 Sensor 2','float','V',1,0,1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1216','O2 Volts Bank 1 Sensor 3','float','V',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1217','O2 Volts Bank 1 Sensor 4','float','V',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1218','O2 Volts Bank 2 Sensor 1','float','V',1,0,1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1219','O2 Volts Bank 2 Sensor 2','float','V',1,0,1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff121a','O2 Volts Bank 2 Sensor 3','float','V',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff121b','O2 Volts Bank 2 Sensor 4','float','V',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('k5a','Relative Accelerator Pedal Position','float','%',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k45','Relative Throttle Position','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k1f','Run Time Since Engine Start','float','s',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('session','Session ID','varchar(255)',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1001','Speed (GPS)','float','km/h',1,0,160); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kd','Speed (OBD)','float','km/h',1,0,160); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k11','Throttle Position (Manifold)','float','%',1,0,100); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('kff124a','Tilt (x)','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('kff124b','Tilt (y)','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('kff124c','Tilt (z)','float',1); -INSERT INTO torque_keys (id, description, type, populated) VALUES ('time','Timestamp','varchar(255)',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('ke','Timing Advance','float','°',1,-64,63); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1225','Torque','float','ft-lb',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kfe1805','Transmission Temperature (Method 1)','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kb4','Transmission Temperature (Method 2)','float','°C',1); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1206','Trip Average KPL','float','kpl',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1208','Trip Average Litres/100 KM','float','l/100km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1205','Trip Average MPG','float','mpg',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1204','Trip Distance','float','km',1,0,200); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff120c','Trip Distance (Stored in Vehicle Profile)','float','km',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1266','Trip Time (Since Journey Start)','float','s',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1268','Trip Time (Whilst Moving)','float','s',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1267','Trip Time (Whilst Stationary)','float','s',1,0,100); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1202','Turbo Boost & Vacuum Gauge','float','psi',1,-20,20); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('k42','Voltage (Control Module)','float','V',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated, min, max) VALUES ('kff1238','Voltage (OBD Adapter)','float','V',1,0,16); -INSERT INTO torque_keys (id, description, type, units, populated) VALUES ('kff1269','Volumetric Efficiency (Calculated)','float','%',1); -INSERT INTO torque_keys (id, type, populated) VALUES ('kff1007','float', 0); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff122e','0-100kph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1278','0-100mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff124f','0-200kph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1277','0-30mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff122d','0-60mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff122f','1/4 mile Time','float','s',1,0,0,30); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1230','1/8 mile Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1264','100-0kph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1280','100-200kph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1260','40-60mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1265','60-0mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff125e','60-120mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1276','60-130mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff125f','60-80mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1261','80-100mph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1275','80-120kph Time','float','s',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k47','Absolute Throttle Position B','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1223','Acceleration Sensor (Total)','float','g',1,0,-1,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1220','Acceleration Sensor (X Axis)','float','g',1,0,-1,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1221','Acceleration Sensor (Y Axis)','float','g',1,0,-1,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1222','Acceleration Sensor (Z Axis)','float','g',1,0,-1,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k49','Accelerator Pedal Position D','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k4a','Accelerator Pedal Position E','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k4b','Accelerator Pedal Position F','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('kff124d','Air Fuel Ratio (Commanded)','float',1,0,0,30); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('kff1249','Air Fuel Ratio (Measured)','float',1,0,0,30); +INSERT INTO torque_keys (id, description, type, populated, favorite) VALUES ('k12','Air Status','float',1,0); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k46','Ambient Air Temp','float','°C',1,0,-40,50); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff129a','Android Device Battery Level','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1263','Average Trip Speed (Whilst Moving Only)','float','km/h',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1272','Average Trip Speed (Whilst Stopped or Moving)','float','km/h',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1270','Barometer (On Android device)','float','mb',1,0,800,1100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k33','Barometric Pressure (From Vehicle)','float','kPa',1,0,0,255); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k3c','Catalyst Temperature (Bank 1 Sensor 1)','float','°C',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k3e','Catalyst Temperature (Bank 1 Sensor 2)','float','°C',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k3d','Catalyst Temperature (Bank 2 Sensor 1)','float','°C',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k3f','Catalyst Temperature (Bank 2 Sensor 2)','float','°C',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1258','CO2 (Average)','float','g/km',1,0,0,120); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1257','CO2 (Instantaneous)','float','g/km',1,0,0,120); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k44','Commanded Equivalence Ratio (lambda)','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff126d','Cost per mile/km (Instant)','float','$/km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff126e','Cost per mile/km (Trip)','float','$/km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff126a','Distance to empty (Estimated)','float','km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k31','Distance Travelled Since Codes Cleared','float','km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k21','Distance Travelled With MIL/CEL Lit','float','km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k2c','EGR Commanded','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k2d','EGR Error','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k5','Engine Coolant Temperature','float','°C',1,0,-40,120); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1273','Engine kW (At the Wheels)','float','kW',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k4','Engine Load','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k43','Engine Load (Absolute)','float','%',1,0,0,20000); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k5c','Engine Oil Temperature','float','°C',1,0,-40,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kc','Engine RPM','float','rpm',1,0,0,10000); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k52','Ethanol Fuel %','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k32','Evap System Vapor Pressure','float','Pa',1,0,0,1000); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k78','Exhaust Gas Temperature Bank 1 Sensor 1','float','°C',1,0,0,600); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k79','Exhaust Gas Temperature Bank 2 Sensor 1','float','°C',1,0,0,600); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff125c','Fuel Cost (Trip)','float','$',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff125d','Fuel Flow Rate/Hour','float','l/hr',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff125a','Fuel Flow Rate/Minute','float','cc/min',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k2f','Fuel Level (From Engine ECU)','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('ka','Fuel Pressure','float','kPa',1,0,0,765); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k23','Fuel Rail Pressure','float','kPa',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k22','Fuel Rail Pressure (Relative to Manifold Vacuum)','float','kPa',1,0,0,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff126b','Fuel Remaining (Calculated From Vehicle Profile)','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, populated, favorite) VALUES ('k3','Fuel Status','float',1,0); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k7','Fuel Trim Bank 1 Long Term','float','%',1,0,-25,25); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k14','Fuel Trim Bank 1 Sensor 1','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k15','Fuel Trim Bank 1 Sensor 2','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k16','Fuel Trim Bank 1 Sensor 3','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k17','Fuel Trim Bank 1 Sensor 4','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k6','Fuel Trim Bank 1 Short Term','float','%',1,0,-25,25); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k9','Fuel Trim Bank 2 Long Term','float','%',1,0,-25,25); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k18','Fuel Trim Bank 2 Sensor 1','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k19','Fuel Trim Bank 2 Sensor 2','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k1a','Fuel Trim Bank 2 Sensor 3','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k1b','Fuel Trim Bank 2 Sensor 4','float','%',1,0,-100,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k8','Fuel Trim Bank 2 Short Term','float','%',1,0.-25,25); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1271','Fuel Used (Trip)','float','l',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1239','GPS Accuracy','float','m',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1010','GPS Altitude','float','m',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff123b','GPS Bearing','float','°',1,0,0,360); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1006','GPS Latitude','double','°',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1005','GPS Longitude','double','°',1,0,0,100); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('kff123a','GPS Satellites','float',1,0,0,24); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1237','GPS vs OBD Speed Difference','float','km/h',1,0,0,10); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1226','Horsepower (At the Wheels)','float','hp',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kf','Intake Air Temperature','float','°C',1,0,-40,60); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kb','Intake Manifold Pressure','float','kPa',1,0,0,255); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1203','Kilometers Per Litre (Instant)','float','kpl',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff5202','Kilometers Per Litre (Long Term Average)','float','kpl',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1207','Litres Per 100 Kilometer (Instant)','float','l/100km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff5203','Litres Per 100 Kilometer (Long Term Average)','float','l/100km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k10','Mass Air Flow Rate','float','g/s',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1201','Miles Per Gallon (Instant)','float','mpg',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff5201','Miles Per Gallon (Long Term Average)','float','mpg',1,0,0,100); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k24','O2 Sensor1 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k34','O2 Sensor1 Equivalence Ratio (Alternate)','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1240','O2 Sensor1 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k25','O2 Sensor2 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1241','O2 Sensor2 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k26','O2 Sensor3 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1242','O2 Sensor3 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k27','O2 Sensor4 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1243','O2 Sensor4 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k28','O2 Sensor5 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1244','O2 Sensor5 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k29','O2 Sensor6 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1245','O2 Sensor6 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k2a','O2 Sensor7 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1246','O2 Sensor7 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, populated, favorite, min, max) VALUES ('k2b','O2 Sensor8 Equivalence Ratio','float',1,0,0,2); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1247','O2 Sensor8 Wide-range Voltage','float','V',1,0,0,8); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1214','O2 Volts Bank 1 Sensor 1','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1215','O2 Volts Bank 1 Sensor 2','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1216','O2 Volts Bank 1 Sensor 3','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1217','O2 Volts Bank 1 Sensor 4','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1218','O2 Volts Bank 2 Sensor 1','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1219','O2 Volts Bank 2 Sensor 2','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff121a','O2 Volts Bank 2 Sensor 3','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff121b','O2 Volts Bank 2 Sensor 4','float','V',1,0,0,1); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1296','Percentage of City Driving','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1297','Percentage of Highway Driving','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1298','Percentage of Idle Driving','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k5a','Relative Accelerator Pedal Position','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k45','Relative Throttle Position','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k1f','Run Time Since Engine Start','float','s',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1001','Speed (GPS)','float','km/h',1,0,0,160); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kd','Speed (OBD)','float','km/h',1,1,0,160); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k11','Throttle Position (Manifold)','float','%',1,0,0,100); +INSERT INTO torque_keys (id, description, type, populated, favorite) VALUES ('kff124a','Tilt (x)','float',1,0); +INSERT INTO torque_keys (id, description, type, populated, favorite) VALUES ('kff124b','Tilt (y)','float',1,0); +INSERT INTO torque_keys (id, description, type, populated, favorite) VALUES ('kff124c','Tilt (z)','float',1,0); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('ke','Timing Advance','float','°',1,0,-64,63); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1225','Torque','float','ft-lb',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kfe1805','Transmission Temperature (Method 1)','float','°C',1,0,0,105); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kb4','Transmission Temperature (Method 2)','float','°C',1,0,0,105); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1206','Trip Average KPL','float','kpl',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1208','Trip Average Litres/100 KM','float','l/100km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1205','Trip Average MPG','float','mpg',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1204','Trip Distance','float','km',1,0,0,200); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff120c','Trip Distance (Stored in Vehicle Profile)','float','km',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1266','Trip Time (Since Journey Start)','float','s',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1268','Trip Time (Whilst Moving)','float','s',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1267','Trip Time (Whilst Stationary)','float','s',1,0,0,100); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1202','Turbo Boost & Vacuum Gauge','float','psi',1,0,-20,20); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('k42','Voltage (Control Module)','float','V',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite, min, max) VALUES ('kff1238','Voltage (OBD Adapter)','float','V',1,0,0,16); +INSERT INTO torque_keys (id, description, type, units, populated, favorite) VALUES ('kff1269','Volumetric Efficiency (Calculated)','float','%',1,0); +INSERT INTO torque_keys (id, type, populated, favorite) VALUES ('kff1007','float', 0,0); diff --git a/scripts/create_torque_log_table.sql b/scripts/create_torque_log_table.sql index f72c78ee..bd2d68e4 100644 --- a/scripts/create_torque_log_table.sql +++ b/scripts/create_torque_log_table.sql @@ -16,18 +16,8 @@ PREPARE stmt FROM @query; EXECUTE stmt; #DROP TABLE IF EXISTS `raw_logs`; CREATE TABLE `raw_logs` ( - `v` varchar(1) NOT NULL, `session` varchar(15) NOT NULL, - `id` varchar(32) NOT NULL, `time` varchar(15) NOT NULL, - `eml` varchar(255), - `profileName` varchar(255) NOT NULL DEFAULT '0', - `profileFuelType` varchar(255) NOT NULL DEFAULT 'Not Specified', - `profileWeight` float NOT NULL DEFAULT '0', - `profileVe` float NOT NULL DEFAULT '0', - `profileFuelCost` float NOT NULL DEFAULT '0', - `notice` varchar(255), - `noticeClass` varchar(255), `k10` float NOT NULL DEFAULT '0', `k11` float NOT NULL DEFAULT '0', `k12` float NOT NULL DEFAULT '0', @@ -92,8 +82,8 @@ CREATE TABLE `raw_logs` ( `kf` float NOT NULL DEFAULT '0', `kfe1805` float NOT NULL DEFAULT '0', `kff1001` float NOT NULL DEFAULT '0', - `kff1005` float NOT NULL DEFAULT '0', - `kff1006` float NOT NULL DEFAULT '0', + `kff1005` double NOT NULL DEFAULT '0', + `kff1006` double NOT NULL DEFAULT '0', `kff1007` float NOT NULL DEFAULT '0', `kff1010` float NOT NULL DEFAULT '0', `kff1201` float NOT NULL DEFAULT '0', @@ -169,6 +159,12 @@ CREATE TABLE `raw_logs` ( `kff1275` float NOT NULL DEFAULT '0', `kff1276` float NOT NULL DEFAULT '0', `kff1277` float NOT NULL DEFAULT '0', + `kff1278` float NOT NULL DEFAULT '0', + `kff1280` float NOT NULL DEFAULT '0', + `kff1296` float NOT NULL DEFAULT '0', + `kff1297` float NOT NULL DEFAULT '0', + `kff1298` float NOT NULL DEFAULT '0', + `kff129a` float NOT NULL DEFAULT '0', `kff5201` float NOT NULL DEFAULT '0', `kff5202` float NOT NULL DEFAULT '0', `kff5203` float NOT NULL DEFAULT '0', diff --git a/web/db_upgrade.php b/web/db_upgrade.php new file mode 100644 index 00000000..d7d8521d --- /dev/null +++ b/web/db_upgrade.php @@ -0,0 +1,49 @@ + + diff --git a/web/del_session.php b/web/del_session.php index 99d53a52..ee14dcc7 100644 --- a/web/del_session.php +++ b/web/del_session.php @@ -12,13 +12,14 @@ } if (isset($deletesession) && !empty($deletesession)) { - $delresult = mysqli_query($con, "DELETE FROM $db_table - WHERE session=".quote_value($deletesession)) or die(mysqli_error($con)); + $tableYear = date( "Y", $deletesession/1000 ); + $tableMonth = date( "m", $deletesession/1000 ); + $db_table_full = "{$db_table}_{$tableYear}_{$tableMonth}"; + $delresult = mysqli_query($con, "DELETE FROM $db_table_full WHERE session=".quote_value($deletesession)) or die(mysqli_error($con)); mysqli_free_result($delresult); - $delresult = mysqli_query($con, "DELETE FROM $db_sessions_table - WHERE session=".quote_value($deletesession)) or die(mysqli_error($con)); + $delresult = mysqli_query($con, "DELETE FROM $db_sessions_table WHERE session=".quote_value($deletesession)) or die(mysqli_error($con)); mysqli_free_result($delresult); } diff --git a/web/export.php b/web/export.php index adbd5994..657110c0 100644 --- a/web/export.php +++ b/web/export.php @@ -5,7 +5,10 @@ $session_id = $_GET['sid']; // Get data for session $output = ""; - $sql = mysqli_query($con, "SELECT * FROM $db_table join $db_sessions_table on $db_table.session = $db_sessions_table.session WHERE $db_table.session=".quote_value($session_id)." ORDER BY $db_table.time DESC;") or die(mysqli_error($con)); + $tableYear = date( "Y", $session_id/1000 ); + $tableMonth = date( "m", $session_id/1000 ); + $db_table_full = "{$db_table}_{$tableYear}_{$tableMonth}"; + $sql = mysqli_query($con, "SELECT * FROM $db_table_full join $db_sessions_table on $db_table_full.session = $db_sessions_table.session WHERE $db_table_full.session=".quote_value($session_id)." ORDER BY $db_table_full.time DESC;") or die(mysqli_error($con)); if ($_GET["filetype"] == "csv") { $columns_total = mysqli_num_fields($sql); diff --git a/web/get_columns.php b/web/get_columns.php index ef2671ac..bf8925a4 100644 --- a/web/get_columns.php +++ b/web/get_columns.php @@ -6,10 +6,10 @@ // 2015.08.21 - edit by surfrock66 - Rather than pull from the column comments, // oull from a new database created which manages variables. Include // a column flagging whether a variable is populated or not. -$colqry = mysqli_query($con, "SELECT id,description,type FROM $db_keys_table WHERE populated = 1 ORDER BY description") or die(mysqli_error($con)); +$colqry = mysqli_query($con, "SELECT id,description,type,favorite FROM $db_keys_table WHERE populated = 1 ORDER BY description") or die(mysqli_error($con)); while ($x = mysqli_fetch_array($colqry)) { if ((substr($x[0], 0, 1) == "k") && ($x[2] == "float")) { - $coldata[] = array("colname"=>$x[0], "colcomment"=>$x[1]); + $coldata[] = array("colname"=>$x[0], "colcomment"=>$x[1], "colfavorite"=>$x[3]); } } diff --git a/web/get_sessions.php b/web/get_sessions.php index 92824f72..c2c3d4ba 100644 --- a/web/get_sessions.php +++ b/web/get_sessions.php @@ -1,36 +1,17 @@ \r\n"; +//echo "\r\n"; // this page relies on being included from another page that has already connected to db session_set_cookie_params(0,dirname($_SERVER['SCRIPT_NAME'])); if (!isset($_SESSION)) { session_start(); } -// Process the 4 possibilities for the year filter: Set in POST, Set in GET, select all possible years, or the default: select the current year -if ( isset($_POST["selyear"]) ) { - $filteryear = $_POST["selyear"]; -} elseif ( isset($_GET["year"])) { - $filteryear = $_GET["year"]; +// Process the possibilities for the year and month filter: Set in POST, Set in GET, select all possible year/months, or the default: select the current year/month +if ( isset($_POST["selyearmonth"]) ) { + $filteryearmonth = $_POST["selyearmonth"]; +} elseif ( isset($_GET["yearmonth"])) { + $filteryearmonth = $_GET["yearmonth"]; } else { - $filteryear = date('Y'); -} -if ( $filteryear == "ALL" ) { - $filteryear = "%"; -} - -// Process the 4 possibilities for the month filter: Set in POST, Set in GET, select all possible months, or the default: select the current month -if ( isset($_POST["selmonth"]) ) { - $filtermonth = $_POST["selmonth"]; -} elseif ( isset($_GET["month"])) { - $filtermonth = $_GET["month"]; -} else { - if ( isset($_POST["selyear"]) || isset($_GET["year"]) ) { - $filtermonth = "%"; - } else { - $filtermonth = date('F'); - } -} -if ( $filtermonth == "ALL" ) { - $filtermonth = "%"; + $filteryearmonth = date('Y_m'); } // Process the 4 possibilities for the profile filter: Set in POST, Set in GET, select all possible profiles, or no filter as default @@ -45,22 +26,18 @@ $filterprofile = "%"; } -// Build the MySQL select string based on the inputs (year, month, or session id) + +// Build the MySQL select string based on the inputs (year_month or session id) $sessionqrystring = "SELECT timestart, timeend, session, profileName, sessionsize FROM $db_sessions_table "; -$sqlqryyear = "YEAR(FROM_UNIXTIME(session/1000)) LIKE " . quote_value($filteryear) . " "; -$sqlqrymonth = "MONTHNAME(FROM_UNIXTIME(session/1000)) LIKE " . quote_value($filtermonth) . " "; +$sqlqryyearmonth = "CONCAT(YEAR(FROM_UNIXTIME(session/1000)), '_', DATE_FORMAT(FROM_UNIXTIME(session/1000),'%m')) LIKE " . quote_value($filteryearmonth) . " "; $sqlqryprofile = "profileName LIKE " . quote_value($filterprofile) . " " ; $orselector = "WHERE "; $andselector = ""; -if ( $filteryear <> "%" || $filtermonth <> "%" || $filterprofile <> "%") { +if ( $filteryearmonth <> "%" || $filterprofile <> "%") { $orselector = " OR "; $sessionqrystring = $sessionqrystring . "WHERE ( "; - if ( $filteryear <> "%" ) { - $sessionqrystring = $sessionqrystring . $sqlqryyear; - $andselector = " AND "; - } - if ( $filtermonth <> "%" ) { - $sessionqrystring = $sessionqrystring . $andselector . $sqlqrymonth; + if ( $filteryearmonth <> "%" ) { + $sessionqrystring = $sessionqrystring . $sqlqryyearmonth; $andselector = " AND "; } if ( $filterprofile <> "%" ) { @@ -101,6 +78,6 @@ } mysqli_free_result($sessionqry); -//echo "\r\n"; +//echo "\r\n"; ?> diff --git a/web/merge_sessions.php b/web/merge_sessions.php index 608fee7f..e5224112 100644 --- a/web/merge_sessions.php +++ b/web/merge_sessions.php @@ -44,6 +44,10 @@ $newsessionsize = $mergerow['sessionsize']; mysqli_free_result($mergeqry); + $tableYear = date( "Y", $mergesession/1000 ); + $tableMonth = date( "m", $mergesession/1000 ); + $db_table_full = "{$db_table}_{$tableYear}_{$tableMonth}"; + foreach ($sessionids as $value) { if ($value == $newsession) { $updatequery = "UPDATE $db_sessions_table SET timestart=$newtimestart, timeend=$newtimeend, sessionsize=$newsessionsize where session=$newsession"; @@ -51,7 +55,7 @@ } else { $delquery = "DELETE FROM $db_sessions_table WHERE session = '$value'"; mysqli_query($con, $delquery) or die(mysqli_error($con)); - $updatequery = "UPDATE $db_table SET session=$newsession WHERE session=".quote_value($value); + $updatequery = "UPDATE $db_table_full SET session=$newsession WHERE session=".quote_value($value); mysqli_query($con, $updatequery) or die(mysqli_error($con)); } } diff --git a/web/pid_commit.php b/web/pid_commit.php index 639c68e2..6f2d3c6b 100644 --- a/web/pid_commit.php +++ b/web/pid_commit.php @@ -14,10 +14,16 @@ $split_data = explode(':', $field_id); $id = $split_data[1]; $field_name = $split_data[0]; -echo "\nField Name: '$field_name'\nField ID: '$id'\nValue: '$val'\n"; - if(!empty($id) && !empty($field_name) && !empty($val)) { - if($field_name == 'populated') { - if($val == 'true'){ +//echo "ID: '$id' Field Name: '$field_name' Field ID: '$id' Value: '$val'"; + if (!empty($id) && !empty($field_name)) { + if ($field_name == 'populated') { + if ($val == 'true') { + $val=1; + } else { + $val=0; + } + } elseif ($field_name == 'favorite') { + if ($val == 'true') { $val=1; } else { $val=0; @@ -25,12 +31,16 @@ } //update the values $query = "UPDATE $db_name.$db_keys_table SET ".quote_name($field_name)." = ".quote_value($val)." WHERE id = ".quote_value($id); -echo "\n$query\n"; - mysqli_query($query) || die(mysqli_error($con)); +//echo "
$query
"; + mysqli_query($con, $query) || die(mysqli_error($con)); if($field_name == 'type') { - $query = "ALTER TABLE $db_name.$db_table MODIFY ".quote_name($id)." ".mysqli_real_escape_string($con, $val)." NOT NULL DEFAULT '0'"; -echo $query; - mysqli_query($query) || die(mysqli_error($con)); + $table_list = mysqli_query($con, "SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE table_schema = '$db_name' and table_name like '$db_table%' ORDER BY table_name DESC;"); + while( $row = mysqli_fetch_assoc($table_list) ) { + $db_table_name = $row["table_name"]; + $query = "ALTER TABLE $db_name.$db_table_name MODIFY ".quote_name($id)." ".mysqli_real_escape_string($con, $val)." NOT NULL DEFAULT '0'"; +//echo "
$query
"; + mysqli_query($con, $query) || die(mysqli_error($con)); + } } echo "Updated"; } else { diff --git a/web/pid_edit.php b/web/pid_edit.php index dac2f7b0..9b7b0889 100644 --- a/web/pid_edit.php +++ b/web/pid_edit.php @@ -7,11 +7,11 @@ // 2015.08.21 - edit by surfrock66 - Rather than pull from the column comments, // oull from a new database created which manages variables. Include // a column flagging whether a variable is populated or not. -$keyqry = mysqli_query($con, "SELECT id,description,units,type,min,max,populated FROM ".$db_name.".".$db_keys_table." ORDER BY description") or die(mysqli_error($con)); +$keyqry = mysqli_query($con, "SELECT id,description,units,type,min,max,populated,favorite FROM ".$db_name.".".$db_keys_table." ORDER BY description") or die(mysqli_error($con)); $i = 0; while ($x = mysqli_fetch_array($keyqry)) { if ((substr($x[0], 0, 1) == "k") ) { - $keydata[$i] = array("id"=>$x[0], "description"=>$x[1], "units"=>$x[2], "type"=>$x[3], "min"=>$x[4], "max"=>$x[5], "populated"=>$x[6]); + $keydata[$i] = array("id"=>$x[0], "description"=>$x[1], "units"=>$x[2], "type"=>$x[3], "min"=>$x[4], "max"=>$x[5], "populated"=>$x[6], "favorite"=>$x[7]); $i = $i + 1; } } @@ -38,7 +38,7 @@ - +