added check for NCE
This commit is contained in:
parent
85e4656c1c
commit
16c715c774
@ -15,6 +15,8 @@ STARTING_VELOCITY = 130
|
||||
BEARING = 90
|
||||
# Scale speed of vehicles by factor x
|
||||
SCALING = 1
|
||||
# At x km the NCE shall happen
|
||||
NCE_KM = 0.1
|
||||
|
||||
|
||||
class Vehicle:
|
||||
@ -23,6 +25,7 @@ class Vehicle:
|
||||
timestamp: Union[datetime, None]
|
||||
_driven_kms: int
|
||||
_gps_location: geopy.Point
|
||||
_nce_happened = False
|
||||
|
||||
def __init__(self,
|
||||
vin: str,
|
||||
@ -32,12 +35,23 @@ class Vehicle:
|
||||
self._gps_location = starting_point
|
||||
self.velocity = starting_velocity
|
||||
|
||||
def daf(self, invoke_nce=False):
|
||||
@property
|
||||
def nce(self):
|
||||
nce = self._nce_happened
|
||||
if nce:
|
||||
if NCE_KM >= self._driven_kms:
|
||||
nce = True
|
||||
self._nce_happened = nce
|
||||
self.velocity = 0
|
||||
return nce
|
||||
|
||||
@property
|
||||
def daf(self):
|
||||
return DAF(vehicle_identification_number=self.vin,
|
||||
gps_location=self.gps_location,
|
||||
velocity=self.velocity,
|
||||
timestamp=self.timestamp,
|
||||
near_crash_event=invoke_nce
|
||||
near_crash_event=self.nce
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user