working branch #1

Merged
quoije merged 9 commits from main into wip 2024-09-15 21:25:49 -04:00
37 changed files with 9965 additions and 9965 deletions
Showing only changes of commit f087478736 - Show all commits
+10 -9
View File
@@ -1,15 +1,16 @@
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.app_events import socketio
from modules import app_gps, app_events, app_car, app_account, app_gps,app_obd
import time
from gevent.pywsgi import WSGIServer
app = Flask(__name__)
socketio.init_app(app)
account = modules.app_account.Account()
obd = modules.app_obd.OBD()
car = modules.app_car.Car()
gps = modules.app_gps.get_gps()
app = Flask(__name__)
app_events.socketio.init_app(app)
account = app_account.Account()
obd = app_obd.OBD()
car = app_car.Car()
gps = app_gps.get_gps()
@app.route('/')
def index():
@@ -38,6 +39,6 @@ if __name__ == '__main__':
# app.run(debug=True, host="0.0.0.0", port="5000")
# Production
http_server = WSGIServer(('', 5000), app)
print("server on :5000")
print("server on http://localhost:5000")
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.
+2 -1
View File
@@ -1,6 +1,7 @@
from flask_socketio import SocketIO
from threading import Thread
import app_obd, time, threading
from modules import app_obd
import time, threading
socketio = SocketIO()
uptime_lock = threading.Lock()
+1 -1
View File
@@ -1,4 +1,4 @@
from app_events import socketio
from modules.app_events import socketio
from threading import Thread
class GPS:
+11 -13
View File
@@ -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 app_events import socketio
from threading import Thread
status = None
@@ -31,21 +31,20 @@ def get_speedtime():
time_now = str(date.strftime("%H:%M:%S"))
return [str(time_now), speed]
@socketio.on('obd')
def obd_connection():
if connection.is_connected():
print(obd_status[1])
socketio.emit('obd_status', obd_status[1])
app_events.socketio.emit('obd_status', obd_status[1])
print("OBD connection established.")
else:
print("OBD connection failed.")
print(obd_status[0])
socketio.emit('obd_status', obd_status[0])
socketio.emit('obd_speed', "-")
socketio.emit('obm_error', "-")
socketio.emit('obd_rpm', "-")
app_events.socketio.emit('obd_status', obd_status[0])
app_events.socketio.emit('obd_speed', "-")
app_events.socketio.emit('obm_error', "-")
app_events.socketio.emit('obd_rpm', "-")
# debug speed for testing
thread_speed = Thread(target=obd_speed)
@@ -70,12 +69,11 @@ def obd_speed():
if response.is_null():
print("No data received. #"+ str(get_speedtime()))
print(app_gps.get_gps())
socketio.emit('obd_speed', get_speedtime())
app_sql.tsv_writer()
app_events.socketio.emit('obd_speed', get_speedtime())
else:
print("Original value:", response.value)
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:
obd_speed_lock.release()
@@ -91,10 +89,10 @@ def obd_rpm():
time.sleep(1)
if response.is_null():
print("No data received. #"+ str(get_speedtime()))
socketio.emit('obd_speed', get_speedtime())
app_events.socketio.emit('obd_speed', get_speedtime())
else:
print("RPM:", response.value)
socketio.emit('obd_speed', response.value.to("kph"))
app_events.socketio.emit('obd_speed', response.value.to("kph"))
finally:
obd_rpm_lock.release()
+3 -3
View File
@@ -1,11 +1,11 @@
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 sqlite3 import Error
currentdatetime = datetime.now()
account = app_account.Account
car = app_car.Car
account = app_account.Account()
car = app_car.Car()
sCarModel = ''.join(letter for letter in car.model if letter.isalnum())
sql_file = account.name + "_" + sCarModel + ".db"
sql_path = "../db/sql/" + sql_file