def checkSensor(self): result = None if isec.sense(self.intersection_number, self.light_name + "1") == True: self.turnSensor("on") result = True elif isec.sense(self.intersection_number, self.light_name + "1") == False: self.turnSensor("off") result = False return result
def chksens(self): if isec.sense(self.int,'A1')==True or isec.sense(self.int, 'C1') ==True: self.SensorA.set('Car Waiting In A Direction') else: self.SensorA.set('No Car') if self.int == 1: if isec.sense(self.int,'B1')==True: self.SensorB.set('Car Waiting In B Direction') if isec.sense(self.int,'B1')==True: self.SensorB.set('Car Waiting In B Direction') else: self.SensorB.set('No Car')
def chksens(self): if isec.sense(self.int, 'A1') == True or isec.sense(self.int, 'C1') == True: self.SensorA.set('Car Waiting In A Direction') else: self.SensorA.set('No Car') if self.int == 1: if isec.sense(self.int, 'B1') == True: self.SensorB.set('Car Waiting In B Direction') if isec.sense(self.int, 'B1') == True: self.SensorB.set('Car Waiting In B Direction') else: self.SensorB.set('No Car')
def statecycle2(self): while 1: while (self.var.get() == 1 and self.go == True): if self.intersection == 1: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1') or isec.sense(self.intersection,'D1')] else: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1')] self.chlt() self.chcv() #isec.print_lights() time.sleep(2) time.sleep(2) print('Auto off for' + str(self.intersection))
def statecycle2(self): while 1: while (self.var.get() == 1 and self.go == True): if self.intersection == 1: self.cs = STATE[self.cs][(isec.sense( self.intersection, 'A1') or isec.sense( self.intersection, 'C1'))][isec.sense(self.intersection, 'B1') or isec.sense(self.intersection, 'D1')] else: self.cs = STATE[self.cs][( isec.sense(self.intersection, 'A1') or isec.sense(self.intersection, 'C1'))][isec.sense( self.intersection, 'B1')] self.chlt() self.chcv() isec.print_lights() time.sleep(2) while (self.var.get() == 1 and self.go == 'stop'): for light in LIGHT: isec.light_off(self.intersection, light) self.chcv() time.sleep(0.5) self.cs = 0 self.chlt() self.chcv() time.sleep(0.5)
def statecycle2(self): while 1: while self.var.get() == 1 and self.go == True: if self.intersection == 1: self.cs = STATE[self.cs][(isec.sense( self.intersection, 'A1') or isec.sense( self.intersection, 'C1'))][isec.sense(self.intersection, 'B1') or isec.sense(self.intersection, 'D1')] else: self.cs = STATE[self.cs][( isec.sense(self.intersection, 'A1') or isec.sense(self.intersection, 'C1'))][isec.sense( self.intersection, 'B1')] for (e, light) in enumerate(LIGHT): if STATE2[self.cs][e] == 1: isec.light_on(self.intersection, light) else: isec.light_off(self.intersection, light) for (e, light3) in enumerate(self.lightcan): if isec.light_status((self.intersection), LIGHT[e]): self.canvas.itemconfig(light3, fill=color[LIGHT[e]]) else: self.canvas.itemconfig(light3, fill=color2[LIGHT[e]]) isec.print_lights() time.sleep(2)
def statecycle2(self): while 1: while (self.var.get() == 1 and self.go == True): if self.intersection == 1: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1') or isec.sense(self.intersection,'D1')] else: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1')] self.chlt() self.chcv() isec.print_lights() time.sleep(2) while (self.var.get() == 1 and self.go == 'stop'): for light in LIGHT: isec.light_off(self.intersection, light) self.chcv() time.sleep(0.5) self.cs = 0 self.chlt() self.chcv() time.sleep(0.5)
def statecycle2(self): while 1: while self.var.get() == 1 and self.go == True: if self.intersection == 1: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1') or isec.sense(self.intersection,'D1')] else: self.cs = STATE [self.cs] [(isec.sense(self.intersection,'A1') or isec.sense(self.intersection,'C1')) ] [isec.sense(self.intersection,'B1')] for (e,light) in enumerate(LIGHT): if STATE2 [self.cs] [e] == 1: isec.light_on(self.intersection, light) else: isec.light_off(self.intersection, light) for (e,light3) in enumerate(self.lightcan): if isec.light_status((self.intersection),LIGHT[e]): self.canvas.itemconfig(light3, fill = color[LIGHT[e]]) else: self.canvas.itemconfig(light3, fill = color2[LIGHT[e]]) isec.print_lights() time.sleep(2)
def statecycle(intersection, cs): state [cs] = STATE [state[cs]] [(isec.sense(intersection,'A1') or isec.sense(intersection,'C1')) ] [isec.sense(intersection,'B1')] if state [cs] == 0: # These if statments check state and # assigns light statuses based on current state. isec.light_off(intersection,light[1]) #These lines are what change the lights isec.light_off(intersection,light[2]) #from onn and off. The variable is used to select isec.light_on(intersection,light[0]) #the different intersections. Each if statment isec.light_off(intersection,light[4]) #makes different lights turn on. isec.light_off(intersection,light[5]) #The light [] is used to pass thru the dictionary isec.light_on(intersection,light[3]) #created above. elif state [cs] == 1: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[3]) isec.light_on(intersection,light[5]) elif state [cs] == 2: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[5]) isec.light_off(intersection,light[3]) isec.light_on(intersection,light[4]) elif state [cs] == 3: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) elif state [cs] == 4: isec.light_off(intersection,light[0]) isec.light_off(intersection,light[1]) isec.light_on(intersection,light[2]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) elif state [cs] == 5: isec.light_off(intersection,light[2]) isec.light_off(intersection,light[0]) isec.light_on(intersection,light[1]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) ch2() isec.print_lights()
def statecycle(intersection, cs): state [cs] = STATE [state[cs]] [(isec.sense(intersection,'A1') or isec.sense(intersection,'C1')) ] [isec.sense(intersection,'B1')] if state [cs] == 0: # These if statments check state and # assigns light statuses based on current state. isec.light_off(intersection,light[1]) #These lines are what change the lights isec.light_off(intersection,light[2]) #from onn and off. The variable is used to select isec.light_on(intersection,light[0]) #the different intersections. Each if statment isec.light_off(intersection,light[4]) #makes different lights turn on. isec.light_off(intersection,light[5]) #The light [] is used to pass thru the dictionary isec.light_on(intersection,light[3]) #created above. time.sleep(1) elif state [cs] == 1: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[3]) isec.light_on(intersection,light[5]) time.sleep(2) elif state [cs] == 2: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[5]) isec.light_off(intersection,light[3]) isec.light_on(intersection,light[4]) time.sleep(4) elif state [cs] == 3: isec.light_off(intersection,light[1]) isec.light_off(intersection,light[2]) isec.light_on(intersection,light[0]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) time.sleep(1) elif state [cs] == 4: isec.light_off(intersection,light[0]) isec.light_off(intersection,light[1]) isec.light_on(intersection,light[2]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) time.sleep(2) elif state [cs] == 5: isec.light_off(intersection,light[2]) isec.light_off(intersection,light[0]) isec.light_on(intersection,light[1]) isec.light_off(intersection,light[4]) isec.light_off(intersection,light[5]) isec.light_on(intersection,light[3]) time.sleep(4) ch2() isec.print_lights()