def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master.title("Traffic System Control - Honors Contract Design")
        self.grid(padx=20, pady=20)
        self.resetIntersections()
        self.createLaunchScreen()

        isec.simulate_hardware = True
        isec.hw_init()
                self.canvas.itemconfig(light3, fill=color[LIGHT[e]])
            else:
                self.canvas.itemconfig(light3, fill=color2[LIGHT[e]])

    def statecycle(self):
        self.cs = STATE[self.cs][1][1]
        self.chlt()
        self.chcv()
        isec.print_lights()


#isec.hw_init(simulate_hardware = False, use_one_intersection = False) # Initializes the software.
root = Tk()
root.title('Light Control System')
root.geometry('1100x500')
isec.hw_init()
isec.simulate_hardware = True  #Turns on simulation software.
isec.sensor_value_from_user = False  #Allows user to enter sensor data.
HI1 = Lights(1, root)
HI2 = Lights(2, root)
HI3 = Lights(3, root)
HI4 = Lights(4, root)
HI5 = Lights(5, root)
OBJECTS = [HI1, HI2, HI3, HI4, HI5]
thread.start_new(HI1.statecycle2, ())
thread.start_new(HI2.statecycle2, ())
thread.start_new(HI3.statecycle2, ())
thread.start_new(HI4.statecycle2, ())
thread.start_new(HI5.statecycle2, ())
Button(text=('Auto On/Off'), command=Startauto).grid(row=1, column=3)
Button(text=('Exit'),
Пример #3
0
STATE = [[[1 , 1],[ 1, 1]], #This is the array
         [[ 1 , 2],[ 1, 2]], #That controls the state, of the Finite state machine
         [[ 3, 3], [ 3, 3]], #States are reassgned based on the current state, and 
         [[ 4, 4], [ 4, 4]], #two sensor values.
         [[ 4, 4], [ 5, 5]], #This is a 3d array.
         [[ 0, 0], [ 0, 0]]] #

#light = {1:'AR', 2:'AY', 3:'AG', 4:'BR', 5:'BY', 6:'BG'} #This the dictionary used to reference lights on an intersection, (I'm lazy)
light = ['AR','AY','AG','BR','BY','BG']
color = {'AR':'#FF0000','AY':'yellow','AG':'green','BR':'#FF0000','BY':'yellow','BG':'green'}
color2 = {'AR':'#920000','AY':'#A29C04','AG':'darkgreen','BR':'#920000','BY':'#A29C04','BG':'darkgreen'}
state = [0,0,0,0,0]

isec.simulate_hardware = True #Turns on simulation software.
isec.sensor_value_from_user = False #Allows user to enter sensor data.
isec.hw_init() # Initializes the software.

root = Tk()

root.title ('Light Control System')
root.geometry ('1200x600')

frame1 = Frame(root)
frame1.grid(row=0,column=0)
frame2 = Frame(root)
frame2.grid(row=0, column=1)
frame3 = Frame(root)
frame3.grid(row=0, column=2)
frame4 = Frame(root)
frame4.grid(row=0, column=3)
frame5 = Frame(root)
Пример #4
0
                isec.light_off(self.intersection, light)
    def chcv(self):
        for light in LIGHT:
            if isec.light_status((self.intersection),light):
                self.canvas.itemconfig(self.lightcan[OVALS1[light]], fill = color[light])
                self.canvas.itemconfig(self.lightcan[OVALS2[light]], fill = color[light])
    def statecycle(self):         
        self.cs = STATE [self.cs] [1] [1]
        self.chlt()
        self.chcv()

#isec.hw_init(simulate_hardware = False, use_one_intersection = False) # Initializes the software.
root = Tk()
root.title ('Light Control System')
root.geometry ('750x700')
isec.hw_init()
isec.simulate_hardware = True #Turns on simulation software.
isec.sensor_value_from_user = False #Allows user to enter sensor data.
HI1 = Lights(root,3,3,1)
HI2 = Lights(root,1,3,2)
HI3 = Lights(root,3,5,3)
HI4 = Lights(root,5,3,4)
HI5 = Lights(root,3,1,5)
OBJECTS = [HI1,HI2,HI3,HI4,HI5]
thread.start_new(HI1.statecycle2, ())
thread.start_new(HI2.statecycle2, ())
thread.start_new(HI3.statecycle2, ())
thread.start_new(HI4.statecycle2, ())
thread.start_new(HI5.statecycle2, ())
Button(text = ('Auto On/Off'), command = Startauto).grid(row = 6, column=3)
Button(text = ('Exit'), width = '10', command = exit, bg = 'red',font=('helvetica', 15, 'underline italic')).grid(row = 7, column=3)
STATE = [[[1 , 1],[ 1, 1]], #This is the array
         [[ 1 , 1],[ 2, 2]], #That controls the state, of the Finite state machine
         [[ 3, 3], [ 3, 3]], #States are reassgned based on the current state, and 
         [[ 4, 4], [ 4, 4]], #two sensor values.
         [[ 4, 5], [ 4, 5]], #This is a 3d array.
         [[ 0, 0], [ 0, 0]]] #

#light = {1:'AR', 2:'AY', 3:'AG', 4:'BR', 5:'BY', 6:'BG'} #This the dictionary used to reference lights on an intersection, (I'm lazy)
light = ['AR','AY','AG','BR','BY','BG']
color = {'AR':'#FF0000','AY':'yellow','AG':'green','BR':'#FF0000','BY':'yellow','BG':'green'}
color2 = {'AR':'#920000','AY':'#A29C04','AG':'darkgreen','BR':'#920000','BY':'#A29C04','BG':'darkgreen'}
state = [0,0,0,0,0]

isec.simulate_hardware = True #Turns on simulation software.
isec.sensor_value_from_user = False #Allows user to enter sensor data.
isec.hw_init() # Initializes the software.

root = Tk()

root.title ('Light Control System')
root.geometry ('1200x600')

frame1 = Frame(root)
frame1.grid(row=0,column=0)
Light1 = Canvas(frame1, width=200, height=300, bg='white')  
Light1.grid(row = 2, column = 0)                
        

CANVAS = [Light1]

for a in CANVAS: