Quick Overview of QP Frameworks and QM Tool - Quantum Leaps
Quick Overview of QP Frameworks and QM Tool - Quantum Leaps
Quick Overview of QP Frameworks and QM Tool - Quantum Leaps
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Quick</strong> <strong>Overview</strong> <strong>of</strong><br />
<strong>QP</strong> <strong>Frameworks</strong> <strong>and</strong> <strong>QM</strong> <strong>Tool</strong><br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
info@quantum-leaps.com<br />
1
<strong>QP</strong> state machine frameworks<br />
<strong>QP</strong> combines:<br />
● Hierarchical state machines (QEP)<br />
● Event-driven framework (QF)<br />
● Real-time kernels (QK/Vanilla/RTOS)<br />
● S<strong>of</strong>tware tracing (QS)<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
2 2
Active Object Computing Model<br />
active<br />
object<br />
(a)<br />
ISR1<br />
ISR2<br />
event<br />
queue<br />
(b)<br />
a<br />
e<br />
events<br />
internal<br />
state<br />
machine<br />
. . .<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
3 3
Event delivery mechanisms<br />
direct<br />
event posting<br />
Active<br />
Object 1<br />
Active<br />
Object 2<br />
. . .<br />
Active<br />
Object N<br />
multicasting a<br />
published event<br />
publish-subscribe<br />
“s<strong>of</strong>tware bus”<br />
ISR_1()<br />
ISR_2()<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
4 4
Execution Pr<strong>of</strong>iles <strong>of</strong> Vanilla <strong>and</strong> QK Kernels<br />
priority<br />
ISR produces<br />
event for highpriority<br />
task<br />
interrupt<br />
entry<br />
(2a)<br />
(3a)<br />
ISR<br />
(4a)<br />
interrupt<br />
return<br />
kernel<br />
(1a) low-priority task<br />
low-priority task (5a) K (6a)<br />
high-priority task<br />
blocking call<br />
or explicit yield<br />
time<br />
(a)<br />
priority<br />
ISR produces<br />
event for highpriority<br />
task<br />
interrupt<br />
entry<br />
(3b) (4b)<br />
ISR K<br />
kernel<br />
(5b) interrupt return<br />
high-priority task (6b) K<br />
(2b)<br />
(7b)<br />
context switch<br />
(b)<br />
(1b)<br />
low-priority task<br />
preempted<br />
low-priority task<br />
time<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
5 5
State-transition explosion<br />
C<br />
OFF<br />
oper<strong>and</strong>1<br />
OPER<br />
C<br />
C<br />
OPER<br />
DIGIT_0_9,<br />
POINT<br />
result<br />
C<br />
opEntered<br />
EQUALS<br />
OFF<br />
Traditional state<br />
machines “explode”<br />
DIGIT_0_9, POINT<br />
OFF<br />
oper<strong>and</strong>2<br />
OFF<br />
– Because <strong>of</strong> the<br />
repetitions<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
6 6
Reuse <strong>of</strong> behavior through state nesting<br />
on<br />
oper<strong>and</strong>1<br />
OPER<br />
OPER<br />
opEntered<br />
DIGIT_0_9, POINT<br />
DIGIT_0_9, POINT<br />
result<br />
EQUALS<br />
oper<strong>and</strong>2<br />
C<br />
OFF<br />
Hierarchical state<br />
machines don't explode<br />
– Because they reuse<br />
behavior<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
7 7
Manual coding a HSM in <strong>QP</strong>/C++<br />
entry /<br />
exit /<br />
on<br />
ready<br />
. . .<br />
. . .<br />
. . .<br />
. . .<br />
top<br />
QState Calc::on(Calc *me, QEvent const *e) {<br />
switch (e->sig) {<br />
case Q_ENTRY_SIG: { // entry action<br />
BSP_message("on-ENTRY");<br />
return Q_HANDLED();<br />
}<br />
case Q_EXIT_SIG: { // exit action<br />
BSP_message("on-EXIT");<br />
return Q_HANDLED();<br />
C }<br />
case Q_INIT_SIG: { // initial transition<br />
BSP_message("on-INIT");<br />
return Q_TRAN(&Calc::ready);<br />
}<br />
case C_SIG: {<br />
// state transition<br />
OFF BSP_clear(); // clear the display<br />
return Q_TRAN(&Calc::on);<br />
}<br />
case OFF_SIG: { // state transition<br />
return Q_TRAN(&Calc::final);<br />
}<br />
}<br />
return Q_SUPER(&QHsm::top); // superstate<br />
}<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
8 8
Automatic coding a HSM with <strong>QM</strong><br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
9 9
Main benefits <strong>of</strong> <strong>QP</strong><br />
Higher level <strong>of</strong> abstraction than RTOS (productivity)<br />
● You work at the level <strong>of</strong> events<br />
<strong>and</strong> state machines, not the raw RTOS<br />
● Your design is more structured,<br />
maintainable, testable, <strong>and</strong> robust<br />
Safer programming model<br />
● You don't need to use semaphores,<br />
<strong>and</strong> other such troublesome RTOS mechanisms<br />
More efficient in time <strong>and</strong> space<br />
● You use less CPU (no blocking) <strong>and</strong> less RAM (less stack space)<br />
● <strong>QP</strong> is smaller in RAM use <strong>and</strong> code size (ROM) than any RTOS!<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
10 10
Who is using <strong>QP</strong>?<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
11 11
Supported processors (bare metal)<br />
<strong>QP</strong> is very portable to 8-, 16-, 32-bit MCUs<br />
● ARM7/9, ARM Cortex<br />
● ColdFire<br />
● Nios II<br />
● M16C/R8C/M32C, H8<br />
● MSP430<br />
● AVRmega, AVRXmega<br />
● TMS320C28<br />
● PsoC<br />
● others upon request...<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
12 12
Supported operating systems<br />
<strong>QP</strong> can work with traditional OS/RTOS<br />
● Linux/embedded Linux<br />
● QNX, Integrity (POSIX)<br />
● Windows/WindowsCE<br />
● VxWorks<br />
● ThreadX<br />
● eCos<br />
● uC/OS-II<br />
● FreeRTOS.org<br />
● others...<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
13 13
Supported middleware<br />
<strong>QP</strong> can work with middleware directly (bare metal)<br />
● LwIP embedded TCP/IP stack<br />
● emWin / uC/GUI embedded GUI<br />
● others upon request...<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
14 14
<strong>QM</strong> graphical modeling tool<br />
<strong>QP</strong> is supported by the free graphical <strong>QM</strong> modeling tool<br />
● Best-in-class state machine diagramming<br />
● Automatic code generation based on <strong>QP</strong><br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
15 15
Summary<br />
<strong>QP</strong> is a lightweight event-driven, state machine framework<br />
Higher level <strong>of</strong> abstraction (productivity) <strong>and</strong> safer than a raw RTOS<br />
Excellent documentation (books, application notes, articles, manuals)<br />
<strong>QP</strong> has been used by hundreds <strong>of</strong> companies worldwide<br />
Markets: consumer, industrial, communication, medical, defense<br />
<strong>QP</strong> is supported by the free <strong>QM</strong> graphical modeling tool<br />
© <strong>Quantum</strong> <strong>Leaps</strong><br />
state-machine.com<br />
16 16