void CscopePlugin::OnFind(wxCommandEvent &event) { wxString WordAtCaret = GetWordAtCaret(); if (WordAtCaret.IsEmpty()) return; wxString list_file, outputfilename; if ( !CreateListFile(list_file) ) return; wxString cmd( GetCscopeBinaryName() + _T(" ") + //_T(" -f ") + reffilename + _T(" -L") ); wxString endMsg(_T("Results for: ")); if ( event.GetId() == idOnFindFunctionsCallingThisFunction) { cmd += _T(" -3 "); endMsg += _T("find functions calling '") + WordAtCaret + _T("'"); } else //if( event.GetId() == idOnFindFunctionsCalledByThisFuncion) { cmd += _T(" -2 "); endMsg += _T("find functions called by '") + WordAtCaret + _T("'"); } // else if ( event.GetId() == idOnFindGlobalDefinition ) // { // cmd += _T(" -1 "); // endMsg += _T("find '") + WordAtCaret + _T("' global definition"); // } // else //idOnFindSymbol // { // cmd += _T(" -0 "); // endMsg += _T("find C symbol '") + WordAtCaret + _T("'"); // } cmd += WordAtCaret + _T(" -i \"") + list_file + _T("\""); DoCscopeCommand(cmd, endMsg); }
void LzBackupQueue::receiveThreadFinish(int isok, QString filename, qint64 endfc) { qDebug() << "NAS backup_start file " << filename << isok; if (isok <= 0) { switch (isok) { case 0: // 反馈、备份结果 backup_feedbackEndToMaster(filename, current_tunnelid); break; case -1: // 暂停 backup_feedbackSuspend(filename, current_tunnelid, endfc, true); break; case -2:backup_handleError(filename, current_tunnelid, QObject::tr("原文件路径与目标路径相同")); break; case -3:backup_handleError(filename, current_tunnelid, QObject::tr("原路径中%1不存在任务文件").arg(current_sourcefile_dir)); break; case -4:backup_handleError(filename, current_tunnelid, QObject::tr("不能在目标路径%1中创建文件").arg(current_directionfile_dir)); break; case -5:backup_handleError(filename, current_tunnelid, QObject::tr("无法备份(连接不到NAS)")); break; case -6:backup_handleError(filename, current_tunnelid, QObject::tr("未初始化备份线程")); break; case -7:backup_handleError(filename, current_tunnelid, QObject::tr("原文件正被占用,无法打开")); break; case -8:backup_handleError(filename, current_tunnelid, QObject::tr("目标文件正被占用,无法打开")); break; case -9:backup_handleError(filename, current_tunnelid, QObject::tr("无法retrieve原文件的起始帧")); break; default: break; } } endMsg(); }
/** * 任务命令解析 * 实现父类的纯虚函数 */ bool LzBackupQueue::parseMsg(QString msg) { QStringList strList = msg.split(",", QString::SkipEmptyParts); int msgid = strList.value(0).toInt(); qDebug() << "msgid= " << msgid; if (msgid > 3000) { switch(msgid) { case 3001: // 3001,filename=xxx,tunnelid=xx,isinterrupted=false(true),interruptedfilepos=xx,beginfc=xx,endfc=xx { if (strList.length() < 7 || !strList.at(1).startsWith("filename") || !strList.at(2).startsWith("tunnelid") || !strList.at(3).startsWith("isinterrupted") || !strList.at(4).startsWith("interruptedfilepos") || !strList.at(5).startsWith("beginfc") || !strList.at(6).startsWith("endfc")) { qDebug() << tr("解析字符出错") << msg; return false; } QString filename = strList.at(1).mid(9); int tunnelid = strList.at(2).mid(9).toInt(); current_tunnelid = tunnelid; QString isinterruptstr = strList.at(3).mid(14); bool isinterrupt = false; if (isinterruptstr.compare("true") == 0) isinterrupt = true; qint64 interruptfilepos = strList.at(4).mid(19).toLongLong(); qint64 beginfc = strList.at(5).mid(8).toLongLong(); qint64 endfc = strList.at(6).mid(6).toLongLong(); if (isinterrupt) emit signalParsedMsgToSlave(tr("[主控] 命令:开始备份文件为%1,文件起始帧号%2,终止帧号%3,从中断位置%4帧开始").arg(filename).arg(beginfc).arg(endfc).arg(interruptfilepos)); else emit signalParsedMsgToSlave(tr("[主控] 命令:开始备份文件为%1,文件起始帧号%2,终止帧号%3,从头开始").arg(filename).arg(beginfc).arg(endfc)); // 确认开始备份 backup_feedbackStartToMaster(filename, tunnelid, beginfc, endfc); // 备份该隧道 int ret = backup_start(filename, tunnelid, isinterrupt, interruptfilepos); if (ret != 0) endMsg(); break; } case 3401://暂停备份 { qDebug() << QObject::tr("[主控] 命令:暂停备份"); /************TODO*************/ backup_suspend(); emit signalParsedMsgToSlave(tr("[主控] 命令:暂停备份")); break; } default: return false; } } return true; }
void CGameManager::updateMovies() { // Initial iteration to mark all the movies as not yet handled for (CMovieList::iterator i = CMovie::_playingMovies->begin(); i != CMovie::_playingMovies->end(); ++i) (*i)->_handled = false; bool repeatFlag; do { repeatFlag = false; // Scan for a movie to process for (CMovieList::iterator i = CMovie::_playingMovies->begin(); i != CMovie::_playingMovies->end(); ++i) { CMovie *movie = *i; if (movie->_handled) continue; CMovieEventList eventsList; if (!movie->handleEvents(eventsList)) movie->removeFromPlayingMovies(); while (!eventsList.empty()) { CMovieEvent *movieEvent = eventsList.front(); switch (movieEvent->_type) { case MET_MOVIE_END: { CMovieEndMsg endMsg(movieEvent->_startFrame, movieEvent->_endFrame); endMsg.execute(movieEvent->_gameObject); break; } case MET_FRAME: { CMovieFrameMsg frameMsg(movieEvent->_initialFrame, 0); frameMsg.execute(movieEvent->_gameObject); break; } default: break; } eventsList.remove(movieEvent); } // Flag the movie as having been handled movie->_handled = true; repeatFlag = true; break; } } while (repeatFlag); }
void CInputHandler::processMessage(CMessage *msg) { const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg); _singleton = false; dispatchMessage(msg); if (_singleton) { _singleton = false; } else if (mouseMsg) { // Keep the game state mouse position up to date if (_mousePos != mouseMsg->_mousePos) { _mousePos = mouseMsg->_mousePos; _gameManager->_gameState.setMousePos(mouseMsg->_mousePos); } // Set flag for whether a mouse button is currently being pressed if (mouseMsg->isButtonDownMsg()) _buttonDown = true; else if (mouseMsg->isButtonUpMsg()) _buttonDown = false; // Drag events generation if (_dragging) { if (mouseMsg->isMouseMoveMsg()) { if (_dragItem) { CMouseDragMoveMsg moveMsg(_mousePos); moveMsg.execute(_dragItem); } } else { if (mouseMsg->isButtonUpMsg() && _dragItem) { // Mouse drag ended CGameObject *target = dragEnd(_mousePos, _dragItem); CMouseDragEndMsg endMsg(_mousePos, target); endMsg.execute(_dragItem); } _dragging = false; _dragItem = nullptr; } } else if (_buttonDown) { if (!mouseMsg->isMouseMoveMsg()) { // Save where the drag movement started from _dragStartPos = _mousePos; } else { Point delta = mouseMsg->_mousePos - _dragStartPos; int distance = (int)sqrt(double(delta.x * delta.x + delta.y * delta.y)); if (distance > 4) { // We've moved far enough with the mouse button held down // to trigger an official dragging operation CMouseDragStartMsg startMsg(_dragStartPos); dispatchMessage(&startMsg); // Set the drag item, if any, that a handler will have set on the message _dragItem = startMsg._dragItem; _gameManager->_dragItem = startMsg._dragItem; if (_dragItem) { CMouseDragMoveMsg moveMsg(_dragStartPos); dispatchMessage(&moveMsg); } _dragging = true; } } } } }
//********************************************************************************************************************** void SimpleTerminal::modifyDspText(DspType type, const QString &text) { // Format text according to type of message static DspType last_type = DspType::NONE; // Need to end the last message? if (last_type != type && _is_msg_open) emit endMsg(); switch(type) { case DspType::READ_MESSAGE: { static QString prev_msg(""); // Parse message and look for EOM string(s) - there could be 0 - n in this message // Emit approriate details to system - end of message? Start of message? Append message? QString msg(text.toHtmlEscaped()); // Find all occurences of EOM int start_pos = 0; int eom_pos = 0; do { QString shared_msg(prev_msg + msg); eom_pos = shared_msg.indexOf(_eom, start_pos); if (eom_pos >= 0) { // Found EOM! if (!_is_msg_open) emit startMsg(); if (eom_pos < prev_msg.length()) // Found EOM start before start of actual message; need to correct start position // to be first character after previous message start_pos += prev_msg.length(); int len = (eom_pos + _eom.length()) - start_pos; emit appendMsg(shared_msg.mid(start_pos, len)); emit endMsg(); start_pos = eom_pos + _eom.length(); } else if (start_pos < shared_msg.length()) { // No EOMs left; send rest of message if (!_is_msg_open) emit startMsg(); emit appendMsg(shared_msg.mid(start_pos)); } } while(eom_pos >= 0); // Keep end of msg for next time if (_eom.length() > 0) { int num_prev_msg_keep = _eom.length() - msg.length(); if (num_prev_msg_keep > 0) prev_msg = prev_msg.right(num_prev_msg_keep) + msg; else prev_msg = msg.right(_eom.length() - 1); } else prev_msg = ""; break; } case DspType::WRITE_MESSAGE: { QString msg = "<span><b>" + text.toHtmlEscaped() + "</b></span>"; emit newMsg(msg); break; } case DspType::COMMAND: { QString msg = "<span style = \"color: blue;\"><b>$ " + text.toHtmlEscaped() + "</b></span>"; emit newMsg(msg); break; } case DspType::COMMAND_RSP: { QString msg = "<span style = \"color: green;\">" + text + "</span>"; emit newMsg(msg); break; } case DspType::ERROR: { QString msg = "<span style = \"color: red;\">ERROR: " + text + "</span>"; emit newMsg(msg); break; } default: break; } last_type = type; }
int main(){ int numJobs=50; int numProcs=1; float memTotal=0; double time; string prompt; clock_t t; //Clears screen //system("clear"); clear(); //Welcome message welcomeMsg(); //Prompts user for input userPrompt(numProcs); //Creation of processes cout<<"\nCreating "<<numJobs <<" processes..."; c_Proc* process[numJobs]; for(int i=0;i<numJobs;i++) process[i] = new c_Proc(i); cout<<numJobs <<" new processes created."<<endl; //Runs scheduler and clocks auto t1 = std::chrono::high_resolution_clock::now(); cout<<"Running processes..."; if(simulator(process, numJobs, numProcs, memTotal)){ cout<<"All processes successfully ran!\n"<<endl; auto t2 = std::chrono::high_resolution_clock::now(); //Outputs time time = std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count(); time = time/1000; cout<<"\nIt took us "<<time; cout<<"ms to run all processes\n"<<endl; } else{ cout<<"Error! We ran out of memory for the processes"<<endl; auto t2 = std::chrono::high_resolution_clock::now(); //Outputs time time = std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count(); time = time/1000; cout<<"\nIt took us "<<time; cout<<"ms to run the processes up to this point.\n"<<endl; } //Outputs total memory consumption cout<<"Total memory of all processes is "; cout<<memTotal/1000000<<"Mb\n"<<endl; //Displays which processor has which job assigned to it //processorOutput(); //Sends processes info to processes.txt processOutput(process,numJobs); //Sends memory consumption and total time to data.txt simulationOutput(memTotal,time,numJobs,numProcs); //Program termination endMsg(); return 0; }