diff --git a/PLC_Files/PLC1.txt b/PLC_Files/PLC1.txt index 71ee5d1f..be3ac3b4 100644 --- a/PLC_Files/PLC1.txt +++ b/PLC_Files/PLC1.txt @@ -1,7 +1,11 @@ -OCCUPIED C -SWITCH A5 B6 -LIGHT !C11 +SwitchOcc or not SwitchRightOcc +SWITCH -OCCUPIED !C -SWITCH A5 C11 -LIGHT C11 +SwitchOcc or SwitchRightOcc +CurrentLIGHT + +SwitchOcc +LeftLIGHT + +not SwitchOcc and SwitchRightOcc +RightLIGHT \ No newline at end of file diff --git a/PLC_Files/PLC_Red.txt b/PLC_Files/PLC_Red.txt deleted file mode 100644 index 8d57327d..00000000 --- a/PLC_Files/PLC_Red.txt +++ /dev/null @@ -1,41 +0,0 @@ -OCCUPIED A - -LIGHT !A1 - -OCCUPIED !A - -LIGHT A1 - -OCCUPIED B - -LIGHT !B5 - -OCCUPIED !B - -LIGHT B5 - -OCCUPIED C - -LIGHT !C8 - -OCCUPIED !C - -LIGHT C8 - -OCCUPIED D - -LIGHT !C8 -CROSSING !D11 -OCCUPIED !D - -LIGHT C8 -CROSSING D11 -OCCUPIED E -SWITCH #FINISH -LIGHT !E13 - -OCCUPIED !E - -LIGHT E13 - -OCCUPIED F diff --git a/PLC_Files/Parser.py b/PLC_Files/Parser.py index 6811b9aa..26760d00 100644 --- a/PLC_Files/Parser.py +++ b/PLC_Files/Parser.py @@ -8,77 +8,26 @@ from Track_Resources.Block import Block class Parser(): - def __init__(self, inputPLC, outPuttedBlocks): + def __init__(self, inputPLC, CrossingTriplesIDS, outPuttedBlocks): self.inputPLC = inputPLC + self.CrossingTriplesIDS = CrossingTriplesIDS self.outPuttedBlocks = outPuttedBlocks - self.commandsToRun = [] - self.blockOccsByID = [False] * 26 #initially no blocks are occupied - - def blockState(self): #will break up inputPLC into what commands to run based off of conditions of occupancies - lines = self.inputPLC.split('\n') - index = 0 - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - - for char in alphabet: - occupied_blocks = [block for block in self.outPuttedBlocks if char in block.ID and block.occupied] - self.blockOccsByID[index] = True if occupied_blocks else False - index = index + 1 - - index = 0 - indexOcc = 0 - indexNotOcc = 0 - indexNextOcc = 0 - indexEnd = len(lines) - 1 - - for length in range(2,25): #start with 2 for C - if (length + 1) >= 25 or not ("OCCUPIED " + alphabet[length]) in lines: break - - isOcc = False - - if (length + 1) < 25 and "OCCUPIED " + alphabet[length + 1] in lines : indexNextOcc = lines.index("OCCUPIED " + alphabet[length + 1]) - else: indexNextOcc = indexEnd - - indexOcc = lines.index("OCCUPIED " + alphabet[length]) - indexNotOcc = lines.index("OCCUPIED !" + alphabet[length]) - - if self.blockOccsByID[length]: - isOcc = True - - if isOcc: - indexLoopStart = indexOcc + 1 - indexLoopEnd = indexNotOcc - 1 - else: - indexLoopStart = indexNotOcc + 1 - if indexNextOcc != indexEnd : indexLoopEnd = indexNextOcc - 1 - else: indexLoopEnd = indexNextOcc + 1 - - for pos in range(indexLoopStart, indexLoopEnd): - self.commandsToRun.append(lines[pos]) - def parsePLC(self): - self.blockState() - - for line in self.commandsToRun: - if line == '' : break - tokens = line.strip().split() - command = tokens[0] - parameters = tokens[1:] - block_id = parameters[0][1:] if parameters[0][0] == '!' else parameters[0] - match = [block for block in self.outPuttedBlocks if block.ID == block_id] - - if command == "LIGHT" or command == "CROSSING": - if parameters[0][0] != '!': - match[0].state = True - else: - match[0].state = False - - #CHANGE TO BE LIKE ABOVE JUST WITH DEFAULT STATES - - elif command == "SWITCH": - if int(parameters[1][1:]) - 1 == int(parameters[0][1:]): match[0].state = True - else : match[0].state = False - - self.commandsToRun = [] - - + lines = self.inputPLC.split('\n') + switchLogic, curLightLogic, leftLightLogic, rightLightLogic = lines[0], lines[3], lines[6], lines[9] + + CrossingTripleBlocks = [ + [block for row in self.CrossingTriplesIDS for element in row + for block in self.outPuttedBlocks if str(element) == str(block.ID[1:])][i:i + 3] + for i in range(0, len(self.CrossingTriplesIDS) * 3, 3) + ] + + for data in CrossingTripleBlocks: + SwitchOcc = data[0].occupied + SwitchRightOcc = data[2].occupied + + data[0].switchState = eval(switchLogic) + data[0].lightState = eval(curLightLogic) + data[1].lightState = eval(leftLightLogic) + data[2].lightState = eval(rightLightLogic) diff --git a/PLC_Files/__pycache__/Parser.cpython-311.pyc b/PLC_Files/__pycache__/Parser.cpython-311.pyc index 676c996a..66df538e 100644 Binary files a/PLC_Files/__pycache__/Parser.cpython-311.pyc and b/PLC_Files/__pycache__/Parser.cpython-311.pyc differ diff --git a/Track_Resources/Block.py b/Track_Resources/Block.py index 20dbeedc..93cf11c8 100644 --- a/Track_Resources/Block.py +++ b/Track_Resources/Block.py @@ -1,12 +1,17 @@ # Define the Block class class Block: - def __init__(self, light, crossing, switch, state,occupied,id,speedLimit,authority): - self.LIGHT = light - self.CROSSING = crossing - self.SWITCH = switch - self.state = state - self.occupied = occupied + def __init__(self, lineColor, blockSection, blockNum, hasLight, hasCrossing, hasSwitch, lightState, crossingState, switchState,id,speedLimit): + self.lineColor = lineColor + self.blockSection = blockSection + self.blockNum = blockNum + self.LIGHT = hasLight + self.CROSSING = hasCrossing + self.SWITCH = hasSwitch + self.lightState = lightState + self.crossingState = crossingState + self.switchState = switchState + self.occupied = False self.ID = id self.speedLimit = speedLimit - self.authority = authority + self.authority = None diff --git a/Track_Resources/__pycache__/Block.cpython-311.pyc b/Track_Resources/__pycache__/Block.cpython-311.pyc index e01afb1b..d2f57b4f 100644 Binary files a/Track_Resources/__pycache__/Block.cpython-311.pyc and b/Track_Resources/__pycache__/Block.cpython-311.pyc differ diff --git a/Wayside SW/Red_Line.csv b/Wayside SW/Red_Line.csv index ac6fa252..ba224b01 100644 --- a/Wayside SW/Red_Line.csv +++ b/Wayside SW/Red_Line.csv @@ -1,77 +1,77 @@ Line,Section,Block Number,Block Length (m),Block Grade (%),Speed Limit (Km/Hr),Infrastructure,Station Side,ELEVATION (M),CUMALTIVE ELEVATION (M) -Red,A,1,50,0.5,40,Light,,0.25,0.25 -Red,A,2,50,1,40,,,0.50,0.75 -Red,A,3,50,1.5,40,,,0.75,1.50 -Red,B,4,50,2,40,Light,,1.00,2.50 +Red,A,1,50,0.5,40,,,0.25,0.25 +Red,A,2,50,1,40,,,0.5,0.75 +Red,A,3,50,1.5,40,,,0.75,1.5 +Red,B,4,50,2,40,,,1,2.5 Red,B,5,50,1.5,40,,,0.75,3.25 -Red,B,6,50,1,40,,,0.50,3.75 +Red,B,6,50,1,40,,,0.5,3.75 Red,C,7,75,0.5,40,STATION: SHADYSIDE,Left/Right,0.38,4.13 -Red,C,8,75,0,40,Light,,0.00,4.13 -Red,C,9,75,0,40,SWITCH TO/FROM YARD (75-yard),,0.00,4.13 -Red,D,10,75,0,40,Light,,0.00,4.13 +Red,C,8,75,0,40,,,0,4.13 +Red,C,9,75,0,40,,,0,4.13 +Red,D,10,75,0,40,,,0,4.13 Red,D,11,75,-0.5,40,RAILWAY CROSSING,,-0.38,3.75 -Red,D,12,75,-1,40,,,-0.75,3.00 -Red,E,13,70,-2,40,Light,,-1.40,1.60 +Red,D,12,75,-1,40,,,-0.75,3 +Red,E,13,70,-2,40,,,-1.4,1.6 Red,E,14,60,-1.25,40,,,-0.75,0.85 -Red,E,15,60,-1,40,SWITCH (15-16; 1-16),,-0.60,0.25 -Red,F,16,50,-0.5,40,STATION: HERRON AVE,Left/Right,-0.25,0.00 -Red,F,17,200,-0.5,55,Light,,-1.00,-1.00 +Red,E,15,60,-1,40,SWITCH (15-16; 15-1),,-0.6,0.25 +Red,F,16,50,-0.5,40,STATION: HERRON AVE,Left/Right,-0.25,0 +Red,F,17,200,-0.5,55,,,-1,-1 Red,F,18,400,-0.06025,70,,,-0.24,-1.24 -Red,F,19,400,0,70,,,0.00,-1.24 -Red,F,20,200,0,70,,,0.00,-1.24 -Red,G,21,100,0,55,STATION; SWISSVILLE,Left/Right,0.00,-1.24 -Red,G,22,100,0,55,Light,,0.00,-1.24 -Red,G,23,100,0,55,,,0.00,-1.24 -Red,H,24,50,0,70,Light,,0.00,-1.24 -Red,H,25,50,0,70,STATION; PENN STATION; UNDERGROUND,Left/Right,0.00,-1.24 -Red,H,26,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,27,50,0,70,SWITCH (27-28; 27-76); UNDERGROUND,,0.00,-1.24 -Red,H,28,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,29,60,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,30,60,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,31,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,32,50,0,70,SWITCH (32-33; 33-72); UNDERGROUND,,0.00,-1.24 -Red,H,33,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,34,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,35,50,0,70,STATION; STEEL PLAZA; UNDERGROUND,Left/Right,0.00,-1.24 -Red,H,36,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,37,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,38,50,0,70,SWITCH (38-39; 38-71); UNDERGROUND,,0.00,-1.24 -Red,H,39,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,40,60,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,41,60,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,42,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,43,50,0,70,SWITCH (43-44; 44-67); UNDERGROUND,,0.00,-1.24 -Red,H,44,50,0,70,UNDERGROUND,,0.00,-1.24 -Red,H,45,50,0,70,STATION; FIRST AVE; UNDERGROUND,Left/Right,0.00,-1.24 -Red,I,46,75,0,70,Light,,0.00,-1.24 -Red,I,47,75,0,70,RAILWAY CROSSING,,0.00,-1.24 -Red,I,48,75,0,70,STATION; STATION SQUARE,Left/Right,0.00,-1.24 -Red,J,49,50,0,60,Light,,0.00,-1.24 -Red,J,50,50,0,60,,,0.00,-1.24 -Red,J,51,50,0,55,,,0.00,-1.24 -Red,J,52,43.2,0,55,SWITCH (52-53; 52-66),,0.00,-1.24 -Red,J,53,50,0,55,,,0.00,-1.24 -Red,J,54,50,0,55,,,0.00,-1.24 -Red,K,55,75,0.5,55,Light,,0.38,-0.87 +Red,F,19,400,0,70,,,0,-1.24 +Red,F,20,200,0,70,,,0,-1.24 +Red,G,21,100,0,55,STATION; SWISSVILLE,Left/Right,0,-1.24 +Red,G,22,100,0,55,,,0,-1.24 +Red,G,23,100,0,55,,,0,-1.24 +Red,H,24,50,0,70,,,0,-1.24 +Red,H,25,50,0,70,STATION; PENN STATION; UNDERGROUND,Left/Right,0,-1.24 +Red,H,26,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,27,50,0,70,SWITCH (27-28; 27-76); UNDERGROUND,,0,-1.24 +Red,H,28,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,29,60,0,70,UNDERGROUND,,0,-1.24 +Red,H,30,60,0,70,UNDERGROUND,,0,-1.24 +Red,H,31,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,32,50,0,70,SWITCH (32-33; 32-72); UNDERGROUND,,0,-1.24 +Red,H,33,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,34,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,35,50,0,70,STATION; STEEL PLAZA; UNDERGROUND,Left/Right,0,-1.24 +Red,H,36,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,37,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,38,50,0,70,SWITCH (38-39; 38-71); UNDERGROUND,,0,-1.24 +Red,H,39,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,40,60,0,70,UNDERGROUND,,0,-1.24 +Red,H,41,60,0,70,UNDERGROUND,,0,-1.24 +Red,H,42,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,43,50,0,70,SWITCH (43-44; 43-67); UNDERGROUND,,0,-1.24 +Red,H,44,50,0,70,UNDERGROUND,,0,-1.24 +Red,H,45,50,0,70,STATION; FIRST AVE; UNDERGROUND,Left/Right,0,-1.24 +Red,I,46,75,0,70,,,0,-1.24 +Red,I,47,75,0,70,RAILWAY CROSSING,,0,-1.24 +Red,I,48,75,0,70,STATION; STATION SQUARE,Left/Right,0,-1.24 +Red,J,49,50,0,60,,,0,-1.24 +Red,J,50,50,0,60,,,0,-1.24 +Red,J,51,50,0,55,,,0,-1.24 +Red,J,52,43.2,0,55,SWITCH (52-53; 52-66),,0,-1.24 +Red,J,53,50,0,55,,,0,-1.24 +Red,J,54,50,0,55,,,0,-1.24 +Red,K,55,75,0.5,55,,,0.38,-0.87 Red,K,56,75,0.5,55,,,0.38,-0.49 Red,K,57,75,0.5,55,,,0.38,-0.12 -Red,L,58,75,1,55,Light,,0.75,0.63 +Red,L,58,75,1,55,,,0.75,0.63 Red,L,59,75,0.5,55,,,0.38,1.01 -Red,L,60,75,0,55,STATION; SOUTH HILLS JUNCTION,Left/Right,0.00,1.01 -Red,M,61,75,-0.5,55,Light,,-0.38,0.63 +Red,L,60,75,0,55,STATION; SOUTH HILLS JUNCTION,Left/Right,0,1.01 +Red,M,61,75,-0.5,55,,,-0.38,0.63 Red,M,62,75,-1,55,,,-0.75,-0.12 Red,M,63,75,-1,55,,,-0.75,-0.87 -Red,N,64,75,-0.5,55,Light,,-0.38,-1.24 -Red,N,65,75,0,55,,,0.00,-1.24 -Red,N,66,75,0,55,,,0.00,-1.24 -Red,O,67,50,0,55,Light,,0.00,-1.24 -Red,P,68,50,0,55,Light,,0.00,-1.24 -Red,P,69,50,0,55,UNDERGROUND,,0.00,-1.24 -Red,P,70,50,0,55,UNDERGROUND,,0.00,-1.24 -Red,Q,71,50,0,55,Light,,0.00,-1.24 -Red,R,72,50,0,55,Light,,0.00,-1.24 -Red,S,73,50,0,55,Light,,0.00,-1.24 -Red,S,74,50,0,55,UNDERGROUND,,0.00,-1.24 -Red,S,75,50,0,55,UNDERGROUND,,0.00,-1.24 -Red,T,76,50,0,55,Light,,0.00,-1.24 +Red,N,64,75,-0.5,55,,,-0.38,-1.24 +Red,N,65,75,0,55,,,0,-1.24 +Red,N,66,75,0,55,,,0,-1.24 +Red,O,67,50,0,55,,,0,-1.24 +Red,P,68,50,0,55,,,0,-1.24 +Red,P,69,50,0,55,UNDERGROUND,,0,-1.24 +Red,P,70,50,0,55,UNDERGROUND,,0,-1.24 +Red,Q,71,50,0,55,,,0,-1.24 +Red,R,72,50,0,55,,,0,-1.24 +Red,S,73,50,0,55,,,0,-1.24 +Red,S,74,50,0,55,UNDERGROUND,,0,-1.24 +Red,S,75,50,0,55,UNDERGROUND,,0,-1.24 +Red,T,76,50,0,55,,,0,-1.24 diff --git a/Wayside SW/app.py b/Wayside SW/app.py index 40a3247e..2780371b 100644 --- a/Wayside SW/app.py +++ b/Wayside SW/app.py @@ -1,5 +1,6 @@ import sys import os +import re # Using Block Class as a seperate file project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) @@ -17,8 +18,9 @@ def sort_by_number(block): return int(block[1:]) # Convert the string to an integer, excluding the 'B' prefix #Function that reads all blocks from a *.csv file and assigns block attributes: -def readTrackFile(fileName): +def readTrackFile(fileName,crossingTriples): totalBlocks = [] + lightBlocks = {} fileName = "Wayside SW/" + fileName with open(fileName, "r") as fileObject: readObj = csv.reader(fileObject, delimiter=",") @@ -26,23 +28,37 @@ def readTrackFile(fileName): hasCrossingTemp = False hasSwitchTemp = False hasLightTemp = False - notNormalBlock = False + lightState = None + crossingState = None + switchState = None blockId = line[1] + line[2] if(i == 0): continue else: if(line[6] == "RAILWAY CROSSING"): hasCrossingTemp = True - notNormalBlock = True + crossingState = True + elif(line[6][0:6] == "SWITCH"): hasSwitchTemp = True - notNormalBlock = True - elif(line[6] == "Light"): - hasLightTemp = True - notNormalBlock = False - tempBlock = Block(hasLightTemp,hasCrossingTemp,hasSwitchTemp,notNormalBlock,False,blockId, line[5],None) + switchState = True + + #numbers = [part for part in line[6].split('-') if part.isdigit()] + numbers = re.findall(r'\b(\d+)-(\d+)\b', line[6]) + current = {num: False for pair in numbers for num in pair} + crossingTriples.append(list(current.keys())) + lightBlocks.update(current) + + tempBlock = Block(line[0],line[1],line[2],hasLightTemp,hasCrossingTemp,hasSwitchTemp,lightState,crossingState,switchState,blockId, line[5]) totalBlocks.append(tempBlock) - + + #Assign light values now + + for block in totalBlocks: + if block.ID[1:] in lightBlocks: + block.LIGHT = True + block.lightState = False + return totalBlocks #Return a list of all blocks within the file class MyApp(QMainWindow): @@ -56,36 +72,31 @@ def __init__(self): uic.loadUi("Wayside SW/Wayside_UI_Rough.ui",self) # Global constants for LIGHT, CROSSING, and SWITCH - LIGHT_CONST = [True, False, False, True,False] - CROSSING_CONST = [False, True, False, True,False] - SWITCH_CONST = [False, False, True, True,False] - NORMAL_CONST = [False, False, False, False, False] - - #Index [0] of each Block => True if Light - #Index [1] of each Block => True if Crossing - #Index [2] of each Block => True if Switch - #Index [3] of each Block => Default - #Index [4] of each Block => True if Occupied + LIGHT_CONST = [True, False, False, False,None,None] + CROSSING_CONST = [False, True, False, None,True,None] + SWITCH_CONST = [False, False, True, None,None,True] + SWITCH_LIGHT_CONST = [True, False, True, False,None,True] + NORMAL_CONST = [False, False, False, None,None,None] #Switch Directions self.B5_Switch_Positions = ["B6","C11"] #Defining blue line blocks - A1 = Block(*NORMAL_CONST,"A1",50,None) - A2 = Block(*NORMAL_CONST,"A2",50,None) - A3 = Block(*CROSSING_CONST,"A3",50,None) - A4 = Block(*NORMAL_CONST,"A4",50,None) - A5 = Block(*SWITCH_CONST,"A5",50,None) - B6 = Block(*LIGHT_CONST,"B6",50,None) - B7 = Block(*NORMAL_CONST,"B7",50,None) - B8 = Block(*NORMAL_CONST,"B8",50,None) - B9 = Block(*NORMAL_CONST,"B9",50,None) - B10 = Block(*NORMAL_CONST,"B10",50,None) - C11 = Block(*LIGHT_CONST,"C11",50,None) - C12 = Block(*NORMAL_CONST,"C12",50,None) - C13 = Block(*NORMAL_CONST,"C13",50,None) - C14 = Block(*NORMAL_CONST,"C14",50,None) - C15 = Block(*NORMAL_CONST,"C15",50,None) + A1 = Block("Blue",'A',1,*NORMAL_CONST,"A1",50) + A2 = Block("Blue",'A',2,*NORMAL_CONST,"A2",50) + A3 = Block("Blue",'A',3,*CROSSING_CONST,"A3",50) + A4 = Block("Blue",'A',4,*NORMAL_CONST,"A4",50) + A5 = Block("Blue",'A',5,*SWITCH_CONST,"A5",50) + B6 = Block("Blue",'B',6,*LIGHT_CONST,"B6",50) + B7 = Block("Blue",'B',7, *NORMAL_CONST,"B7",50) + B8 = Block("Blue",'B',8, *NORMAL_CONST,"B8",50) + B9 = Block("Blue",'B',9, *NORMAL_CONST,"B9",50) + B10 = Block("Blue",'B', 10, *NORMAL_CONST,"B10",50) + C11 = Block("Blue",'C',11,*LIGHT_CONST,"C11",50) + C12 = Block("Blue",'C',12,*NORMAL_CONST,"C12",50) + C13 = Block("Blue",'C',13,*NORMAL_CONST,"C13",50) + C14 = Block("Blue",'C',14,*NORMAL_CONST,"C14",50) + C15 = Block("Blue",'C',15,*NORMAL_CONST,"C15",50) #Defines an array of these blocks @@ -94,14 +105,18 @@ def __init__(self): self.SwitchBlocks = ["B5","B6","C11"] #Defines Red line blocks - self.allRedBlocks = readTrackFile("Red_Line.csv") + self.redCrossingTriplesIDS = [] #ids of red crossing blocks + self.allRedBlocks = readTrackFile("Red_Line.csv",self.redCrossingTriplesIDS) self.specialRedBlocks = [] for block in self.allRedBlocks: - if block.state == True: self.specialRedBlocks.append(block) + if block.LIGHT or block.CROSSING or block.SWITCH : self.specialRedBlocks.append(block) #Create Parser Object - self.FileParser = Parser(None,self.AllBlocks) #Currently empty onject + self.SwitchBlocksNums = [['5','6','11']] + + #self.FileParser = Parser(None,self.redCrossingTriplesIDS,self.allRedBlocks) #Currently testing red object + self.FileParser = Parser(None,self.SwitchBlocksNums,self.AllBlocks) # Buttons self.fileButton.clicked.connect(self.on_file_button_clicked) @@ -201,8 +216,8 @@ def blockActions(self): selectedBlock = self.BlockArray[selectedIndex] if selectedBlock.LIGHT and self.label_7.text(): - self.greenButton.setEnabled(not selectedBlock.state and self.label_7.text() == "MANUAL") - self.redButton.setEnabled(selectedBlock.state and self.label_7.text() == "MANUAL") + self.greenButton.setEnabled(not selectedBlock.lightState and self.label_7.text() == "MANUAL") + self.redButton.setEnabled(selectedBlock.lightState and self.label_7.text() == "MANUAL") self.upCrossingButton.setEnabled(False) self.downCrossingButton.setEnabled(False) self.switchButton.setEnabled(False) @@ -211,28 +226,28 @@ def blockActions(self): self.downCrossingButton.setStyleSheet("") self.label_11.setText("") - if selectedBlock.state: + if selectedBlock.lightState: self.greenButton.setStyleSheet('QPushButton {background-color: green; color: yellow;}') self.redButton.setStyleSheet("") - elif not selectedBlock.state: + elif not selectedBlock.lightState: self.greenButton.setStyleSheet("") self.redButton.setStyleSheet('QPushButton {background-color: red; color: yellow;}') elif selectedBlock.CROSSING and self.selectLine.isChecked(): self.greenButton.setEnabled(False) self.redButton.setEnabled(False) - self.upCrossingButton.setEnabled(not selectedBlock.state and self.label_7.text() == "MANUAL") - self.downCrossingButton.setEnabled(selectedBlock.state and self.label_7.text() == "MANUAL") + self.upCrossingButton.setEnabled(not selectedBlock.crossingState and self.label_7.text() == "MANUAL") + self.downCrossingButton.setEnabled(selectedBlock.crossingState and self.label_7.text() == "MANUAL") self.switchButton.setEnabled(False) self.greenButton.setStyleSheet("") self.redButton.setStyleSheet("") self.label_11.setText("") - if selectedBlock.state: + if selectedBlock.crossingState: self.upCrossingButton.setStyleSheet("background-color: yellow") self.downCrossingButton.setStyleSheet("") - elif not selectedBlock.state: + elif not selectedBlock.crossingState: self.upCrossingButton.setStyleSheet("") self.downCrossingButton.setStyleSheet("background-color: yellow") @@ -243,7 +258,7 @@ def blockActions(self): self.downCrossingButton.setEnabled(False) self.switchButton.setEnabled(True and self.label_7.text() == "MANUAL") - if selectedBlock.state == True: + if selectedBlock.switchState: self.label_11.setText(self.SwitchBlocks[1]) else: @@ -256,7 +271,7 @@ def blockActions(self): def greenButtonPushed(self): selectedIndex = self.blockMenu.currentIndex() - self.BlockArray[selectedIndex].state = True + self.BlockArray[selectedIndex].lightState = True self.greenButton.setEnabled(False) self.redButton.setEnabled(True) self.greenButton.setStyleSheet('QPushButton {background-color: green; color: yellow;}') @@ -265,7 +280,7 @@ def greenButtonPushed(self): def redButtonPushed(self): selectedIndex = self.blockMenu.currentIndex() - self.BlockArray[selectedIndex].state = False + self.BlockArray[selectedIndex].lightState = False self.greenButton.setEnabled(True) self.redButton.setEnabled(False) self.greenButton.setStyleSheet("") @@ -274,7 +289,7 @@ def redButtonPushed(self): def upButtonPushed(self): selectedIndex = self.blockMenu.currentIndex() - self.BlockArray[selectedIndex].state = True + self.BlockArray[selectedIndex].crossingState = True self.upCrossingButton.setEnabled(False) self.downCrossingButton.setEnabled(True) self.upCrossingButton.setStyleSheet("background-color: yellow") @@ -283,7 +298,7 @@ def upButtonPushed(self): def downButtonPushed(self): selectedIndex = self.blockMenu.currentIndex() - self.BlockArray[selectedIndex].state = False + self.BlockArray[selectedIndex].crossingState = False self.upCrossingButton.setEnabled(True) self.downCrossingButton.setEnabled(False) self.upCrossingButton.setStyleSheet("") @@ -292,7 +307,7 @@ def downButtonPushed(self): def switchButtonPushed(self): selectedIndex = self.blockMenu.currentIndex() - self.BlockArray[selectedIndex].state = not self.BlockArray[selectedIndex].state + self.BlockArray[selectedIndex].switchState = not self.BlockArray[selectedIndex].switchState current_text = self.label_11.text() if current_text == self.B5_Switch_Positions[0]: @@ -391,7 +406,7 @@ def updateBlockStates(self, arr): self.label_24.setText("") - if selectedBlock.state: + if selectedBlock.lightState: self.label_19.setText("Green") self.label_22.setText("") else: @@ -401,14 +416,14 @@ def updateBlockStates(self, arr): self.label_24.setText("") - if selectedBlock.state: + if selectedBlock.crossingState: self.label_19.setText("") self.label_22.setText("Up") else: self.label_19.setText("") self.label_22.setText("Down") elif selectedBlock.SWITCH: - if selectedBlock.state: + if selectedBlock.switchState: self.label_19.setText("") self.label_22.setText("") self.label_24.setText("B6")