Slide design: Dr. Mark L. Hornick

Slides:



Advertisements
Similar presentations
Multi-threaded applications SE SE-2811 Dr. Mark L. Hornick 2 What SE1011 students are told… When the main() method is called, the instructions.
Advertisements

SE3910 Week 2, Class 2 Today Real-Time Systems Embedded Systems Other ??? Week 3 Tuesday Lab Lab start TBA SE-2811 Slide design: Dr. Mark L. Hornick Content:
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
Week 5, Day 3: Observer Today Reducing coupling with the Observer The Observer pattern in Java APIs Posting events to a UI worker thread SE-2811 Slide.
SE3910 Week 2, Class 1 Today Basic Circuits Other ??? Tomorrow Lab 2, S365 (Complete prelab BEFORE) Thursday See ScheduleSchedule SE-2811 Slide design:
Week 3, Day 1: Processes & Threads Return Quiz Processes Threads Lab: Quiz Lab 3: Strategy & Factory Patterns! SE-2811 Slide design: Dr. Mark L. Hornick.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Today TBA Tomorrow Good Friday SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1 SE3910 Week 5, Class 3.
Week 3, Day 1: Processes & Threads Processes Threads SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
SE-3910 Real-time Systems Week 5, Class 2 – Lab turn-in page is up! – Lost-and-not-found power supply – Quick-Quiz (Ungraded) – Use interrupts in a Linux/C.
Using Qt for GUI development Brad Whitlock March 2002.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
SE-1021 Software Engineering II Week 5, Class 2 Why my computer crashed Layouts Multiple action listeners Single actionPerformed method – distinguishing.
SE-3910 Real-time Systems Week 7, Class 1 – GStreamer – QT SE Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling, Some from.
Today Quiz Multithreading Options Qt socket buffers between threads Quiz today & Tuesday in lab SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Today C/C++:.h/.cpp; compiling and linking Fourier Transform (corrected) Nyquist Theorem Audio sampling rates SE-2811 Slide design: Dr. Mark L. Hornick.
Week 3, Day 2: Threads Questions about Threads “Multithreading” in Swing Lab tomorrow: Quiz Lab 3: Threading! SE-2811 Slide design: Dr. Mark L. Hornick.
CS2852 Week 3, Class 2 Today Stacks Queues SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
SE-3910 Real-time Systems Week 7, Class 1 – Announcement – GStreamer – Bins Boardshots – QT Swing & Qt Signals & Slots – Code – Example SE Dr. Josiah.
CS2852 Week 5, Class 2 Today Queue Applications Circular Queue Implementation Testing SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CS2852 Week 7, Class 1 Today Binary Search Tree Implementing add Implementing find Return Quiz 4 (second attempt) Both sections are graded SE-2811 Slide.
Today Return Quiz First release of final project template Multithreading Options Qt socket buffers between threads Tomorrow: Quiz Interthread communication.
Today Final Project “Preview” Real-time concurrency Multithreading Options pthreads qthreads GPIO.h & GPIO.cpp Quiz tomorrow & Tuesday in lab SE-2811 Slide.
Today Return Quiz First true release of final project (Lab 8) Multithreading Options Qt socket buffers between threads SE-2811 Slide design: Dr. Mark L.
Today Quiz not yet graded Final report requirements posted More on Multithreading Happens-Before in Java SE-2811 Slide design: Dr. Mark L. Hornick Content:
Today Signals Nyquist Theorem (revisited) Audio Sampling Latency and Bandwidth Scheduling Theory SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr.
Week 7, Class 1: The Command Pattern (cont.) Get Ready for Poll Everywhere Labs 2 & 3 returned Lab 7 due this evening at 11pm Quiz tomorrow at start of.
Today (or Thursday) Qt Thursday Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1 SE3910 Week 6, Lab.
CS2910 Week 8, Class 2 Today Return Quiz Look at Schedule TCP implementation! Week 8, Monday Quiz on SMTP May include some questions requiring you to interpret.
Today Quiz not yet graded (Sorry!) More on Multithreading Happens-Before in Java Other langauges with Happens-Before Happens-Before in C++ SE-2811 Slide.
Week 6, Class 3: Composite Swing composites File composites Computer composites SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Week 8, Class 3: Model-View-Controller Final Project Worth 2 labs Cleanup of Ducks Reducing coupling Finishing FactoryMethod Cleanup of Singleton SE-2811.
SE3910 Week 6, Class 1 Week 6, Class 2 (Wednesday) Quiz Week 7, Class 2 (Wednesday) Half-Exam 2 Bring Calculator!! Qt GUI Design Analog and Digital Datarates.
SE3910 Week 8, Class 2 Week 4 Lab: Please return your graded Lab 4 to me so I can enter it in my gradebook Week 7, Class 2 (Wednesday) Half-Exam 2 Done.
SE3910 Week 8, Class 3 Week 4 Lab: Please return your graded Lab 4 to me so I can enter it in my gradebook Week 9 Lab: Individual demos of working sub-modules.
Slide design: Dr. Mark L. Hornick
A Quick Java Swing Tutorial
Graphical User Interfaces
Slide Style & Content: Dr. Schilling
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
SE-3910 Real-time Systems Week 10, Class 3 Loop jamming
Slide design: Dr. Mark L. Hornick
Week 2, Day 1: The Factory Method Pattern
SE-2811 Software Component Design
Review: Java GUI Programming
Week 6, Class 2: Observer Pattern
Slide design: Dr. Mark L. Hornick
Week 7, Class 1: The Command Pattern (cont.)
Slide design: Dr. Mark L. Hornick
9. Threads SE2811 Software Component Design
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Slide design: Dr. Mark L. Hornick
Polling vs. Interrupts CS2852 4/9/2019
Zhen Jiang West Chester University
Polling vs. Interrupts CS2852 4/21/2019
SE-1021 Software Engineering II
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
9. Threads SE2811 Software Component Design
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
9. Threads SE2811 Software Component Design
Slide design: Dr. Mark L. Hornick
Presentation transcript:

Slide design: Dr. Mark L. Hornick SE3910 5/22/2018 SE3910 Week 5, Class 3 Today Qt Perhaps Physical Datarate Limits In Lab: No Quiz 17q3: 1-2,4,6-7,10-15,17,22,26-36 Print slides 20,21 on half sheets SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder Dr. Josiah Yoder

GUI Toolkits Java C# C/C++ AWT Swing SWT Java FX WPF Windows Forms CS2852 5/22/2018 GUI Toolkits Java AWT Swing SWT Java FX C# WPF Windows Forms Silverlight GTK# C/C++ Qt FLTK GTK Motif MFC SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

What makes a good toolkit? CS2852 5/22/2018 What makes a good toolkit? Make table, fill in a few elements Do “Boardshot” SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

Qt Features Fully object-oriented Utility classes 5/22/2018 Qt Features Fully object-oriented Utility classes Consistent interfaces OpenGL support Rich set of widgets (controls) Network support Database support Have native look and feel Plugin support Unicode/Internationalization support Drag and drop Customizable appearance GUI builder SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Josiah Yoder

Qt Widgets Java Swing Qt CS2852 5/22/2018 Print large for me! SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

CS2852 5/22/2018 Example QT Widgets SE3910 Real Time Systems Dr. Yoder

QT Built in Dialog Boxes CS2852 5/22/2018 QT Built in Dialog Boxes File dialog Font dialog Color dialog Printer dialog Similar to Java… SE3910 Real Time Systems Dr. Yoder

Layouts Java Qt FlowLayout GridLayout BorderLayout BoxLayout SE3910 5/22/2018 Layouts Java FlowLayout GridLayout BorderLayout BoxLayout Qt FlowLayout (ex) QGridLayout BorderLayout (ex) QHBoxLayout QVBoxLayout SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Josiah Yoder

Layouts in Java and Qt Layouts in Java Layouts in Qt (in JFrame) SE3910 5/22/2018 Layouts in Java and Qt Layouts in Java (in JFrame) setLayout(layout) add(button) Layouts in Qt (in QMainWindow) layout->add(button) widget->setLayout(layout) setCentralWidget(widget) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Josiah Yoder

Events/Signals Java Qt What Design Pattern is this? Event CS2852 5/22/2018 Events/Signals Java Event E.g. ActionEvent Event Listener E.g. ActionListener How does Java initiate an event? Qt Signal E.g. clicked() Slot E.g. on_pushButton_clicked emit What Design Pattern is this? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

CS2852 5/22/2018 Custom Events in Java How do you register an event with an event source in Java? How do you create your own event in Java? How do you fire an event in java? Define MOC and qmake on board SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

Custom Events in QT emit progressNotification(1000 * seconds); CS2852 5/22/2018 Custom Events in QT How do you register an event with an event source in QT? connect(button, SIGNAL(clicked()), qApp, SLOT(quit())); How do you create your own event in QT? signals: void clicked(); How do you fire an event in QT? emit progressNotification(1000 * seconds); Define MOC and qmake on board SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling Dr. Yoder

Threading – qthreads (with corrections) SE3910 5/22/2018 Threading – qthreads (with corrections) Java qthreads java.lang.Thread #include <QThread> No external jar needed (moc and friends take care of this) Thread t = new Thread(r) t.start(); QThread *t = new QThread; moveToThread(t); // note here interface Runnable { void run(); } QObject (e.g. QWidget (e.g. QMainWindow)) t.join(); connect the QThread::finish() signal to a slot that checks if all threads are done. Object o; QMutex synchronized(o) { … } … /* Garbage coll. */ Avoid sharing memory entirely… … see code example… ???? Dr. Josiah Yoder

Useful if you are into Qt slots/signals == events 5/22/2018 Useful if you are into Qt slots/signals == events “A QThread should be used much like a regular thread instance: prepare an object (QObject) class with all your desired functionality in it. Then create a new QThread instance, push the QObject onto it using moveToThread(QThread*) of the QObject instance and call start() on the QThread instance. That’s all.” https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/ I have successfully used this approach. SE-2811 Dr.Yoder Dr. Josiah Yoder

Qt’s connect method http://doc.qt.io/qt-5/qobject.html#connect http://doc.qt.io/qt-5/qt.html#ConnectionType-enum SE-2811 Dr.Yoder

Qt Connection types 1 2 3 0x80 Constant Value Description http://doc.qt.io/qt-5/qt.html#ConnectionType-enum Constant Value Description Qt::AutoConnection (Default) If the receiver lives inthe thread that emits the signal, Qt::DirectConnection is used. Otherwise, Qt::QueuedConnection is used. The connection type is determined when the signal is emitted. Qt::Direct Connection 1 The slot is invoked immediately when the signal is emitted. The slot is executed in the signalling thread. Qt::Queued Connection 2 The slot is invoked when control returns to the event loop of the receiver's thread. The slot is executed inhe t receiver's thread. Qt::Blocking QueuedConnection 3 Same as Qt::QueuedConnection, except that the signalling thread blocks until the slot returns. This connection must not be used if the receiver lives in the signalling thread, or else the application will deadlock. Qt::Unique Connection 0x80 This is a flag that can be combined with any one of the above connection types, using a bitwise OR. When Qt::UniqueConnection is set,QObject::connect() will fail if the connection already exists (i.e. if the same signal is already connected to the same slot for the same pair of objects). This flag was introduced in Qt 4.6. SE-2811 Dr.Yoder

Coding example. Exercise: Both the Java and Qt solutions will behave poorly if I start multiple threads. Predict how each solution will behave if I: Click start // what happens? (For Java? For Qt?) Click stop SE-2811 Dr.Yoder

Week 10 Class 1 Communicating with Qt from a Non-Qt thread SE-2811 Dr.Yoder

Need invokeMethod http://doc.qt.io/qt-4.8/qmetaobject.html#invokeMethod http://doc.qt.io/qt-4.8/qmetaobject.html#Q_ARG Code example: QMetaObject::invokeMethod(&objWithSlot, “slotMethodName”, Qt::QueuedConnection, Q_ARG(QString, QString(“Hello!”))) (But avoid smart quotes) Like SwingUtilities.invokeLater() SE-2811 Dr.Yoder

Sharing Memory If you pass a pointer through a slot, both sender and receiver will have a pointer to the same memory. Some memory management care is needed to avoid issues here. SE-2811 Dr.Yoder

Slide design: Dr. Mark L. Hornick References EB: Derek Malloy, Exploring Beaglebone, Wiley, 2015 Laplante and Ovaska, Real-Time Systems Design and Analysis, Fourth Edition, Wiley, 2012 SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder