//多线程 UINT CIODlg::Comd(LPVOID pParam) { controller = new CController; initState(); //controller->alarm(); BYTE m_data; while (ISSTART) { Sleep(10); char c = controller->getKeyCode(); CCOutput::outputChar("key=", c); if (c == 'O') { // 开锁操作 startUnlock(); } else if (c == '#') { completeInput(); } else if (c == '*') { del(); } else if (c == 'A') { setStateText("请输入管理员密码"); password = ""; state = ADMIN_PWD; } else if (c == 'M') { setStateText("请输入原密码"); password = ""; state = IDENTIFY_PWD; } else if (state != INIT_STATE) { password += c; TRACE(password.c_str()); TRACE("\n"); } displayPassword(); } return 0; }
void CIODlg::initState() { numError = 0; password = ""; setStateText("选择对应的操作 M:修改密码, O:解锁"); state = INIT_STATE; }
Mg3dScene::Mg3dScene(QWidget*parent):QGLView(parent),d_ptr(new Mg3dScenePrivate) { ///////////////////// d_ptr->showGrid = false; d_ptr->showReference = false; d_ptr->reference = new Mg3DReference(); d_ptr->reference->setAxisLenght(20); d_ptr->axisNode = d_ptr->reference->createReferenceAxis(); d_ptr->gridsNode = d_ptr->reference->createReferenceGrids(); d_ptr->axisNode->setParent(this); d_ptr->gridsNode->setParent(this); d_ptr->fboVertices.appendVertex(QVector3D(-1,-1,0));//0 d_ptr->fboVertices.appendVertex(QVector3D(1,-1,0));//1 d_ptr->fboVertices.appendVertex(QVector3D(1,1,0));//2 d_ptr->fboVertices.appendVertex(QVector3D(-1,1,0));//3 d_ptr->fboVertices.appendIndices(0,1,2); d_ptr->fboVertices.appendIndices(2,3,0); setStateTextSize(1); setStateText(0,"FPS : undefined"); }
void CIODlg::checkPassword() { if (password == realPassword) { setStateText("密码正确,绿灯亮十秒"); controller->successUnlock(); } else { numError++; if (numError >= 3 && numError % 3 == 0) { setStateText("报警,绿灯亮5秒"); //报警 controller->alarm(); } } initState(); }
void CIODlg::completeInput() { if (state == START_UNLOCK) checkPassword(); else if (state == IDENTIFY_PWD) { if (password == realPassword) { setStateText("原密码正确,请输入新密码"); password = ""; state = SET_NEW_PWD; } else { // 进入初始状态 initState(); } } else if (state == SET_NEW_PWD) { realPassword = password; initState(); } else if (state == ADMIN_PWD) { if (password == realPassword) { realPassword = "******"; initState(); } else { // 退出程序 OnCancel(); } } }
void CIODlg::startUnlock() { password = ""; state = START_UNLOCK; setStateText("请输入密码"); }
void Mg3dScene::updateFps() { int elapsed =qMax(d_ptr->fpsTime.elapsed(),1); d_ptr->fpsManager.addNewTime(elapsed); setStateText(0,d_ptr->fpsManager.fpsString()); }