working branch #1

Merged
quoije merged 9 commits from main into wip 2024-09-15 21:25:49 -04:00
4 changed files with 20 additions and 31 deletions
Showing only changes of commit 286649e9c3 - Show all commits
+3 -2
View File
@@ -1,4 +1,4 @@
import obd, time, threading, app_gps
import obd, time, threading, app_gps, app_sql
from datetime import datetime
from app_events import socketio
from threading import Thread
@@ -66,11 +66,12 @@ def obd_speed():
while loop == True:
global speed
speed = speed + 1
time.sleep(1)
time.sleep(10)
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()
else:
print("Original value:", response.value)
print("Value in kph:", response.value.to("kph"))
+17
View File
@@ -0,0 +1,17 @@
import csv, os
import app_obd, app_car, app_account, app_gps
from datetime import datetime
currentday = datetime.today().strftime("%d%m%Y")
currenttime = datetime.now().strftime("%H_%M_%S")
account = app_account.Account
car = app_car.Car
sCarModel = ''.join(letter for letter in car.model if letter.isalnum())
sql_name = account.name + "_" + sCarModel + "_" + currentday + ".sql"
sql_path = "../db/sql/"
# ## VN, NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER
# (["VN", "NAME", "DATE", "TIME", "GPSX", "GPSY", "SPEED", "ODOMETER"])
# ([car.model, account.name, currentday, currenttime, GPSX, GPSY, SPEED, ODOMETER])
-25
View File
@@ -1,25 +0,0 @@
import csv, os
import app_obd, app_car, app_account, app_gps
from datetime import datetime
currentday = datetime.today().strftime("%d%m%Y")
currenttime = datetime.now().strftime("%H_%M_%S")
account = app_account.Account
car = app_car.Car
sCarModel = ''.join(letter for letter in car.model if letter.isalnum())
tsv_name = account.name + "_" + sCarModel + "_" + currentday + "_" + currenttime + ".tsv"
tsv_path = "../db/tsv/" + tsv_name
def tsv_writer(bExist):
with open(tsv_path, 'w') as o_file:
## VN, NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER
writer = csv.writer(o_file, delimiter='\t')
if bExist == False:
writer.writerow(["VN", "NAME", "DATE", "TIME", "GX", "GY", "SPEED", "ODO"])
else:
writer.writerow([car.model, account.name, currentday, currenttime])
if os.path.exists(tsv_path):
tsv_writer(True)
else:
tsv_writer(False)
-4
View File
@@ -1,4 +0,0 @@
## TSV File to MangoDB
## ACCOUNT_VN_20240401_00_00_00.TSV
##
## VN NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER
1 ## TSV File to MangoDB
2 ## ACCOUNT_VN_20240401_00_00_00.TSV
3 ##
4 ## VN NAME, DATE, TIME, GPS_X, GPS_Y, SPEED, ODOMETER