diff --git a/Track_Resources/__pycache__/Block.cpython-312.pyc b/Track_Resources/__pycache__/Block.cpython-312.pyc index 4322cb07..518eb85a 100644 Binary files a/Track_Resources/__pycache__/Block.cpython-312.pyc and b/Track_Resources/__pycache__/Block.cpython-312.pyc differ diff --git a/Wayside_SW/WaysideSWandTB.py b/Wayside_SW/WaysideSWandTB.py index 4e0e42e3..053bf486 100644 --- a/Wayside_SW/WaysideSWandTB.py +++ b/Wayside_SW/WaysideSWandTB.py @@ -99,6 +99,45 @@ def __init__(self): if block.LIGHT or block.CROSSING or block.SWITCH : self.specialGreenBlocksW2.append(block) block.Wayside = "W2" + #2D array of blocks within 5 blocks of each other + self.green5blocks = [] + + for block in self.allGreenBlocks: + tempList = [] + for x in range(5,-1,-1): + temp1 = int(block.blockNum) - x - 1 + if temp1 < 1: continue + tempList.append(temp1) + for x in range(5): + temp2 = int(block.blockNum) + x + 1 + if temp2 > len(self.allGreenBlocks): continue + tempList.append(temp2) + self.green5blocks.append(tempList) + + switch1 = [5,4,3,2,1,12,13,14,15,16] + switch2 = [24,25,26,27,28,150,149,148,147,146] + switch3 = [72,73,74,75,76,101,102,103,104,105] + switch4 = [81,82,83,84,85,100,101,102,103,104] + + # Define the pattern + pattern = [slice(i, i + 5) for i in range(1,6)] + + # Apply the pattern to each switch + new_switch1 = [switch1[s] for s in pattern] + new_switch2 = [switch2[s] for s in pattern] + new_switch3 = [switch3[s] for s in pattern] + new_switch4 = [switch4[s] for s in pattern] + + # Apply the pattern to each switch + switches = [switch1, switch2, switch3, switch4] + + for switch, pattern in zip(switches, [new_switch1, new_switch2, new_switch3, new_switch4]): + for index, arr in zip(switch, pattern): + for x in arr: + if x not in self.green5blocks[index - 1]: + self.green5blocks[index - 1].append(x) + + #Defines Red line blocks self.redCrossingTriplesIDS = [] #ids of red crossing blocks @@ -442,6 +481,12 @@ def updateBlocks(self,new_data): block.occupied = True self.occupiedBlocks.append(block) + for block in sentBlocks: + blockNum = int(block[1:]) + for x in (self.green5blocks[blockNum - 1]): + if self.allGreenBlocks[x - 1].occupied: + self.sendTrainSpeedAuth.emit(0,0,0) + self.BlockOcc.setText(" ".join(sentBlocks)) if self.label_7.text() == "AUTOMATIC" : self.FileParser.parsePLC() self.blockActions() @@ -449,8 +494,7 @@ def updateBlocks(self,new_data): self.sendOccupiedBlocks.emit(self.occupiedBlocks) def receiveSpeedAuth(self,initialTrainSpeedAuthority): - self.initialTrainSpeedAuthority.append(initialTrainSpeedAuthority) - self.sendTrainSpeedAuth.emit(initialTrainSpeedAuthority) + self.sendTrainSpeedAuth.emit(initialTrainSpeedAuthority) class TestBench(QMainWindow): diff --git a/Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc b/Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc index fbad8744..a1944da8 100644 Binary files a/Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc and b/Wayside_SW/__pycache__/WaysideSWandTB.cpython-312.pyc differ