diff --git a/Car.py b/Car.py
index 83ff5c2..c6df0ad 100644
--- a/Car.py
+++ b/Car.py
@@ -54,9 +54,10 @@ class Car():
self.v=0
self.a=10
self.b=20
- self.minSpace=1
+ self.minSpace=10
self.leaderBefore=False
self.distToInter=0
+ self.timeStopped=0
self.vmax=0
@@ -418,6 +419,9 @@ class Car():
self.conduiteKrauss(self.vmax,self.leader,dt)
+ if self.v == 0:
+ self.timeStopped += dt
+
lgt=self.v*dt
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
diff --git a/CarController.py b/CarController.py
index a3193fc..a30769d 100644
--- a/CarController.py
+++ b/CarController.py
@@ -102,6 +102,8 @@ class CarController:
self.t=0
self.dt=1/60
self.spawnFailed = 0
+ self.totalStopped = 0
+ self.carsDestroyed = 0
self.infoWidget = None
@@ -174,7 +176,7 @@ class CarController:
self.cars.append(flow.spawnCar())
else:
self.spawnFailed += 1
- flow.addCar2Counter()
+ #flow.addCar2Counter()
flow.priority += 1
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
@@ -191,6 +193,8 @@ class CarController:
car.draw(painter)
def destroyCar(self, car):
+ self.carsDestroyed += 1
+ self.totalStopped += car.timeStopped
self.cars.remove(car)
def updateConstant(self, name, val):
diff --git a/main.py b/main.py
index 8508a2a..e548b79 100644
--- a/main.py
+++ b/main.py
@@ -78,6 +78,13 @@ class MainWindow(QMainWindow):
widget.setText(f"fps : {1000/t:.1f}")
widget.update()
+ widget = self.findChild(QLabel, "timeStopped")
+ controller = self.mainLoop.controller
+ if controller.carsDestroyed==0:
+ return
+ averageTimeStopped = controller.totalStopped / controller.carsDestroyed
+ widget.setText(f"temps d'arrêt : {averageTimeStopped:.2f}s/voiture \n nombre de voitures qui n'ont pas pu apparaitre : {controller.spawnFailed}")
+
@Slot(int)
def updatePhysicsFps(self,t):
widget = self.findChild(QLabel,"physicsFPS")
diff --git a/window.py b/window.py
index f3d8a0b..14bc7fc 100644
--- a/window.py
+++ b/window.py
@@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'window.ui'
##
-## Created by: Qt User Interface Compiler version 6.2.3
+## Created by: Qt User Interface Compiler version 6.3.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
@@ -27,7 +27,7 @@ class Ui_MainWindow(object):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.setEnabled(True)
- MainWindow.resize(540, 360)
+ MainWindow.resize(886, 675)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.gridLayout = QGridLayout(self.centralwidget)
@@ -93,6 +93,11 @@ class Ui_MainWindow(object):
self.generalInfos.addLayout(self.horizontalLayout_4)
+ self.timeStopped = QLabel(self.centralwidget)
+ self.timeStopped.setObjectName(u"timeStopped")
+
+ self.generalInfos.addWidget(self.timeStopped)
+
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.startButton = QPushButton(self.centralwidget)
@@ -136,7 +141,7 @@ class Ui_MainWindow(object):
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
- self.menubar.setGeometry(QRect(0, 0, 540, 27))
+ self.menubar.setGeometry(QRect(0, 0, 886, 27))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
@@ -154,6 +159,7 @@ class Ui_MainWindow(object):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.mainFps.setText(QCoreApplication.translate("MainWindow", u"Display fps", None))
self.physicsFPS.setText(QCoreApplication.translate("MainWindow", u"Physics FPS", None))
+ self.timeStopped.setText(QCoreApplication.translate("MainWindow", u"Time stopped", None))
self.startButton.setText(QCoreApplication.translate("MainWindow", u"Start", None))
self.stopButton.setText(QCoreApplication.translate("MainWindow", u"Stop", None))
# retranslateUi
diff --git a/window.ui b/window.ui
index 1fb2716..bfa99e1 100644
--- a/window.ui
+++ b/window.ui
@@ -9,8 +9,8 @@
0
0
- 540
- 360
+ 886
+ 675
@@ -42,7 +42,7 @@
-
-
+
-
-
@@ -85,6 +85,13 @@
+ -
+
+
+ Time stopped
+
+
+
-
-
@@ -132,7 +139,7 @@
0
0
- 540
+ 886
27