working branch #1
@@ -1,15 +1,16 @@
|
|||||||
from flask import Flask, render_template, make_response, json
|
from flask import Flask, render_template, make_response, json
|
||||||
import modules.app_obd, modules.app_car, modules.app_account, modules.app_gps, time
|
from modules import app_gps, app_events, app_car, app_account, app_gps,app_obd
|
||||||
from modules.app_events import socketio
|
import time
|
||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
socketio.init_app(app)
|
|
||||||
|
|
||||||
account = modules.app_account.Account()
|
app = Flask(__name__)
|
||||||
obd = modules.app_obd.OBD()
|
app_events.socketio.init_app(app)
|
||||||
car = modules.app_car.Car()
|
|
||||||
gps = modules.app_gps.get_gps()
|
account = app_account.Account()
|
||||||
|
obd = app_obd.OBD()
|
||||||
|
car = app_car.Car()
|
||||||
|
gps = app_gps.get_gps()
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@@ -38,6 +39,6 @@ if __name__ == '__main__':
|
|||||||
# app.run(debug=True, host="0.0.0.0", port="5000")
|
# app.run(debug=True, host="0.0.0.0", port="5000")
|
||||||
# Production
|
# Production
|
||||||
http_server = WSGIServer(('', 5000), app)
|
http_server = WSGIServer(('', 5000), app)
|
||||||
print("server on :5000")
|
print("server on http://localhost:5000")
|
||||||
http_server.serve_forever()
|
http_server.serve_forever()
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import app_obd, time, threading
|
from modules import app_obd
|
||||||
|
import time, threading
|
||||||
|
|
||||||
socketio = SocketIO()
|
socketio = SocketIO()
|
||||||
uptime_lock = threading.Lock()
|
uptime_lock = threading.Lock()
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
from app_events import socketio
|
from modules.app_events import socketio
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
class GPS:
|
class GPS:
|
||||||
|
|||||||
+11
-13
@@ -1,6 +1,6 @@
|
|||||||
import obd, time, threading, app_gps, app_sql
|
from modules import app_gps, app_sql, app_events
|
||||||
|
import obd, time, threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app_events import socketio
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
status = None
|
status = None
|
||||||
@@ -31,21 +31,20 @@ def get_speedtime():
|
|||||||
time_now = str(date.strftime("%H:%M:%S"))
|
time_now = str(date.strftime("%H:%M:%S"))
|
||||||
return [str(time_now), speed]
|
return [str(time_now), speed]
|
||||||
|
|
||||||
@socketio.on('obd')
|
|
||||||
def obd_connection():
|
def obd_connection():
|
||||||
if connection.is_connected():
|
if connection.is_connected():
|
||||||
print(obd_status[1])
|
print(obd_status[1])
|
||||||
socketio.emit('obd_status', obd_status[1])
|
app_events.socketio.emit('obd_status', obd_status[1])
|
||||||
print("OBD connection established.")
|
print("OBD connection established.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("OBD connection failed.")
|
print("OBD connection failed.")
|
||||||
print(obd_status[0])
|
print(obd_status[0])
|
||||||
|
|
||||||
socketio.emit('obd_status', obd_status[0])
|
app_events.socketio.emit('obd_status', obd_status[0])
|
||||||
socketio.emit('obd_speed', "-")
|
app_events.socketio.emit('obd_speed', "-")
|
||||||
socketio.emit('obm_error', "-")
|
app_events.socketio.emit('obm_error', "-")
|
||||||
socketio.emit('obd_rpm', "-")
|
app_events.socketio.emit('obd_rpm', "-")
|
||||||
|
|
||||||
# debug speed for testing
|
# debug speed for testing
|
||||||
thread_speed = Thread(target=obd_speed)
|
thread_speed = Thread(target=obd_speed)
|
||||||
@@ -70,12 +69,11 @@ def obd_speed():
|
|||||||
if response.is_null():
|
if response.is_null():
|
||||||
print("No data received. #"+ str(get_speedtime()))
|
print("No data received. #"+ str(get_speedtime()))
|
||||||
print(app_gps.get_gps())
|
print(app_gps.get_gps())
|
||||||
socketio.emit('obd_speed', get_speedtime())
|
app_events.socketio.emit('obd_speed', get_speedtime())
|
||||||
app_sql.tsv_writer()
|
|
||||||
else:
|
else:
|
||||||
print("Original value:", response.value)
|
print("Original value:", response.value)
|
||||||
print("Value in kph:", response.value.to("kph"))
|
print("Value in kph:", response.value.to("kph"))
|
||||||
socketio.emit('obd_speed', response.value.to("kph"))
|
app_events.socketio.emit('obd_speed', response.value.to("kph"))
|
||||||
finally:
|
finally:
|
||||||
obd_speed_lock.release()
|
obd_speed_lock.release()
|
||||||
|
|
||||||
@@ -91,10 +89,10 @@ def obd_rpm():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if response.is_null():
|
if response.is_null():
|
||||||
print("No data received. #"+ str(get_speedtime()))
|
print("No data received. #"+ str(get_speedtime()))
|
||||||
socketio.emit('obd_speed', get_speedtime())
|
app_events.socketio.emit('obd_speed', get_speedtime())
|
||||||
else:
|
else:
|
||||||
print("RPM:", response.value)
|
print("RPM:", response.value)
|
||||||
socketio.emit('obd_speed', response.value.to("kph"))
|
app_events.socketio.emit('obd_speed', response.value.to("kph"))
|
||||||
finally:
|
finally:
|
||||||
obd_rpm_lock.release()
|
obd_rpm_lock.release()
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import app_obd, app_car, app_account, app_gps
|
from modules import app_obd, app_car, app_account, app_gps
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlite3 import Error
|
from sqlite3 import Error
|
||||||
|
|
||||||
currentdatetime = datetime.now()
|
currentdatetime = datetime.now()
|
||||||
account = app_account.Account
|
account = app_account.Account()
|
||||||
car = app_car.Car
|
car = app_car.Car()
|
||||||
sCarModel = ''.join(letter for letter in car.model if letter.isalnum())
|
sCarModel = ''.join(letter for letter in car.model if letter.isalnum())
|
||||||
sql_file = account.name + "_" + sCarModel + ".db"
|
sql_file = account.name + "_" + sCarModel + ".db"
|
||||||
sql_path = "../db/sql/" + sql_file
|
sql_path = "../db/sql/" + sql_file
|
||||||
|
|||||||
Reference in New Issue
Block a user