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 #157

Merged
merged 5 commits into from
Mar 28, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Train_Controller_SW/__pycache__/NonVital.cpython-312.pyc
Train_Controller_SW/__pycache__/Power.cpython-312.pyc
Train_Controller_SW/__pycache__/Speed.cpython-312.pyc
Train_Controller_SW/__pycache__/TrainController.cpython-312.
Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc
Binary file modified CTC/__pycache__/CTC_Maintenance.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/CTC_Testbench.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/CTC_UI.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/OccupiedBlocks.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/Schedule.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/TempData.cpython-312.pyc
Binary file not shown.
Binary file modified CTC/__pycache__/Throughput.cpython-312.pyc
Binary file not shown.
49 changes: 32 additions & 17 deletions MainSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,40 @@
from Train_Model.app_trainmodel_tb import *


#Utility function to initialize clock
#Utility function to update the clock
def clock():
global time
time = time.addSecs(60)

time = time.addSecs(1)
current_time = time.toString("hh:mm")
#Pulling clock data for CTC UI

#Pulling clock data for CTC and Track Model
MainWindow.CTCwindow.displayClock(current_time)
MainWindow.TrackModelWindow.set_clock(current_time)
MainWindow.TrackModelWindow.get_time(time)


#Pulling clock data for each train in existance
for train in MainWindow.currentTrains:
train.update_time(time)



#Modifies speed of simulation based of slider on the main UI
def updateClockSpeed():
#MainWindow.horizontalSlider.
print("temp")
#timer0.setInterval(1000)
SliderValue = MainWindow.SpeedSlider.value()

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

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

#Pauses simulation as a toggle function from button on the main UI
def pauseSim():
if MainWindow.PauseButton.isChecked():
timer.stop()
MainWindow.PauseButton.setText("Unpause Simulation")
else:
timer.start()
MainWindow.PauseButton.setText("Pause Simulation")


#Starting PyQt application
UI_window = QtWidgets.QApplication(sys.argv)
Expand All @@ -65,7 +78,7 @@ def updateClockSpeed():
MainWindow.CTCwindow.sendDispatchInfo.connect(MainWindow.CTC_tb.showDispatchInfo)

#CTC to Wayside

MainWindow.CTCwindow.sendDispatchInfo.connect(MainWindow.WaysideSWwindow.receiveSpeedAuth)

#CTC to MainWindow
MainWindow.CTCwindow.create_a_train.connect(MainWindow.create_new_train)
Expand Down Expand Up @@ -98,16 +111,18 @@ def updateClockSpeed():

"""Clock Initialization"""
#Initializing Qtimer for clock
timer0 = QtCore.QTimer()
global timer
timer = QtCore.QTimer()
time = QtCore.QTime(0, 0, 0) #Hours, Minutes, Second
timer0.setInterval(100) #Interval in ms
timer0.timeout.connect(clock)
timer0.start()
timer.setInterval(1000) #Interval in ms
timer.timeout.connect(clock)
timer.start()

QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)

#Initializing Time Slider
#MainWindow.horizontalSlider.SliderRealeased(updateClockSpeed)
#Connecting Main UI functionality signals
MainWindow.SpeedSlider.sliderReleased.connect(updateClockSpeed)
MainWindow.PauseButton.clicked.connect(pauseSim)


sys.exit(UI_window.exec_())
84 changes: 57 additions & 27 deletions MainUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>394</height>
<width>424</width>
<height>455</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -20,8 +20,8 @@
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<x>20</x>
<y>50</y>
<width>61</width>
<height>61</height>
</rect>
Expand All @@ -43,9 +43,9 @@
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>100</x>
<y>20</y>
<width>241</width>
<x>40</x>
<y>10</y>
<width>351</width>
<height>16</height>
</rect>
</property>
Expand All @@ -65,8 +65,8 @@
<rect>
<x>100</x>
<y>40</y>
<width>242</width>
<height>49</height>
<width>261</width>
<height>81</height>
</rect>
</property>
<property name="styleSheet">
Expand All @@ -78,7 +78,7 @@
<property name="title">
<string>Simulation Speed Control</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1">
<item>
<layout class="QHBoxLayout" name="SpeedSliderLayout">
<property name="spacing">
Expand All @@ -99,18 +99,24 @@
</string>
</property>
<property name="text">
<string>0x Speed</string>
<string>1x Speed</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider">
<widget class="QSlider" name="SpeedSlider">
<property name="styleSheet">
<string notr="true">
background-color: white;

</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -131,15 +137,39 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="PauseButton">
<property name="text">
<string>Start Simulation</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="CurrentSpeedLabel">
<property name="text">
<string>Current Speed: 1x</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>110</x>
<y>90</y>
<x>120</x>
<y>130</y>
<width>221</width>
<height>271</height>
<height>292</height>
</rect>
</property>
<property name="styleSheet">
Expand All @@ -162,29 +192,29 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="TrainModelButton">
<item row="3" column="0">
<widget class="QPushButton" name="WaysideHW_Button">
<property name="styleSheet">
<string notr="true">
background-color: white;

</string>
</property>
<property name="text">
<string>Train Model</string>
<string>Wayside HW</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="WaysideHW_Button">
<item row="6" column="0">
<widget class="QPushButton" name="TrainModelButton">
<property name="styleSheet">
<string notr="true">
background-color: white;

</string>
</property>
<property name="text">
<string>Wayside HW</string>
<string>Train Model</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -241,29 +271,29 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="TrackModelButton">
<item row="1" column="0">
<widget class="QPushButton" name="CTC_Button">
<property name="styleSheet">
<string notr="true">
background-color: white;

</string>
</property>
<property name="text">
<string>Track Model</string>
<string>CTC</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="CTC_Button">
<item row="4" column="0">
<widget class="QPushButton" name="TrackModelButton">
<property name="styleSheet">
<string notr="true">
background-color: white;

</string>
</property>
<property name="text">
<string>CTC</string>
<string>Track Model</string>
</property>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions Main_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def create_new_train(self, TrainID):
#self.currentTrains[-1].sendSignalToTrack.(self.TrackModelWindow.recieveSignalFromTrain)



"""
UI_window = QtWidgets.QApplication(sys.argv)
window = MainUI()
Expand Down
Binary file modified PLC_Files/__pycache__/Parser.cpython-312.pyc
Binary file not shown.
Binary file modified PLC_Files/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified Track_Model/__pycache__/TrackModel.cpython-312.pyc
Binary file not shown.
Binary file modified Track_Resources/__pycache__/Block.cpython-312.pyc
Binary file not shown.
Binary file modified Track_Resources/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/Authority.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/Failure.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/NonVital.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/Power.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/Speed.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/TrainController.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Controller_SW/__pycache__/mainControl.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Model/__pycache__/app_trainmodel_tb.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Model/__pycache__/app_trainmodel_ui.cpython-312.pyc
Binary file not shown.
Binary file modified Train_Model/__pycache__/clock_test.cpython-312.pyc
Binary file not shown.
Binary file modified Wayside_HW/__pycache__/TrackController_HW.cpython-312.pyc
Binary file not shown.
Binary file modified Wayside_HW/__pycache__/TrackController_HW_TB.cpython-312.pyc
Binary file not shown.
Binary file modified Wayside_HW/__pycache__/readTrackFile.cpython-312.pyc
Binary file not shown.
Binary file modified Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/Main_UI.cpython-312.pyc
Binary file not shown.