本文整理汇总了C++中restart函数的典型用法代码示例。如果您正苦于以下问题:C++ restart函数的具体用法?C++ restart怎么用?C++ restart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了restart函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: restart
void CheckInternetOp::start()
{
restart();
}
开发者ID:SiteView,项目名称:Lenovo,代码行数:4,代码来源:BeanImpl.cpp
示例2: pcap_handle
static void pcap_handle(u_char *user, const struct pcap_pkthdr *h, const u_char *buf)
{
static unsigned failCount = 0;
pthread_t thread_lan;
#ifndef NO_ARP
if (buf[0x0c]==0x88 && buf[0x0d]==0x8e) {
#endif
if (memcmp(destMAC, buf+6, 6)!=0 && startMode>2) /* 服务器MAC地址不符 */
return;
capBuf = buf;
if (buf[0x0F]==0x00 && buf[0x12]==0x01 && buf[0x16]==0x01) { /* 验证用户名 */
if (startMode < 3) {
memcpy(destMAC, buf+6, 6);
print_log(_("** 认证服务器MAC: %s\n"), formatHex(destMAC, 6));
startMode += 3; /* 标记认证服务器MAC为已获取,可以锁定 */
}
if (proxyMode == 0) {
if (startMode==3 && memcmp(buf+0x17, "User name", 9)==0) /* 塞尔 */
startMode = 5;
switchState(ID_IDENTITY);
} else {
if (proxyClientRequested == 1) {
print_log(_(">> 服务器已请求用户名\n"));
proxy_send_to_lan(buf, h->len);
} else {
print_log(_("!! 在代理认证完成后收到用户名请求,将重启认证!\n"));
switchState(ID_WAITCLIENT);
}
}
}
else if (buf[0x0F]==0x00 && buf[0x12]==0x01 && buf[0x16]==0x04) { /* 验证密码 */
if (proxyMode == 0) {
switchState(ID_CHALLENGE);
} else {
if (proxyClientRequested == 1) {
print_log(_(">> 服务器已请求密码\n"));
proxy_send_to_lan(buf, h->len);
} else {
print_log(_("!! 在代理认证完成后收到密码请求,将重启认证!\n"));
switchState(ID_WAITCLIENT);
}
}
}
else if (buf[0x0F]==0x00 && buf[0x12]==0x03) { /* 认证成功 */
print_log(_(">> 认证成功!\n"));
failCount = 0;
proxySuccessCount++;
if (proxyMode != 0) {
proxy_send_to_lan(buf, h->len);
if (proxySuccessCount >= proxyRequireSuccessCount) {
pcap_breakloop(hPcapLan);
proxyClientRequested = 0;
proxySuccessCount = 0;
memcpy(lastSuccessClientMAC, clientMAC, 6); // 备份本次认证成功的客户端MAC,用于通知掉线
proxy_clear_client_mac(); // 重设MAC地址,以备下次使用不同客户端认证用
print_log(_(">> 已关闭LAN监听线程\n"));
}
}
if (!(startMode%3 == 2)) {
getEchoKey(buf);
}
showRuijieMsg(buf, h->caplen);
if (dhcpMode==1 || dhcpMode==2) /* 二次认证第一次或者认证后 */
switchState(ID_DHCP);
else if (startMode%3 == 2)
switchState(ID_WAITECHO);
else
switchState(ID_ECHO);
}
else if (buf[0x0F]==0x00 && buf[0x12]==0x01 && buf[0x16]==0x02) /* 显示赛尔提示信息 */
showCernetMsg(buf);
else if (buf[0x0F] == 0x05) /* (赛尔)响应在线 */
switchState(ID_ECHO);
else if (buf[0x0F]==0x00 && buf[0x12]==0x04) { /* 认证失败或被踢下线 */
if (state==ID_WAITECHO || state==ID_ECHO) {
if (proxyMode == 0) {
print_log(_(">> 认证掉线!\n"));
showRuijieMsg(buf, h->caplen);
if (restartOnLogOff) {
print_log(_(">> 正在重新认证...\n"));
switchState(ID_START);
} else {
exit(1);
}
} else {
pthread_create(&thread_lan, NULL, lan_thread, 0);
print_log(_(">> 认证掉线,已发回客户端并重新启用对LAN的监听\n"));
showRuijieMsg(buf, h->caplen);
// clientMAC已经在成功时被清除了,所以使用lastSuccessClientMAC发送,发完清除
memmove(clientMAC, lastSuccessClientMAC, 6);
proxy_send_to_lan(buf, h->len);
proxy_clear_client_mac();
switchState(ID_WAITCLIENT);
}
}
else if (buf[0x1b]!=0 || startMode%3==2) {
print_log(_(">> 认证失败!\n"));
showRuijieMsg(buf, h->caplen);
if (maxFail && ++failCount>=maxFail) {
//.........这里部分代码省略.........
开发者ID:updateing,项目名称:mentohust-proxy,代码行数:101,代码来源:mentohust.c
示例3: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
GlobalCache *globalCache = new GlobalCache();
loginStatus = false;
updateTimer = startTimer(100);
QTimerEvent *e= new QTimerEvent(updateTimer);
setWindowTitle("#precIsioN Billing Software 1.2");
/* Setting height and width properties */
QDesktopWidget *desktop = QApplication::desktop();
int width = desktop->width();
int height = desktop->height();
GlobalCache::setScreenWidth(width);
GlobalCache::setScreenHeight(height);
resize(width/2, height/2);
int sideWidth = 10; //width/48;
int sideHeight = (height-50)/14;
widgetWidth = width - 20; //sideWidth *46;
widgetHeight = sideHeight * 14;
/* Creating menu bar and status bar */
menubar = new QMenuBar(this);
setMenuBar(menubar);
menuAdministrator = new QMenu(menubar);
menuAdministrator->setTitle("Administrator");
menubar->addMenu(menuAdministrator);
QAction *homeAct = new QAction(("&Home"), this);
homeAct->setShortcut(QKeySequence(tr("Ctrl+H")));
menuAdministrator->addAction(homeAct);
menuAdministrator->addSeparator();
QAction *changePasswordAct = new QAction("Change Password", this);
menuAdministrator->addAction(changePasswordAct);
QAction *refreshAct = new QAction(("&Refresh"), this);
refreshAct->setShortcut(QKeySequence(tr("Ctrl+R")));
menuAdministrator->addAction(refreshAct);
QAction *fullScreenAct = new QAction(("&Full Screen"), this);
fullScreenAct->setShortcut(Qt::Key_F11);
menuAdministrator->addAction(fullScreenAct);
QAction *restartAct = new QAction("Restart", this);
restartAct->setShortcut(QKeySequence((tr("Shift+Ctrl+X"))));
menuAdministrator->addAction(restartAct);
QAction *quitAct = new QAction(("Quit Application"), this);
quitAct->setShortcut(QKeySequence(tr("Ctrl+X")));
menuAdministrator->addAction(quitAct);
menuStock = new QMenu(menubar);
menuStock->setTitle("Stock");
menubar->addMenu(menuStock);
QAction *manageStockAct = new QAction(("Manage Stock"), this);
manageStockAct->setShortcut(QKeySequence(tr("Ctrl+M")));
menuStock->addAction(manageStockAct);
QAction *bulkStockUpdationAct = new QAction("Bulk Stock Updation", this);
bulkStockUpdationAct->setShortcut(QKeySequence(tr("Ctrl+U")));
menuStock->addAction(bulkStockUpdationAct);
menuStock->addSeparator();
QAction *stockPruchaseInvoiceAct = new QAction(("Stock Purchase Invoice"), this);
menuStock->addAction(stockPruchaseInvoiceAct);
QAction *oldStockPurchaseInvoiceAct = new QAction(("Old Stock Purchase Invoice"), this);
menuStock->addAction(oldStockPurchaseInvoiceAct);
menuStock->addSeparator();
QAction *stockUpdationAct = new QAction(("Single Stock Updation"), this);
menuStock->addAction(stockUpdationAct);
menuStock->addSeparator();
QAction *addNewStockAct = new QAction(("Add New Stock"), this);
menuStock->addAction(addNewStockAct);
QAction *deleteStockact = new QAction(("Remove Stock"), this);
menuStock->addAction(deleteStockact);
QAction *updateStockAct = new QAction(("Edit Stock Details"), this);
menuStock->addAction(updateStockAct);
menuStock->addSeparator();
QAction *checkStockAct = new QAction("Check Stock", this);
checkStockAct->setShortcut(QKeySequence("Ctrl+F"));
menuStock->addAction(checkStockAct);
menuInvoice = new QMenu(menubar);
menuInvoice->setTitle("Invoice");
menubar->addMenu(menuInvoice);
QAction *invoiceAct = new QAction(("&New Invoice"), this);
invoiceAct->setShortcut(QKeySequence(tr("Ctrl+N")));
menuInvoice->addAction(invoiceAct);
QAction *setInvoiceAct = new QAction(("Set Invoice No"), this);
menuInvoice->addAction(setInvoiceAct);
QAction *cancelInvoiceAct = new QAction(("Cancel Invoice"), this);
menuInvoice->addAction(cancelInvoiceAct);
QAction *oldInvoiceAct = new QAction(("Old Invoices"), this);
menuInvoice->addAction(oldInvoiceAct);
menuEstimate = new QMenu(menubar);
menuEstimate->setTitle("Estimate");
menubar->addMenu(menuEstimate);
QAction *estimateAct = new QAction(("&New Estimate"), this);
//.........这里部分代码省略.........
开发者ID:chikkupa,项目名称:BillingSoftware,代码行数:101,代码来源:mainwindow.cpp
示例4: kernel_main
/*======================================================================*
kernel_main
*======================================================================*/
PUBLIC int kernel_main()
{
disp_str("-----\"kernel_main\" begins-----\n");
TASK* p_task = task_table;
PROCESS* p_proc = proc_table;
char* p_task_stack = task_stack + STACK_SIZE_TOTAL;
u16 selector_ldt = SELECTOR_LDT_FIRST;
int i;
u8 privilege;
u8 rpl;
int eflags;
for (i = 0; i < NR_TASKS+NR_PROCS; i++) {
if (i < NR_TASKS) { /* 任务 */
p_task = task_table + i;
privilege = PRIVILEGE_TASK;
rpl = RPL_TASK;
eflags = 0x1202; /* IF=1, IOPL=1, bit 2 is always 1 */
}
else { /* 用户进程 */
p_task = user_proc_table + (i - NR_TASKS);
privilege = PRIVILEGE_USER;
rpl = RPL_USER;
eflags = 0x202; /* IF=1, bit 2 is always 1 */
}
strcpy(p_proc->p_name, p_task->name); // name of the process
p_proc->pid = i; // pid
p_proc->ldt_sel = selector_ldt;
memcpy(&p_proc->ldts[0], &gdt[SELECTOR_KERNEL_CS >> 3],
sizeof(DESCRIPTOR));
p_proc->ldts[0].attr1 = DA_C | privilege << 5;
memcpy(&p_proc->ldts[1], &gdt[SELECTOR_KERNEL_DS >> 3],
sizeof(DESCRIPTOR));
p_proc->ldts[1].attr1 = DA_DRW | privilege << 5;
p_proc->regs.cs = (0 & SA_RPL_MASK & SA_TI_MASK) | SA_TIL | rpl;
p_proc->regs.ds = (8 & SA_RPL_MASK & SA_TI_MASK) | SA_TIL | rpl;
p_proc->regs.es = (8 & SA_RPL_MASK & SA_TI_MASK) | SA_TIL | rpl;
p_proc->regs.fs = (8 & SA_RPL_MASK & SA_TI_MASK) | SA_TIL | rpl;
p_proc->regs.ss = (8 & SA_RPL_MASK & SA_TI_MASK) | SA_TIL | rpl;
p_proc->regs.gs = (SELECTOR_KERNEL_GS & SA_RPL_MASK) | rpl;
p_proc->regs.eip = (u32)p_task->initial_eip;
p_proc->regs.esp = (u32)p_task_stack;
p_proc->regs.eflags = eflags;
p_task_stack -= p_task->stacksize;
p_proc++;
p_task++;
selector_ldt += 1 << 3;
}
proc_table[0].ticks = proc_table[0].priority = 15;
proc_table[1].ticks = proc_table[1].priority = 5;
proc_table[2].ticks = proc_table[2].priority = 3;
k_reenter = 0;
ticks = 0;
p_proc_ready = proc_table;
init_clock();
init_keyboard();
restart();
while(1){}
}
开发者ID:Garfield-Chen,项目名称:hf-2011,代码行数:73,代码来源:main.c
示例5: restart
/**
* \brief Changes the direction of this movement.
*
* The movement is restarted.
*
* \param direction8 the new direction (0 to 7)
*/
void JumpMovement::set_direction8(int direction8) {
this->direction8 = direction8;
restart();
}
开发者ID:Arvek,项目名称:SOLARME,代码行数:12,代码来源:JumpMovement.cpp
示例6: Timer
开发者ID:VarLog,项目名称:RealTimeViz,代码行数:4,代码来源:timer.hpp
示例7: restart
HighResolutionTimer::HighResolutionTimer() {
restart();
}
开发者ID:MLDL,项目名称:lightlda,代码行数:3,代码来源:high_resolution_timer.cpp
示例8: restart
HumanConsole::HumanConsole(GameCenter* gameCenter) {
this->gameCenter = gameCenter;
restart();
}
开发者ID:chnlkw,项目名称:16thAI9,代码行数:4,代码来源:humanconsole.cpp
示例9: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Register QtKeypadBridge for the virtual keyboard functionality
ui->keypadWidget->installEventFilter(&qt_keypad_bridge);
ui->lcdView->installEventFilter(&qt_keypad_bridge);
//Emu -> GUI (QueuedConnection as they're different threads)
connect(&emu, SIGNAL(serialChar(char)), this, SLOT(serialChar(char)), Qt::QueuedConnection);
connect(&emu, SIGNAL(debugStr(QString)), this, SLOT(debugStr(QString))); //Not queued connection as it may cause a hang
connect(&emu, SIGNAL(speedChanged(double)), this, SLOT(showSpeed(double)), Qt::QueuedConnection);
connect(&emu, SIGNAL(statusMsg(QString)), ui->statusbar, SLOT(showMessage(QString)), Qt::QueuedConnection);
connect(&emu, SIGNAL(turboModeChanged(bool)), ui->buttonSpeed, SLOT(setChecked(bool)), Qt::QueuedConnection);
connect(&emu, SIGNAL(usblinkChanged(bool)), this, SLOT(usblinkChanged(bool)), Qt::QueuedConnection);
//Menu "Emulator"
connect(ui->buttonReset, SIGNAL(clicked(bool)), &emu, SLOT(reset()));
connect(ui->actionReset, SIGNAL(triggered()), &emu, SLOT(reset()));
connect(ui->actionRestart, SIGNAL(triggered()), this, SLOT(restart()));
connect(ui->actionDebugger, SIGNAL(triggered()), &emu, SLOT(enterDebugger()));
connect(ui->buttonPause, SIGNAL(clicked(bool)), &emu, SLOT(setPaused(bool)));
connect(ui->buttonPause, SIGNAL(clicked(bool)), ui->actionPause, SLOT(setChecked(bool)));
connect(ui->actionPause, SIGNAL(toggled(bool)), &emu, SLOT(setPaused(bool)));
connect(ui->actionPause, SIGNAL(toggled(bool)), ui->buttonPause, SLOT(setChecked(bool)));
connect(ui->buttonSpeed, SIGNAL(clicked(bool)), &emu, SLOT(setTurboMode(bool)));
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F11), this);
shortcut->setAutoRepeat(false);
connect(shortcut, SIGNAL(activated()), &emu, SLOT(toggleTurbo()));
//Menu "Tools"
connect(ui->buttonScreenshot, SIGNAL(clicked()), this, SLOT(screenshot()));
connect(ui->actionScreenshot, SIGNAL(triggered()), this, SLOT(screenshot()));
connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectUSB()));
connect(ui->buttonUSB, SIGNAL(clicked(bool)), this, SLOT(connectUSB()));
connect(ui->actionXModem, SIGNAL(triggered()), this, SLOT(xmodemSend()));
ui->actionConnect->setShortcut(QKeySequence(Qt::Key_F10));
ui->actionConnect->setAutoRepeat(false);
//Menu "Flash"
connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveFlash()));
connect(ui->actionCreate_flash, SIGNAL(triggered()), this, SLOT(createFlash()));
//Debugging
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(debugCommand()));
//File transfer
connect(ui->refreshButton, SIGNAL(clicked(bool)), this, SLOT(reload_filebrowser()));
connect(this, SIGNAL(usblink_progress_changed(int)), this, SLOT(changeProgress(int)), Qt::QueuedConnection);
//Settings
connect(ui->checkDebugger, SIGNAL(toggled(bool)), this, SLOT(setDebuggerOnStartup(bool)));
connect(ui->checkWarning, SIGNAL(toggled(bool)), this, SLOT(setDebuggerOnWarning(bool)));
connect(ui->uiDocks, SIGNAL(toggled(bool)), this, SLOT(setUIMode(bool)));
connect(ui->checkAutostart, SIGNAL(toggled(bool)), this, SLOT(setAutostart(bool)));
connect(ui->fileBoot1, SIGNAL(pressed()), this, SLOT(selectBoot1()));
connect(ui->fileFlash, SIGNAL(pressed()), this, SLOT(selectFlash()));
connect(ui->pathTransfer, SIGNAL(textEdited(QString)), this, SLOT(setUSBPath(QString)));
connect(ui->spinGDB, SIGNAL(valueChanged(int)), this, SLOT(setGDBPort(int)));
connect(ui->spinRDBG, SIGNAL(valueChanged(int)), this, SLOT(setRDBGPort(int)));
connect(ui->orderDiags, SIGNAL(toggled(bool)), this, SLOT(setBootOrder(bool)));
//Set up monospace fonts
QFont monospace = QFontDatabase::systemFont(QFontDatabase::FixedFont);
ui->debugConsole->setFont(monospace);
ui->serialConsole->setFont(monospace);
qRegisterMetaType<QVector<int>>();
#ifdef Q_OS_ANDROID
//On android the settings file is deleted everytime you update or uninstall,
//so choose a better, safer, location
QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
settings = new QSettings(path + "/nspire_emu.ini", QSettings::IniFormat);
#else
settings = new QSettings();
#endif
//Load settings
setUIMode(settings->value("docksEnabled", true).toBool());
restoreGeometry(settings->value("windowGeometry").toByteArray());
restoreState(settings->value("windowState").toByteArray(), WindowStateVersion);
selectBoot1(settings->value("boot1", "").toString());
selectFlash(settings->value("flash", "").toString());
setDebuggerOnStartup(settings->value("debugOnStart", false).toBool());
setDebuggerOnWarning(settings->value("debugOnWarn", false).toBool());
setUSBPath(settings->value("usbdir", QString("ndless")).toString());
setGDBPort(settings->value("gdbPort", 3333).toUInt());
setRDBGPort(settings->value("rdbgPort", 3334).toUInt());
setBootOrder(false);
bool autostart = settings->value("emuAutostart", false).toBool();
setAutostart(autostart);
if(emu.boot1 != "" && emu.flash != "" && autostart)
emu.start();
else
ui->statusbar->showMessage(trUtf8("Start the emulation via Emulation->Restart."));
//.........这里部分代码省略.........
开发者ID:juliusdedekind,项目名称:firebird,代码行数:101,代码来源:mainwindow.cpp
示例10: restart
void Game::init() {
restart(1);
}
开发者ID:rubyist,项目名称:pingduino,代码行数:3,代码来源:Game.cpp
示例11: ft_ctrl_z
void ft_ctrl_z(t_env *env)
{
restart();
}
开发者ID:GabrielPora,项目名称:Minishell,代码行数:4,代码来源:keys_cb.c
示例12: restart
void CTokenizer::reset()
{
restart();
}
开发者ID:8bitgeek,项目名称:caribou-rtos,代码行数:4,代码来源:ctokenizer.cpp
示例13: LOG_DEBUG
void CheckInternetOp::onTimeout()
{
m_timer1.stop();
LOG_DEBUG(QString::fromUtf8("retry %1/%2").arg(m_retryCount).arg(m_maxRetryCount));
restart();
}
开发者ID:SiteView,项目名称:Lenovo,代码行数:6,代码来源:BeanImpl.cpp
示例14: run
// The `run` method will start the game loop.
void run()
{
while(true)
{
window.clear(sf::Color::Black);
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) break;
// The `P` key will toggle the pause. To prevent continuous
// use of the pause button, we need to check if the input
// was pressed last frame.
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::P))
{
// If `P` was not pressed last frame, we can toggle
// the state.
if(!pausePressedLastFrame)
{
if(state == State::Paused)
state = State::InProgress;
else if(state == State::InProgress)
state = State::Paused;
}
pausePressedLastFrame = true;
}
else
pausePressedLastFrame = false;
// Let's also use the `R` key to restart the game.
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::R)) restart();
// If the game is paused, we'll only draw game elements,
// without updating them.
if(state != State::Paused)
{
// The rest of the game loop code is exactly the same.
ball.update();
paddle.update();
for(auto& brick : bricks)
{
brick.update();
solveBrickBallCollision(brick, ball);
}
bricks.erase(
std::remove_if(std::begin(bricks), std::end(bricks),
[](const auto& mBrick)
{
return mBrick.destroyed;
}),
std::end(bricks));
solvePaddleBallCollision(paddle, ball);
}
ball.draw(window);
paddle.draw(window);
for(auto& brick : bricks) brick.draw(window);
window.display();
}
}
开发者ID:Boza-s6,项目名称:cppcon2014,代码行数:64,代码来源:p09.cpp
示例15: QThread
QLuaApplication::Private::Thread::Thread(QLuaApplication::Private *d)
: QThread(d->theApp), d(d), engine(0), loop(0)
{
connect(this,SIGNAL(restart()),d,SLOT(start()),Qt::QueuedConnection);
}
开发者ID:HaveF,项目名称:torch,代码行数:5,代码来源:qluaapplication.cpp
示例16: start_tcl
//.........这里部分代码省略.........
PBS_EVENTCLASS_SERVER,
msg_daemonname, log_buffer);
return (-1);
}
token = strtok(NULL, " \t");
if (*(token + strlen(token) - 1) == '\n')
*(token + strlen(token) - 1) = '\0';
if (special[i].handler(token))
{
fclose(conf);
return (-1);
}
}
else
{
log_record(PBSEVENT_ERROR, PBS_EVENTCLASS_SERVER,
msg_daemonname,
"invalid line in config file");
fclose(conf);
return (-1);
}
}
fclose(conf);
return (0);
}
void
restart(sig)
int sig;
{
char *id = "restart";
if (sig)
{
sprintf(log_buffer, "restart on signal %d", sig);
log_close(1);
log_open(logfile, path_log);
}
else
{
sprintf(log_buffer, "restart command");
}
log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);
Tcl_DeleteInterp(interp);
if (configfile)
{
if (read_config(configfile) != 0)
die(0);
}
start_tcl();
}
void
badconn(msg)
char *msg;
{
开发者ID:actorquedeveloper,项目名称:torque-old,代码行数:67,代码来源:pbs_sched.c
示例17: block_profiler
block_profiler(char const* description, bool enable_logging = true)
: stats_(get_stats(description)), measuring_(false),
enable_logging_(enable_logging)
{
restart();
}
开发者ID:brycelelbach,项目名称:hpx,代码行数:6,代码来源:block_profiler.hpp
示例18: restart
/*! \brief Constructor
*/
MillisecondTimer::MillisecondTimer()
{
restart();
}
开发者ID:ChristopherBlignaut,项目名称:SAEAuto,代码行数:6,代码来源:xsens_time.cpp
示例19: _app
//.........这里部分代码省略.........
if (_openGL.hasVBO())
{
_vertexArray = new OpenglVertexArray;
_vertexArray->bind();
}
// TODO: move it back in window::resize
if (_openGL._major < 3)
{
#if 0
GLfloat aspect = (GLfloat)width / height;
GLfloat maxX = 1.0;
GLfloat maxY = 1.0;
if (width >= height)
{
maxX = 1.0f * aspect;
}
else
{
maxY = 1.0f / aspect;
}
//gluOrtho2D(0, maxX, 0, maxY);
#endif
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1, 1, -1, 1);
}
_window->onKey(
[this] (oak::Window* window, unsigned char key, int x, int y)
{
keyPressed(window, key, x, y);
});
_window->onPaint(
[this] (oak::Window* window)
{
std::chrono::high_resolution_clock::time_point newTimePoint = _fpsClock.now();
int seconds = std::chrono::duration_cast<std::chrono::seconds>(newTimePoint - _referenceTimePoint).count();
if (seconds >= 9)
{
memset(_fps, 0, 5 * sizeof(int));
_referenceTimePoint += std::chrono::seconds(seconds - 1);
seconds = 1;
}
else if (seconds >= 5)
{
memmove(_fps, _fps + seconds - 4, (5+4 - seconds) * sizeof(int));
memset(_fps + 5+4 - seconds, 0, (seconds - 4) * sizeof(int));
_referenceTimePoint += std::chrono::seconds(seconds - 4);
seconds = 4;
}
_fps[seconds]++;
int sum = 0;
int count = 0;
float fps = 0.0f;
for (int i = 0; i < seconds; i++)
{
sum += _fps[i] * g_fpsWeights[i];
count += g_fpsWeights[i];
}
if (count != 0)
fps = (float)sum/count;
glClear(GL_COLOR_BUFFER_BIT);
try
{
if (_splinePainter)
{
_splinePainter->paint(window);
}
if (_config.helpVisible && _staticTextPainter)
{
updateOptionTexts(_staticTextPainter->staticText().lines(), fps);
_staticTextPainter->paint(window);
}
}
catch(int errorCode)
{
_app->exit(errorCode);
}
});
_timer = new oak::Timer(TIMER_MS, true,
[this] (oak::Timer*)
{
if (_config.animatingOn)
{
oak::Spline::animate(_splinePainter->objects());
_window->repaint();
}
});
restart(true, true);
_timer->start();
}
开发者ID:CodeDJ,项目名称:bsplines,代码行数:101,代码来源:applicationcontroller.cpp
示例20: restart
/**
* I2C.begin for I2C.
*/
void PCA9685::begin()
{
Wire.begin();
restart();
}
开发者ID:Kowalski22,项目名称:PCA9685,代码行数:8,代码来源:PCA9685.cpp
注:本文中的restart函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论