14
CS-260 Event Driven Programming Dick Steflik

CS-260

  • Upload
    xiang

  • View
    33

  • Download
    1

Embed Size (px)

DESCRIPTION

CS-260. Event Driven Programming Dick Steflik. What is it?. Program execution is determined by user or sensor generated events rather than the old linear (begining to end) execution of command line programs. Execution is non-linear. Embedded Systems. - PowerPoint PPT Presentation

Citation preview

Page 1: CS-260

CS-260

Event Driven ProgrammingDick Steflik

Page 2: CS-260

What is it?

• Program execution is determined by user or sensor generated events rather than the old linear (begining to end) execution of command line programs.

• Execution is non-linear

Page 3: CS-260

Embedded Systems

• Interrupts – these are usually sensor generated asynchronous real-world events.

• Usually handled by an ISS (Interrupt Servicing Subroutine) that gains control via a hardware controlled vector (automatic hardware branch).

• Ex. A microcontroller based humidifier that has a low water interrupt that automatically puts the device into a non-damaging state when it runs out of water and displays a low water message.

Page 4: CS-260

Event Handling• The IBM Series 1 (circa 1980s) process control

computer was one of the first event driven computers, it responded to external sensor generated events and was used to control industrial processes.– Programmed via EDL (Event Driven Language).– For each possible event a handler was provided, a

typical program would initialize the environment then enter a do forever loop. When an event occurred, program control would transfer from the loop to the appropriate handler, execute the handler then return to the loop.

Page 5: CS-260

GUI Event Processing• With the advent of the personal computer and

the modern day Graphical User Interface the model used for Event Processing in process control applications was extended to the GUI.– Initialize the environment

register the event generatorsloop forever (wait for an event)

– when an even occurs, put it into the event queue– the dispatcher will examine the next event in the

queue and invoke the correct handler

Page 6: CS-260

Initializing the Environment

• Mask off all events (don’t allow events)• Register all of the widgets that create events

– what they are, where they are, names

• Register the event handlers– bind the various events to their handlers

• Unmask the events (allow them to happen.

Page 7: CS-260

Event Queues

• most systems enqueue events before dispatching

• a queue may be a simple fifo but more likely a priority queue, that way some events can be dispatched before others

Page 8: CS-260

GUI Events

• Keyboard Events• Mouse Events• Screen Events (touch screens)• Pen Events

Page 9: CS-260

Cross Platform GUI Toolkits• Tcl/Tk – The Tk GUI toolkit

– Tkinter: python wrappers for Tk; open source

• GTK+ (Gimp Toolkit)– PyGTK : Python wrappers for the GTK+; open source

• wxWidgets– wxPython: Python bindings for wxWidgets; open

source

• Qt– PyQt: Python bindings for Qt; PyQt is a licensed

product (as is Qt)

Page 10: CS-260

Tkinter : Tk Interface

• a Python binding to the Tk GUI toolkit• de-facto GUI standard for Python• written by Fredrik Lundh• Python wrapper around a Tcl interpreter

embedded in the Python interpretor; this lets you mix Python and Tcl in the same program.

• “themed Tk” - Tk widgets can be themed to look like the hosting OS.

Page 11: CS-260

Toolkit Relationships

Page 12: CS-260

Previous Slide

• The previous slide shows the relationships on UNIX and LINUX systems where the toolkits are based on X11, remember X11 is a client-server display system where the app is an X-client and makes calls to xlib to send commands to an display things and uses an x-server to display them. This is very different than the way it is done on Windows

Page 13: CS-260
Page 14: CS-260

X11 Architecture

Example deployment of X server: the X server receives input from a local keyboard and mouse and displays to a screen. A web browser and a terminal emulator run on the user's workstation and a software update application runs on a remote computer but is controlled and monitored from the user's machine