def _process(self, output):
		if output == "cross":
			DRAW._drawCross()
			self.state_label.configure(text="DEACTIVATED", fg="red")
			self.message_label.configure(text="", fg="red")
		elif output == "right_arrow":
			DRAW._draw_rigth_arrow()
			self.state_label.configure(text="DEACTIVATED:")
			self.message_label.configure(text="> waiting for user input...")
		elif output == "left_arrow":
			DRAW._draw_left_arrow()
			self.state_label.configure(text="ACTIVATED:")
			self.message_label.configure(text="> Waiting for user input...")
		elif output == "empty_circle_red":
			self.state_label.configure(text="DEACTIVATED:")
			self.message_label.configure(text="Monitor will become active in 60 seconds.")
			DRAW._draw_empty_circle()
			self.after(5000, DRAW._draw_full_circle)
			self.after(5001, self.change_to_activated)
		elif output == "full_circle_green":
			DRAW._draw_full_circle()
			self.state_label.configure(text="ACTIVATED")
			self.message_label.configure(text="")
			# print(self.fsm.state)
		elif output == "alarmed":
			print("call the code from part 2 of the assignment")
Exemplo n.º 2
0
	def _process(self, output):
		#response to red cross output
		if output == "cross":
			DRAW._drawCross()
			self.state_label.configure(text="DEACTIVATED", fg="red")
			self.message_label.configure(text="", fg="red")
		#resposne to red right arrow output
		elif output == "right_arrow":
			DRAW._draw_rigth_arrow()
			self.state_label.configure(text="DEACTIVATED:")
			self.message_label.configure(text="> waiting for user input...")
		#response to left green arrow output
		elif output == "left_arrow":
			DRAW._draw_left_arrow()
			self.state_label.configure(text="ACTIVATED:")
			self.message_label.configure(text="> Waiting for user input...")
		#response to empty red circle output
		elif output == "empty_circle_red":
			self.state_label.configure(text="DEACTIVATED:")
			self.message_label.configure(text="Monitor will become active\n in {} seconds.".format(GUI.SLEEPTIME/1000))
			DRAW._draw_empty_circle()
			#used .after to avoid the freezing of the GUI
			self.after(GUI.SLEEPTIME, DRAW._draw_full_circle)
			self.after(GUI.SLEEPTIME, self.change_to_activated)
		elif output == "full_circle_green":
			DRAW._draw_full_circle()
			self.state_label.configure(text="ACTIVATED")
			self.message_label.configure(text="")
			# print(self.fsm.state)
		elif output == "alarmed":
			SEND.sendEmail()
			SEND.sendTweet()
			CAM.take_pic()
	def __init__(self):
		super().__init__()
		
		self.geometry('300x200')
		self.configure(background="black")
		# self.text = Text(self, background='black', foreground='white', font=('Comic Sans MS', 12))
		# self.text.pack()
		self.header = Label(self, text = "IR sensor alarm", fg = "red" ,background='black')
		self.header.pack()

		self.state_label = Label(self, text = "DEACTIVATED", fg = "red", background='black',font=("Helvetica", 16))
		self.state_label.pack(pady=(70,0))

		self.message_label = Label(self, text = "", fg = "red", background='black',font=("Helvetica", 16))
		self.message_label.pack()

		self.bind('<KeyPress>', self._onKeyPress) # if any key is pressed call _onKeyPress


		# use P1 header pin numbering convention
		GPIO.setmode(GPIO.BOARD)

		# configure pin 33 as input
		GPIO.setup(GUI.IRSENSOR, GPIO.IN)

		#call _IRSensorEvevt when ir signal recieved        
		GPIO.add_event_detect(GUI.IRSENSOR, GPIO.RISING, callback=self._IRSensorEvent)

		# create instance of monitor FSM and initialize to deactivated
		self.fsm = MonitorFSM()
		self.fsm.start()
		# draw a cross for the inital deactivated state
		DRAW._drawCross()
Exemplo n.º 4
0
    def __init__(self):
        super(Application, self).__init__()
        self.lastFrameTime = time.time()
        self.runTime = 0
        self.angle = 0
        self.camera = Camera.Camera()
        self.mouse_move_valid = False
        self.mouse_last_x = None
        self.mouse_last_y = None
        self.scene = SolarSystemScene.SolarSystemScene()

        # Culling type. GL_BACK is the default.
        # glCullFace(GL_BACK)
        # glCullFace(GL_FRONT_AND_BACK)
        glEnable(GL_CULL_FACE)
        glEnable(GL_DEPTH_TEST)
        # glEnable(GL_BLEND)
        # glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE)
        # glEnable(GL_POLYGON_SMOOTH)
        # glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE)
        glLineWidth (1.5)
        # glDisable(GL_CULL_FACE)
        glMatrixMode(GL_MODELVIEW)

        glEnable(GL_LIGHTING)
        glShadeModel(GL_SMOOTH)



        # Open GL only supports up to 8 lights.
        num_lights = len(self.scene.lights)

        for light_num in range(min(num_lights, 8)):
            print("Setting light " + str(light_num))
            glEnable(get_light_enum(light_num))

        if(num_lights > 8):
            print("Warning: More than 8 lights detected in scene.")

        self.lastFrameTime = time.time()

        # Drawing initializations.
        red = (0.8, 0.1, 0.0, 1.0)

        self.triangle1 = glGenLists(1)
        glNewList(self.triangle1, GL_COMPILE)
        glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red)
        ds.TriangleEquil()
        glEndList()

        self.cube1 = glGenLists(1)
        glNewList(self.cube1, GL_COMPILE)
        glPolygonMode(GL_FRONT, GL_FILL)
        ds.DrawCube()
        glEndList()

        self.skybox = glGenLists(1)
        glNewList(self.skybox, GL_COMPILE)
        glPolygonMode(GL_FRONT, GL_FILL)
        ds.DrawSkybox()
        glEndList()

        #Skybox texture
        if(self.scene.skybox_tex != None):
            self.skybox_name = GLuint()

            glPixelStorei(GL_UNPACK_ALIGNMENT, 1)

            glGenTextures(1, self.skybox_name)
            glBindTexture(GL_TEXTURE_2D, self.skybox_name)

            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, self.scene.skybox_tex_dim,
                      self.scene.skybox_tex_dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.scene.skybox_tex)