📄 main.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Product: QBomb Example, DOS, Large model, Turbo C++ 1.01// Last Updated for Version: 3.3.00// Date of the Last Update: Jan 24, 2007//// Q u a n t u m L e a P s// ---------------------------// innovating embedded systems//// Copyright (C) 2002-2007 Quantum Leaps, LLC. All rights reserved.//// This software may be distributed and modified under the terms of the GNU// General Public License version 2 (GPL) as published by the Free Software// Foundation and appearing in the file GPL.TXT included in the packaging of// this file. Please note that GPL Section 2[b] requires that all works based// on this software must also be made publicly available under the terms of// the GPL ("Copyleft").//// Alternatively, this software may be distributed and modified under the// terms of Quantum Leaps commercial licenses, which expressly supersede// the GPL and are specifically designed for licensees interested in// retaining the proprietary status of their code.//// Contact information:// Quantum Leaps Web site: http://www.quantum-leaps.com// e-mail: sales@quantum-leaps.com//////////////////////////////////////////////////////////////////////////////#include "qep_port.h"#include "qassert.h"#include "qbomb.h"#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <dos.h>Q_DEFINE_THIS_FILE// Local objects -------------------------------------------------------------static QBomb l_qbomb; // quantum bomb FSM//............................................................................int main() { printf("QBomb example, built on %s at %s,\n" "QEP/C++: %s.\nPress ESC to quit...\n", __DATE__, __TIME__, QEP::getVersion()); QBombInitEvt ie; ie.defuse = 0x0D; // 1101 binary l_qbomb.init(&ie); // trigger initial transition for (;;) { // event loop static int tickCtr = 1; QEvent e; char const *msg = (char *)0; delay(100); // delay for 100 milliseconds if (kbhit()) { switch (getch()) { case 'a': case 'A': { // Arm key e.sig = ARM_SIG; msg = "ARM"; break; } case 'u': case 'U': { // Up key e.sig = UP_SIG; msg = "UP"; break; } case 'd': case 'D': { // Down key e.sig = DOWN_SIG; msg = "DOWN"; break; } case '\33': { // ESC key l_qbomb.exit(); break; } } } else if (--tickCtr == 0) { // time for the tick? tickCtr = 10; e.sig = TICK_SIG; msg = "TICK"; } if (msg != (char *)0) { printf("\n[%2d] %s: ", (int)l_qbomb.getTimeout(), msg); l_qbomb.dispatch(&e); // dispatch the event } } return 0;}//............................................................................void Q_assert_handler(char const Q_ROM * const Q_ROM_VAR file, int line) { fprintf(stderr, "Assertion failed in %s, line %d", file, line); exit(-1);}//............................................................................void QBomb::updateState(char const *s) { printf("%s;", s);}//............................................................................void QBomb::exit(void) { printf("\nBye, Bye!"); ::exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -