Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abby branch #168

Merged
merged 4 commits into from
Mar 30, 2024
Merged
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
5 changes: 3 additions & 2 deletions CTC/CTC_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def displayClock(self, time):
self.create_a_train.emit(i[1])

#Train ID, speed, Authority
self.sendDispatchInfo.emit([i[1], 70, 900])
self.sendDispatchInfo.emit([i[1], 70, self.trainSchedule.AuthorityInfo[int(i[1][1:]) - 1]])
print(i[1], "Dispatched")

#Initializing where the train starts
Expand Down Expand Up @@ -311,7 +311,8 @@ def updateOccupiedBlocks(self, arr):
for i in arr:
TrainID = self.occupiedBlocks.matchOccupanciesToTrains(i[0], i[1])
self.occupiedBlocks.BlockDataNew.append([TrainID, i[0], i[1]])
self.occupiedBlocks.currentTrains[int(TrainID[1:]) - 1].append(i[0])
if TrainID != 'X':
self.occupiedBlocks.currentTrains[int(TrainID[1:]) - 1].append(i[0])

#print(self.occupiedBlocks.currentTrains)

Expand Down
7 changes: 6 additions & 1 deletion CTC/Schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Schedule():
def __init__(self):
self.Scheduledata = []
self.departureInfo = []
self.AuthorityInfo = []
self.TrackData = TempData()

#Function to add a single train to the schedule
Expand Down Expand Up @@ -51,12 +51,14 @@ def calculateDeparture(self, Destination, ArrivalTime, Departure, line):

#Calculating Departure Time
TravelTime = 0
Authority = 0

if line == 'green':
for i in range(len(self.TrackData.GreenRouteInfo)):
if self.TrackData.GreenRouteInfo[i][0] == DepartureStation:
for j in range(i + 1, len(self.TrackData.GreenRouteInfo)):
TravelTime += float(self.TrackData.GreenRouteInfo[j][1])
Authority += float(self.TrackData.GreenRouteInfo[j][2])

if self.TrackData.GreenRouteInfo[j][0] == Destination:
break
Expand All @@ -67,6 +69,7 @@ def calculateDeparture(self, Destination, ArrivalTime, Departure, line):
if self.TrackData.RedRouteInfo[i][0] == DepartureStation:
for j in range(i + 1, len(self.TrackData.RedRouteInfo)):
TravelTime += float(self.TrackData.RedRouteInfo[j][1])
Authority += float(self.TrackData.GreenRouteInfo[j][2])

if self.TrackData.RedRouteInfo[j][0] == Destination:
break
Expand All @@ -78,6 +81,8 @@ def calculateDeparture(self, Destination, ArrivalTime, Departure, line):

Departure.append(DepartureTime)

self.AuthorityInfo.append(Authority)




Expand Down
2 changes: 1 addition & 1 deletion CTC/TestSchedule.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Line,TrainID,Destination,ArrivalTime
green,T1,Glenbury,00:05
green,T1,Popular,00:14
4 changes: 3 additions & 1 deletion MainSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def updateClockSpeed():

timer.setInterval(int(1000 / SliderValue))
timer.timeout.connect(clock)
timer.start()

if not MainWindow.PauseButton.isChecked():
timer.start()

MainWindow.CurrentSpeedLabel.setText("Current Speed: "+str(SliderValue)+"x")

Expand Down