Date post: | 23-Jun-2015 |
Category: |
Technology |
Upload: | miro-samek |
View: | 21,229 times |
Download: | 1 times |
2 2© Quantum Leapsstate-machine.com
QP state machine frameworksQP combines:● Hierarchical state machines (QEP)● Event-driven framework (QF)● Real-time kernels (QK/Vanilla/RTOS)● Software tracing (QS)
3 3© Quantum Leapsstate-machine.com
Active Object Computing Model
ISR1 ISR2
. . .
events
eventqueue
e = queue.get();
dispatch(e);
active object’sevent loop
init();
(a) (b)
internal statemachine
activeobject
blockingoperation
4 4© Quantum Leapsstate-machine.com
Event delivery mechanisms
ISR_1() ISR_2()
Active Object 1
Active Object 2
Active Object N
directevent posting
publish-subscribe “software bus”
. . .
multicasting a published event
5 5© Quantum Leapsstate-machine.com
Execution Profiles of Vanilla and QK Kernels(a)
low-priority task time
prio
rity
high-priority task
low-priority task
interruptentry
blocking callor explicit yield
interruptreturn
K
kernel
(b)
low-priority task time
high-priority task
low-priority task
interruptentry
context switch
interrupt return
K
kernel
(2a)
(3a)
(4a)
(1a) (5a) (6a)
(1b)
(2b)
(3b) (4b)ISR
(5b)
(6b)
(7b)
ISR producesevent for high-priority task
prio
rity
ISR producesevent for high-priority task
ISR
K
preempted
6 6© Quantum Leapsstate-machine.com
State-transition explosion
operand1
OPER
opEntered
operand2DIGIT_0_9, POINT
EQUALS
result
DIGIT_0_9, POINT
OPER
C
C
C
C
OFF
OFF
OFF
OFF Traditional state machines “explode”– Because of the
repetitions
7 7© Quantum Leapsstate-machine.com
Reuse of behavior through state nestingon
operand1
OPER
opEntered
operand2
DIGIT_0_9, POINTEQUALS
resultDIGIT_0_9, POINTOPER
C
OFFHierarchical state machines don't explode– Because they reuse
behavior
8 8© Quantum Leapsstate-machine.com
Manual coding a HSM in QP/C++QState Calc::on(Calc *me, QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: { // entry action BSP_message("on-ENTRY"); return Q_HANDLED(); } case Q_EXIT_SIG: { // exit action BSP_message("on-EXIT"); return Q_HANDLED(); } case Q_INIT_SIG: { // initial transition BSP_message("on-INIT"); return Q_TRAN(&Calc::ready); } case C_SIG: { // state transition BSP_clear(); // clear the display return Q_TRAN(&Calc::on); } case OFF_SIG: { // state transition return Q_TRAN(&Calc::final); } } return Q_SUPER(&QHsm::top); // superstate}
top
entry /exit /
on
. . .
. . .
readyC
. . .
. . .
OFF
9 9© Quantum Leapsstate-machine.com
Automatic coding a HSM with QM
10 10© Quantum Leapsstate-machine.com
Main benefits of QPHigher level of abstraction than RTOS (productivity)● You work at the level of events
and state machines, not the raw RTOS● Your design is more structured,
maintainable, testable, and robust
Safer programming model● You don't need to use semaphores,
and other such troublesome RTOS mechanisms
More efficient in time and space● You use less CPU (no blocking) and less RAM (less stack space)● QP is smaller in RAM use and code size (ROM) than any RTOS!
11 11© Quantum Leapsstate-machine.com
Who is using QP?
12 12© Quantum Leapsstate-machine.com
Supported processors (bare metal)QP is very portable to 8-, 16-, 32-bit MCUs● ARM7/9, ARM Cortex● ColdFire● Nios II● M16C/R8C/M32C, H8
● MSP430● AVRmega, AVRXmega● TMS320C28● PsoC● others upon request...
13 13© Quantum Leapsstate-machine.com
Supported operating systemsQP can work with traditional OS/RTOS● Linux/embedded Linux● QNX, Integrity (POSIX)● Windows/WindowsCE● VxWorks
● ThreadX● eCos● uC/OS-II● FreeRTOS.org● others...
14 14© Quantum Leapsstate-machine.com
Supported middlewareQP can work with middleware directly (bare metal)● LwIP embedded TCP/IP stack● emWin / uC/GUI embedded GUI● others upon request...
15 15© Quantum Leapsstate-machine.com
QM graphical modeling toolQP is supported by the free graphical QM modeling tool● Best-in-class state machine diagramming● Automatic code generation based on QP
16 16© Quantum Leapsstate-machine.com
SummaryQP is a lightweight event-driven, state machine framework
Higher level of abstraction (productivity) and safer than a raw RTOSExcellent documentation (books, application notes, articles, manuals)
QP has been used by hundreds of companies worldwideMarkets: consumer, industrial, communication, medical, defense
QP is supported by the free QM graphical modeling tool