Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions base/enginecurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from os.path import exists

from os import makedirs
from os import makedirs, remove
makedirs('curves/', exist_ok=True) #create curves folder if not exists

from utility import np_drag_fit, simplify_curve, round_to
Expand All @@ -31,7 +31,7 @@ class EngineCurve():
DELIMITER = '\t'
ENCODING = 'ISO-8859-1' #why not UTF-8?
FOLDER = 'curves'
FILENAME = lambda _, gtdp: f'{EngineCurve.FOLDER}/{gtdp.car_ordinal}.tsv'
FILENAME = lambda _, ordinal: f'{EngineCurve.FOLDER}/{ordinal}.tsv'
ROUND = 100 #round the saved curve to multiples of round
ROUND_REVLIMIT = 50 #covers 99.9% of all standard revlimits

Expand All @@ -41,9 +41,15 @@ def __init__(self, config, *args, **kwargs):
for var in ['curve_state', 'rpm', 'power', 'torque', 'revlimit']:
setattr(self, var, None)

def reset(self):
def reset(self, ordinal=None):
for var in ['curve_state', 'rpm', 'power', 'torque', 'revlimit']:
setattr(self, var, None)
if ordinal is not None:
filename = self.FILENAME(ordinal)
try:
remove(filename)
except Exception:
pass

def is_loaded(self):
return self.curve_state == True
Expand All @@ -53,7 +59,7 @@ def update(self, gtdp, *args, **kwargs):
if self.curve_state:
return #this should not happen though

filename = self.FILENAME(gtdp)
filename = self.FILENAME(gtdp.car_ordinal)
if exists(filename): #file exists
self.load(filename)
self.curve_state = True
Expand Down
2 changes: 1 addition & 1 deletion base/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def init_vars(self):
def reset(self, *args):
self.rpm.reset()
self.history.reset()
self.curve.reset(self.car_ordinal.get())
self.car_ordinal.reset()
self.gears.reset()
self.lookahead.reset()
self.datacollector.reset()
self.revlimit.reset()
self.curve.reset()
# self.shiftdump.reset()

self.we_beeped = 0
Expand Down
4 changes: 2 additions & 2 deletions gui/enginecurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ def update(self, gtdp, *args, **kwargs):
if self.is_loaded():
self.enable()

def reset(self):
super().reset()
def reset(self, ordinal):
super().reset(ordinal)
self.disable()

#enable the button in the GUI
Expand Down