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(self):         
     self.cs = self.cs = STATE [self.cs] [1] [1]
     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()
    def statecycle(self):
        self.cs = self.cs = STATE[self.cs][1][1]
        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()
 def turnLight(self, switch, color):
     color_letter = None
     if color == "green":
         color_letter = "G"
     elif color == "yellow":
         color_letter = "Y"
     elif color == "red":
         color_letter = "R"
     if switch == "on":
         self.Canvas.itemconfig(self.gui, fill=color_bank[color])
         if self.light_name != "C" and self.light_name != "D":
             isec.light_on(self.intersection_number, self.light_name + color_letter)
     elif switch == "off":
         if self.light_name != "C" and self.light_name != "D":
             isec.light_off(self.intersection_number, self.light_name + color_letter)
     self.root.update()
 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 chlt(self):
     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)
Exemple #9
0
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 chlt(self):        
     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)
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()