Skip to content

Commit

Permalink
Merge pull request #166 from asmithie13/TCTMI
Browse files Browse the repository at this point in the history
Tctmi sending acc velocity to track model
  • Loading branch information
21AQN01 authored Mar 29, 2024
2 parents 99bf70d + c278b67 commit 07bf45c
Show file tree
Hide file tree
Showing 35 changed files with 103 additions and 54 deletions.
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.
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.
13 changes: 9 additions & 4 deletions Train_Controller_SW/Authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ def Authority_Monitor(self):
#calculate authority using d=r*t
self.rate = self.ui.lcdCurSpd.value()*1.46667 #mph to fps
self.time = 1
self.ui.lcdAuth.display(self.ui.lcdAuth.value() - self.rate*self.time) #auth = auth - rate*time
if(not(self.ui.lcdAuth.value() == 0) and not(self.ui.lcdCurSpd.value)):
self.ui.lcdAuth.display(self.ui.lcdAuth.value() - int(self.rate*self.time)) #auth = auth - rate*time


if self.ui.lcdAuth.value() != 0:

#authority in m from ft
self.AuthM = self.ui.lcdAuth.value()*0.3048

# in order to get most accurate stopping distance we use this
#self.AuthM = self.ui.lcdAuth.value()*0.3048

self.AuthM = self.decimal_m_auth

#current speed in m/s from mph
self.V_i = self.ui.lcdCurSpd.value()*0.44704
Expand Down Expand Up @@ -66,6 +71,6 @@ def Control_Doors(self,door):

def Control_Authority(self,auth):
self.decimal_m_auth = auth
print(auth)
self.ui.lcdAuth.display(int(auth * 3.28084))
if(self.ui.lcdAuth.value() != 0):
self.ui.vertSliderPow.setDisabled(False)
self.ui.vertSliderPow.setEnabled(True)
44 changes: 27 additions & 17 deletions Train_Controller_SW/Failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,42 @@ def __init__(self,ui,ebrake_sig, ebrake_disable_sig):
self.ebrake_disable_sig = ebrake_disable_sig


def Control_Emergency_Brake(self):
def Control_Emergency_Brake(self,ebrake_in):
if self.ui.Ebrake.isChecked() == True:
enable = True
self.ebrake_disable_sig.emit(0)

self.ebrake_disable_sig.emit(1)

elif ebrake_in == True:
if self.ui.Ebrake.isChecked() == False:
self.ui.Ebrake.toggle()
enable = True
else:
if self.ui.Ebrake.isChecked() == True:
self.ui.Ebrake.toggle()
enable = False
self.ebrake_disable_sig.emit(1)
self.ebrake_disable_sig.emit(0)





if(not(self.ui.buttonAuto.isChecked())):
self.ui.buttonDoorL.setDisabled(enable)
self.ui.buttonDoorR.setDisabled(enable)
self.ui.temp.setDisabled(enable)
self.ui.buttonHDoff.setDisabled(enable)
self.ui.buttonHDon.setDisabled(enable)
self.ui.IntLightSld.setDisabled(enable)
self.ui.lineEditAnn.setDisabled(enable)
self.ui.vertSliderBrk.setDisabled(enable)
self.ui.vertSliderPow.setDisabled(enable)
self.ui.inputKi.setDisabled(enable)
self.ui.inputKp.setDisabled(enable)

self.ebrake_sig.emit(enable)
self.ui.buttonAuto.setDisabled(enable)
self.ui.buttonMan.setDisabled(enable)
self.ui.buttonDoorL.setDisabled(enable)
self.ui.buttonDoorR.setDisabled(enable)
self.ui.temp.setDisabled(enable)
self.ui.buttonHDoff.setDisabled(enable)
self.ui.buttonHDon.setDisabled(enable)
self.ui.IntLightSld.setDisabled(enable)
self.ui.lineEditAnn.setDisabled(enable)
self.ui.vertSliderPow.setValue(0)
self.ui.vertSliderBrk.setValue(0)
self.ui.vertSliderBrk.setDisabled(enable)
self.ui.vertSliderPow.setDisabled(enable)
self.ui.inputKi.setDisabled(enable)
self.ui.inputKp.setDisabled(enable)



def Control_Signal_Failure(self,sig_fail):
Expand Down
2 changes: 2 additions & 0 deletions Train_Controller_SW/Power.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ def calculate_power(self):
self.ui.lcdBrk.display(self.ui.vertSliderBrk.value())
self.ui.lcdAcel.display(self.power)
self.curr_power_sig.emit(self.power)
print("Curr Power")
print(self.power)

2 changes: 1 addition & 1 deletion Train_Controller_SW/Speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def Speed_Monitor(self):

#this case only is used in automatic mode, if we are in manual mode the train driver can drive how they please
elif current_speed < ((speed_limit or cmd_speed) and (self.ui.buttonAuto.isChecked() == True)):
self.ui.vertSliderPow.setValue(1)
self.ui.vertSliderPow.setValue(100)
self.ui.vertSliderBrk.setValue(0)

#this case only is used in automatic mode, if we are in manual mode the train driver can drive how they please
Expand Down
19 changes: 11 additions & 8 deletions Train_Controller_SW/TrainController.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self):
self.curr_spd_lim_sig.connect(self.Vital_Speed.Control_Speed_Limit)
self.curr_auth_sig.connect(self.Vital_Authority.Control_Authority)
self.curr_temp_sig.connect(self.NonVital.Cabin_Temperature)
self.ebrake_sig.connect(self.ui.Ebrake.setChecked)
self.ebrake_sig.connect(self.Vital_Failure.Control_Emergency_Brake)
self.pwr_fail_sig.connect(self.Vital_Failure.Control_Power_Failure)
self.brk_fail_sig.connect(self.Vital_Failure.Control_Brake_Failure)
self.sig_fail_sig.connect(self.Vital_Failure.Control_Signal_Failure)
Expand All @@ -81,7 +81,7 @@ def __init__(self):
self.time_sig.connect(self.Timer)

#connecting UI buttons to functions
self.ui.Ebrake.clicked.connect(lambda : self.Vital_Failure.Control_Emergency_Brake())
self.ui.Ebrake.clicked.connect(lambda : self.Vital_Failure.Control_Emergency_Brake(0))
self.ui.buttonMan.clicked.connect(lambda : self.Control_Manual())
self.ui.buttonAuto.clicked.connect(lambda : self.Control_Automatic())
#self.ui.temp.valueChanged.connect(lambda : self.NonVital.Cabin_Temperature())
Expand All @@ -97,7 +97,8 @@ def __init__(self):
#self.ui.lcdAuth.valueChanged.connect(lambda :self.Vital_Authority.authTimerStart())

#sending off signals in manual mode
self.ui.buttonDoorL.clicked.connect(lambda : self.NonVital.Control_DoorL())
self.ui.buttonDoorL.clicked.connect(lambda : self.NonVital.Door())
self.ui.buttonDoorR.clicked.connect(lambda : self.NonVital.Door())
self.ui.IntLightSld.valueChanged.connect(lambda : self.int_light_sig.emit(self.ui.IntLightSld.value()))


Expand All @@ -110,6 +111,9 @@ def __init__(self):
#self.ui.SigFail.stateChanged.connect(self.Vital_Failure.Control_Signal_Failure())
#self.ui.Ebrake.stateChanged.connect(self.Vital_Failure.Control_Emergency_Brake())

#temporary ADD SPEED LIM
self.curr_spd_lim_sig.emit(30)

## add for doors
self.window.show()

Expand All @@ -125,10 +129,9 @@ def Control_Automatic(self):
self.ui.inputKi.setDisabled(True)
self.ui.inputKp.setDisabled(True)

#CHAD FIX THIS
#self.ui.Speed_Montior()
self.ui.vertSliderPow.setDisabled(True)
self.ui.vertSliderBrk.setDisabled(True)
self.Vital_Speed.Speed_Monitor()
#self.ui.vertSliderPow.setDisabled(True)
#self.ui.vertSliderBrk.setDisabled(True)

def Control_Manual(self):
self.ui.buttonAuto.toggle()
Expand All @@ -146,7 +149,7 @@ def Control_Manual(self):
self.ui.vertSliderPow.setDisabled(True)
else:
self.ui.vertSliderPow.setDisabled(False)
self.ui.vertSliderBrk.setDisabled(False)
self.ui.vertSliderBrk.setDisabled(False)

def Timer(self, time):
hours, minutes, seconds = [int(part) for part in time.split(':')]
Expand Down
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.
6 changes: 3 additions & 3 deletions Train_Controller_SW/mainControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ def setupUi(self, MainWindow):
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.lcdSpdLim = QtWidgets.QLCDNumber(self.groupBox_8)
self.lcdSpdLim.setDigitCount(2)
self.lcdSpdLim.setDigitCount(3)
self.lcdSpdLim.setObjectName("lcdSpdLim")
self.horizontalLayout_6.addWidget(self.lcdSpdLim)
self.lcdCmdSpd = QtWidgets.QLCDNumber(self.groupBox_8)
self.lcdCmdSpd.setDigitCount(2)
self.lcdCmdSpd.setDigitCount(3)
self.lcdCmdSpd.setObjectName("lcdCmdSpd")
self.horizontalLayout_6.addWidget(self.lcdCmdSpd)
self.lcdCurSpd = QtWidgets.QLCDNumber(self.groupBox_8)
self.lcdCurSpd.setDigitCount(2)
self.lcdCurSpd.setDigitCount(3)
self.lcdCurSpd.setObjectName("lcdCurSpd")
self.horizontalLayout_6.addWidget(self.lcdCurSpd)
self.gridLayout_5.addLayout(self.horizontalLayout_6, 1, 0, 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion Train_Model/TrainModel_UI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ selection-color: rgb(99, 99, 99);
</string>
</property>
<property name="text">
<string>EMERGENCY STOP</string>
<string>EMERGENCY BRAKE</string>
</property>
<property name="checkable">
<bool>false</bool>
Expand Down
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.
69 changes: 49 additions & 20 deletions Train_Model/app_trainmodel_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
class TrainModel_mainwindow(QMainWindow):

#in mph
commanded_speed_def=50
commanded_speed_def=0
#in lbs
mass_def=125002.1
mass_def=0
#in seconds
time_def=10
time_def=0

#Track Model Signals
track_model_acc_velo = qtc.pyqtSignal(int)

def __init__(self):
super().__init__()
uic.loadUi("Train_Model/TrainModel_UI.ui", self)
Expand All @@ -46,16 +49,15 @@ def __init__(self):
self.TC.curr_power_sig.connect(self.get_power_input)
self.TC.announcement_sig.connect(self.set_announcements)
self.TC.temp_control_sig.connect(self.set_cabin_temp)
self.TC.ebrake_disable_sig.connect(self.change_ebrake_color)

#self.TC.ebrake_disable_sig.connect(self.change_ebrake_color)


self.train_calculations.Calculate_acceleration()
self.train_calculations.calculate_force()
self.train_calculations.get_acceleration()
self.train_calculations.calculate_acc_velocity()

self.estop_locked=False

#changing state when sig_fail_enable/disable are clicked
self.sig_fail_enable.clicked.connect(self.sig_fail_enable_clicked)
self.sig_fail_disable.clicked.connect(self.sig_fail_disable_clicked)
Expand All @@ -69,6 +71,11 @@ def __init__(self):
self.en_fail_disable.clicked.connect(self.en_fail_disable_clicked)
#self.brake_fail_input_tb.stateChanged.connect(self.brake_fail_tb)

self.ebrake.setCheckable(True)
#ebrake signals
self.ebrake.clicked.connect(lambda : self.ebrake_activated(1))
self.TC.ebrake_disable_sig.connect(self.ebrake_disabled)

#Initially setting the default colors
self.bf_enable.setStyleSheet('background-color: rgb(233, 247, 255);')
self.bf_disable.setStyleSheet('background-color: rgb(38, 207, 4);')
Expand All @@ -84,6 +91,8 @@ def __init__(self):
self.en_fail_state = False
self.emergency_stop_state=False



def Return_TrainController(self):
return self.TC

Expand All @@ -102,31 +111,45 @@ def get_power_input(self, power_input):

#sending authority to train controller [ASK LAUREN AND CHAD]
def receiveSpeedAuth_tm(self,speedAuth):
print("train model is receiving comm speed and auth")
trainID=speedAuth[0]
Comm_Speed=speedAuth[1]
self.train_calculations.get_commanded_speed(float(Comm_Speed))
Authority=speedAuth[2]
print("hiiiiii", speedAuth)
print("speedAuth",speedAuth)
#self.sendSpeedAuth.emit(speedAuth)
#self.main_window.cspeed_display.setText(str(Comm_Speed))
# self.send_com_speed_tb.emit(str(Comm_Speed))
# self.send_authority_tb.emit(str(Authority))
self.TC.curr_cmd_spd_sig.emit(int(Comm_Speed))
self.TC.curr_auth_sig.emit(float(Authority))


def estop_button_clicked(self):
if not self.emergency_stop_state:
self.ebrake.setStyleSheet('background-color: rgb(99, 99, 99);')
self.emergency_stop_state = True

def change_ebrake_color(self,ebrake_state):
if ebrake_state:
self.ebrake.setStyleSheet('background-color: rgb(99, 99, 99);')
# def estop_button_clicked(self,state):
# self.emergency_stop_state=state
# if not state:
# self.ebrake.setStyleSheet('background-color: rgb(99, 99, 99);')
# self.emergency_stop_state = True
# self.TC.ebrake_sig.emit(state)

else:
self.ebrake.setStyleSheet('background-color: rgb(195, 16, 40);')
def TC_ebrake_activated(self,state):
self.ebrake.toggle()
if(self.ebrake.isChecked()):
self.ebrake.setCheckable(False)



self.TC.ebrake_sig.emit(ebrake_state)
def ebrake_activated(self,state):
self.ebrake.setCheckable(False)
self.TC.ebrake_sig.emit(1)

def ebrake_disabled(self,ebrake_state):
self.ebrake.setCheckable(True)
self.ebrake.toggle()




def set_length(self, input_txt):
self.length_of_vehicle_display.setText(input_txt)

Expand Down Expand Up @@ -291,6 +314,11 @@ def left_doors(self,state):
self.left_doors_value.setFixedSize(109, 97)
self.left_doors_value.setText('OPEN')

def acc_vel_to_track_model(self,velocity):
velocity=self.train_calculations.calculate_acc_velocity
self.track_model_acc_velo.emit(int(velocity))


#CLASS CONTAINING ALL TRAIN CALCULATIONS
class TrainCalculations:

Expand Down Expand Up @@ -346,6 +374,7 @@ def calculate_acc_velocity(self):
velocity = initial_velocity + (acceleration * time)
self.main_window.Acc_Velo_value_lcd.display(velocity)
self.TC.curr_spd_sig.emit(int(velocity))
return int(velocity)



Expand Down Expand Up @@ -610,9 +639,9 @@ def display_announcement(self):
#set ccount
window_tb.ccount_input_signal.connect(window.set_ccount)
#set ebrake
window_tb.ebrake_input_signal.connect(window.change_ebrake_color)
#window_tb.ebrake_input_signal.connect(window.change_ebrake_color)
#estop manual
window.ebrake.clicked.connect(window.estop_button_clicked)

#brake_fail
window_tb.brake_fail_input_signal.connect(window.brake_fail_tb)
#signal_fail
Expand Down
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.

0 comments on commit 07bf45c

Please sign in to comment.