temps d arret
This commit is contained in:
parent
48bb475e0b
commit
578c433f99
6
Car.py
6
Car.py
@ -54,9 +54,10 @@ class Car():
|
|||||||
self.v=0
|
self.v=0
|
||||||
self.a=10
|
self.a=10
|
||||||
self.b=20
|
self.b=20
|
||||||
self.minSpace=1
|
self.minSpace=10
|
||||||
self.leaderBefore=False
|
self.leaderBefore=False
|
||||||
self.distToInter=0
|
self.distToInter=0
|
||||||
|
self.timeStopped=0
|
||||||
|
|
||||||
self.vmax=0
|
self.vmax=0
|
||||||
|
|
||||||
@ -418,6 +419,9 @@ class Car():
|
|||||||
|
|
||||||
self.conduiteKrauss(self.vmax,self.leader,dt)
|
self.conduiteKrauss(self.vmax,self.leader,dt)
|
||||||
|
|
||||||
|
if self.v == 0:
|
||||||
|
self.timeStopped += dt
|
||||||
|
|
||||||
lgt=self.v*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])
|
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
|
||||||
|
@ -102,6 +102,8 @@ class CarController:
|
|||||||
self.t=0
|
self.t=0
|
||||||
self.dt=1/60
|
self.dt=1/60
|
||||||
self.spawnFailed = 0
|
self.spawnFailed = 0
|
||||||
|
self.totalStopped = 0
|
||||||
|
self.carsDestroyed = 0
|
||||||
|
|
||||||
self.infoWidget = None
|
self.infoWidget = None
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ class CarController:
|
|||||||
self.cars.append(flow.spawnCar())
|
self.cars.append(flow.spawnCar())
|
||||||
else:
|
else:
|
||||||
self.spawnFailed += 1
|
self.spawnFailed += 1
|
||||||
flow.addCar2Counter()
|
#flow.addCar2Counter()
|
||||||
flow.priority += 1
|
flow.priority += 1
|
||||||
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
||||||
|
|
||||||
@ -191,6 +193,8 @@ class CarController:
|
|||||||
car.draw(painter)
|
car.draw(painter)
|
||||||
|
|
||||||
def destroyCar(self, car):
|
def destroyCar(self, car):
|
||||||
|
self.carsDestroyed += 1
|
||||||
|
self.totalStopped += car.timeStopped
|
||||||
self.cars.remove(car)
|
self.cars.remove(car)
|
||||||
|
|
||||||
def updateConstant(self, name, val):
|
def updateConstant(self, name, val):
|
||||||
|
7
main.py
7
main.py
@ -78,6 +78,13 @@ class MainWindow(QMainWindow):
|
|||||||
widget.setText(f"fps : {1000/t:.1f}")
|
widget.setText(f"fps : {1000/t:.1f}")
|
||||||
widget.update()
|
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)
|
@Slot(int)
|
||||||
def updatePhysicsFps(self,t):
|
def updatePhysicsFps(self,t):
|
||||||
widget = self.findChild(QLabel,"physicsFPS")
|
widget = self.findChild(QLabel,"physicsFPS")
|
||||||
|
12
window.py
12
window.py
@ -3,7 +3,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
## Form generated from reading UI file 'window.ui'
|
## 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!
|
## 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():
|
if not MainWindow.objectName():
|
||||||
MainWindow.setObjectName(u"MainWindow")
|
MainWindow.setObjectName(u"MainWindow")
|
||||||
MainWindow.setEnabled(True)
|
MainWindow.setEnabled(True)
|
||||||
MainWindow.resize(540, 360)
|
MainWindow.resize(886, 675)
|
||||||
self.centralwidget = QWidget(MainWindow)
|
self.centralwidget = QWidget(MainWindow)
|
||||||
self.centralwidget.setObjectName(u"centralwidget")
|
self.centralwidget.setObjectName(u"centralwidget")
|
||||||
self.gridLayout = QGridLayout(self.centralwidget)
|
self.gridLayout = QGridLayout(self.centralwidget)
|
||||||
@ -93,6 +93,11 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
self.generalInfos.addLayout(self.horizontalLayout_4)
|
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 = QHBoxLayout()
|
||||||
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
||||||
self.startButton = QPushButton(self.centralwidget)
|
self.startButton = QPushButton(self.centralwidget)
|
||||||
@ -136,7 +141,7 @@ class Ui_MainWindow(object):
|
|||||||
MainWindow.setCentralWidget(self.centralwidget)
|
MainWindow.setCentralWidget(self.centralwidget)
|
||||||
self.menubar = QMenuBar(MainWindow)
|
self.menubar = QMenuBar(MainWindow)
|
||||||
self.menubar.setObjectName(u"menubar")
|
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)
|
MainWindow.setMenuBar(self.menubar)
|
||||||
self.statusbar = QStatusBar(MainWindow)
|
self.statusbar = QStatusBar(MainWindow)
|
||||||
self.statusbar.setObjectName(u"statusbar")
|
self.statusbar.setObjectName(u"statusbar")
|
||||||
@ -154,6 +159,7 @@ class Ui_MainWindow(object):
|
|||||||
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
|
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
|
||||||
self.mainFps.setText(QCoreApplication.translate("MainWindow", u"Display fps", None))
|
self.mainFps.setText(QCoreApplication.translate("MainWindow", u"Display fps", None))
|
||||||
self.physicsFPS.setText(QCoreApplication.translate("MainWindow", u"Physics 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.startButton.setText(QCoreApplication.translate("MainWindow", u"Start", None))
|
||||||
self.stopButton.setText(QCoreApplication.translate("MainWindow", u"Stop", None))
|
self.stopButton.setText(QCoreApplication.translate("MainWindow", u"Stop", None))
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
15
window.ui
15
window.ui
@ -9,8 +9,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>540</width>
|
<width>886</width>
|
||||||
<height>360</height>
|
<height>675</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<layout class="QVBoxLayout" name="constEdit"/>
|
<layout class="QVBoxLayout" name="constEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="generalInfos" stretch="0,0,0">
|
<layout class="QVBoxLayout" name="generalInfos" stretch="0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="2,1">
|
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="2,1">
|
||||||
<item>
|
<item>
|
||||||
@ -85,6 +85,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="timeStopped">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time stopped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
@ -132,7 +139,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>540</width>
|
<width>886</width>
|
||||||
<height>27</height>
|
<height>27</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user