restructure
This commit is contained in:
+3
-2
@@ -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"))
|
||||
|
||||
@@ -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])
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user