void checkUnitigMembership(UnitigVector &unitigs) { int nutg = 0; int nfrg = 0; writeLog("checkUnitigMembership()-- numfrags=%d\n", FI->numFragments()); uint32 *inUnitig = new uint32 [FI->numFragments()+1]; uint32 logSizeMax = 0; uint32 logSize[64] = {0}; for (uint32 i=0; i<FI->numFragments()+1; i++) inUnitig[i] = noUnitig; for (uint32 ti=0; ti<unitigs.size(); ti++) { Unitig *tig = unitigs[ti]; int32 len = 0; if (tig) { nutg++; for (uint32 fi=0; fi<tig->ufpath.size(); fi++) { ufNode *frg = &tig->ufpath[fi]; nfrg++; if (frg->ident > FI->numFragments()) writeLog("HUH? ident=%d numfrags=%d\n", frg->ident, FI->numFragments()); inUnitig[frg->ident] = ti; len = MAX(len, frg->position.bgn); len = MAX(len, frg->position.end); } uint32 ls = (uint32)(log10(len) / log10(2)); logSizeMax = (logSizeMax < ls) ? ls : logSizeMax; logSize[ls]++; } } int lost = 0; int found = 0; for (uint32 i=0; i<FI->numFragments()+1; i++) { if (FI->fragmentLength(i) > 0) { if (inUnitig[i] == 0) { writeLog("ERROR frag %d is in unitig 0!\n", i); } else if (inUnitig[i] != noUnitig) { found++; } else { writeLog("ERROR frag %d disappeared!\n", i); lost++; } } } writeLog("checkUnitigMembership()-- nutg=%d nfrg=%d lost=%d found=%d\n", nutg, nfrg, lost, found); writeLog("checkUnitigMembership()-- log2 length histogram:\n"); for (uint32 i=5; i<=logSizeMax; i++) writeLog("checkUnitigMembership()-- %2u (%9u-%9u) %u\n", i, (uint32)1 << i, (uint32)1 << (i+1), logSize[i]); assert(lost == 0); delete [] inUnitig; }
void CGameAI::doHeal() { makeSureLocation(); rightClickTager(script.targetX, script.targetY); Sleep(TALK_INTERVAL); RECT rect = {309, 218, 323, 233}; writeLog(TEXT("执行治疗")); if(leader->getScreen()->colorDeviation(&rect, RGB(255,255,255)) > 5) { CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->locate(IDB_YES, &rect, &YES_CONDITION)) { TRACE("Found yes\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->locate(IDB_SURE, &rect, &SURE_CONDITION)) { TRACE("Found sure\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } rect.left = 325; rect.top = 298; rect.right = 340; rect.bottom = 313; if(leader->getScreen()->colorDeviation(&rect, RGB(255,255,255)) > 5) { CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->locate(IDB_YES, &rect, &YES_CONDITION)) { CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->locate(IDB_SURE, &rect, &SURE_CONDITION)) { CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); SetCursorPos(rect.right+3, rect.bottom+3); } if(leader->getScreen()->locate(IDB_CANCEL, &rect, &CANCEL_CONDITION)) { TRACE("Found cancel\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } else { TRACE("Cancel button not found!\n"); } writeLog(TEXT("治疗完成")); fuckingNP(); }
void ServerNForm::keyPressEvent(QKeyEvent *e) { int key = e->key(); switch(key) { case Qt::Key_A: // Left Down { if(UI2Madata.flag01&BASIC_START) UI2Madata.flag01 |= FPEDAL_LEFT; break; } case Qt::Key_S: // Middle Down { if(UI2Madata.flag01&BASIC_START) UI2Madata.flag01 |= FPEDAL_MIDDLE; break; } case Qt::Key_D: // Right Down { if(UI2Madata.flag01&BASIC_START) { UI2Madata.flag01 |= FPEDAL_RIGHT; writeLog("Pedal down", "3"); scaleDecreaseButton->setEnabled(FALSE); // Disallow scale change while running scaleIncreaseButton->setEnabled(FALSE); // "" camAngle1->setEnabled(FALSE); camAngle2->setEnabled(FALSE); camAngle3->setEnabled(FALSE); } break; } case Qt::Key_Q: // Left Up { UI2Madata.flag01 &= (ALL_ONES - FPEDAL_LEFT); break; } case Qt::Key_W: // Middle Up { UI2Madata.flag01 &= (ALL_ONES - FPEDAL_MIDDLE); break; } case Qt::Key_E: // Right Up { if(UI2Madata.flag01&BASIC_START && UI2Madata.flag01&FPEDAL_RIGHT ) { writeLog("Pedal up", "4"); scaleDecreaseButton->setEnabled(TRUE); // Disallow scale change while running scaleIncreaseButton->setEnabled(TRUE); // "" camAngle1->setEnabled(TRUE); camAngle2->setEnabled(TRUE); camAngle3->setEnabled(TRUE); } UI2Madata.flag01 &= (ALL_ONES - FPEDAL_RIGHT); break; } case Qt::Key_Space: { if(UI2Madata.flag01&BASIC_START) { if (UI2Madata.flag01&FPEDAL_RIGHT && false) { writeLog("Pedal up", "4"); scaleDecreaseButton->setEnabled(TRUE); // Disallow scale change while running scaleIncreaseButton->setEnabled(TRUE); // "" camAngle1->setEnabled(TRUE); camAngle2->setEnabled(TRUE); camAngle3->setEnabled(TRUE); UI2Madata.flag01 &= (ALL_ONES - FPEDAL_RIGHT); } else { UI2Madata.flag01 |= FPEDAL_RIGHT; writeLog("Pedal down", "3"); scaleDecreaseButton->setEnabled(FALSE); // Disallow scale change while running scaleIncreaseButton->setEnabled(FALSE); // "" camAngle1->setEnabled(FALSE); camAngle2->setEnabled(FALSE); camAngle3->setEnabled(FALSE); } } break; } default: { break; } } // switch SIForm::keyPressEvent(e); updateMaster(); }
/** * Zapise do logu zaznam o uspesnem prihlaseni */ void Thread::writeLogSave(QString netName, QString state) { QString msg = getUsername() + "#" + QString::number(Message::LOG_SAVE) + "#The net " + netName + " has been saved. Result: " + state; writeLog(msg); }
void placeZombies(UnitigVector &unitigs, double erate, double elimit) { writeLog("==> SEARCHING FOR ZOMBIES\n"); uint32 *inUnitig = new uint32 [FI->numFragments()+1]; int numZombies = 0; // Mark fragments as dead, then unmark them if they are in a real living unitig. for (uint32 i=0; i<FI->numFragments()+1; i++) inUnitig[i] = noUnitig; for (uint32 ti=0; ti<unitigs.size(); ti++) { Unitig *utg = unitigs[ti]; if (utg == NULL) continue; for (uint32 fi=0; fi<utg->ufpath.size(); fi++) inUnitig[utg->ufpath[fi].ident] = utg->id(); } // For anything not in a living unitig, reload the overlaps and find a new container. // (NOT IMPLEMENTED - for now we just move these to new singleton unitigs). for (uint32 i=0; i<FI->numFragments()+1; i++) { if (FI->fragmentLength(i) == 0) // Deleted fragment continue; if (inUnitig[i] != noUnitig) // Valid fragment in a unitig continue; Unitig *utg = unitigs.newUnitig(false); ufNode frg; frg.ident = i; frg.contained = 0; frg.parent = 0; frg.ahang = 0; frg.bhang = 0; frg.position.bgn = 0; frg.position.end = FI->fragmentLength(i); frg.containment_depth = 0; utg->addFrag(frg, 0, false); writeLog("placeZombies()-- unitig %d created from zombie fragment %d\n", utg->id(), i); numZombies++; } writeLog("RESURRECTED %d ZOMBIE FRAGMENT%s.\n", numZombies, (numZombies != 1) ? "s" : ""); delete [] inUnitig; }
/** * Zapise do logu zaznam o uspesnem prihlaseni */ void Thread::writeLogLogin() { QString msg = getUsername() + "#" + QString::number(Message::LOG_LOGGED) + "#Successfully logged"; writeLog(msg); }
/** * Zapise do logu zaznam o odpojeni klienta */ void Thread::writeLogDisconnect() { QString msg = "#" + QString::number(Message::LOG_DISCONNECT) + "#" + QString::number(socketDescriptor); writeLog(msg); }
void Widget::startServer() { #ifdef WIN32 //Initialize WINSOCK because CFTPServer needs it on Windows WSADATA WSAData; if( WSAStartup( MAKEWORD(1, 0), &WSAData) != 0 ) { //printf("-WSAStartup failure: WSAGetLastError=%d\r\n", WSAGetLastError() ); QMessageBox::information(0, "Error", "Winsock error: " + WSAGetLastError()); //return 0; } #endif QString dir = qApp->applicationDirPath(); if(QDir().exists("/Sync") == false) { QDir().mkdir(dir + "/Sync"); } //Begin FTP Server Initialization ftpServer = new CFtpServer(); ftpServer->SetDataPortRange(100, 900); CFtpServer::CUserEntry *FtpUser = ftpServer->AddUser("lanclient", "tseug", QString(dir + "/Sync").toAscii()); ftpServer->AddUser("anonymous", NULL, "C:\\dir"); if(FtpUser) { FtpUser->SetMaxNumberOfClient( 0 ); FtpUser->SetPrivileges( CFtpServer::READFILE | CFtpServer::WRITEFILE | CFtpServer::LIST | CFtpServer::DELETEFILE | CFtpServer::CREATEDIR | CFtpServer::DELETEDIR ); } else { writeLog("FTP Server Could Not Create User"); sysIcon->showMessage("FTP Error", "No user could be created on the FTP Server. Login Not Possible", QSystemTrayIcon::Critical, 10000 ); error(); } if(ftpServer->StartListening(INADDR_ANY, 21)) { if(ftpServer->StartAccepting() == false) { writeLog("FTP Server Could Not Begin Accepting on Port 21. Code corruption or incompatible dll"); sysIcon->showMessage("FTP Error", "FTP Server Couldn't start accepting connections.", QSystemTrayIcon::Critical, 10000 ); error(); } } else { writeLog("FTP Server Could Not Start Listening On Port 21. Check WINSOCK. This application does not support concurrent instances."); sysIcon->showMessage("FTP Error", "FTP Server Couldn't Listen on port 21. It may be in use already.", QSystemTrayIcon::Critical, 10000 ); error(); } /* End FTP Server Initialization All Files in the applications working directory are now availible through FTP with user "lanclient" with pass "tseug" */ client->setEnabled(false); udpSocket->bind(QHostAddress::Any, standardUdpPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(udpSocket, SIGNAL(readyRead()), this, SLOT(signalReceived())); //resize the mainWindow because we need a bigger interface for server mode mainWindow->resize(600, 500); //create the tab-widget that we parent the sub-windows too computerManager = new QTabWidget(mainWindow); computerManager->setGeometry(5, 70, 590, 430); primaryStatus = new QWidget(computerManager); ftpWindow = new QWidget(computerManager); serverDownload = new QPushButton(ftpWindow); serverDownload->setGeometry(20, 355, 545, 45); QObject::connect(serverDownload, SIGNAL(clicked()), this, SLOT(serverDownloadStart())); computersConnected = 0; ftpFiles = new QTreeWidget(ftpWindow); ftpFiles->setGeometry(0, 0, 580, 350); fileModel = new QTreeWidgetItem(0); computerNames.append("Files"); ftpFiles->setHeaderLabels(computerNames); computerManager->addTab(primaryStatus, "Network Status"); computerManager->addTab(ftpWindow, "File Control"); mapper = new QSignalMapper(this); computerTable = new QTreeWidget(primaryStatus); computerTable->setGeometry(0, 0, 580, 400); QTreeWidgetItem * compModel = new QTreeWidgetItem(0); compModel->setText(0, "Name"); compModel->setText(1,"Bytes Total"); compModel->setText(2, "Active"); computerTable->setHeaderItem(compModel); computerTable->setColumnCount(3); computerTable->setColumnWidth(0, 150); computerTable->setColumnWidth(1, 120); computerTable->setColumnWidth(2, 305); computerTable->show(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); fileWatcher = new QFileSystemWatcher(this); fileWatcher->addPath(dir + "/Sync"); connect(fileWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(sendUpdate())); timer->start(tcpCheckRate); computerManager->show(); updateFileTable(); }
PDMBUILDER_API bool checkSourceCode() { SourceCode *sourceCode = getSourceCode(); //string url = sourceCode->GetUrl(); string fullpath(workspace+"\\"+sourceCode->GetLocalPath()); //string fullpath = sourceCode->GetLocalPath(); string log ; fullpath = changeSeparator(fullpath); string svnPath(fullpath+"\\.svn"); if (!PathFileExists(svnPath.c_str())) { //printf("to checkout"); log += checkout(workspace); //printf("svn checkout\n"); int accessInt = log.find("Access to"); if (accessInt!=string::npos) { if (log.find("forbidden")!=string::npos) { string nextNumFile(fullpath+"\\nextBuildNumber"); if (!PathFileExists(nextNumFile.c_str())) { writeLog(log,workspace+"\\log"); delete sourceCode; return true; } if (forceFlag!="false") { writeLog(log,workspace+"\\log"); } delete sourceCode; return false; } } int errorint = log.find("error"); if (errorint!=string::npos&&errorint==log.length()-5) { writeLog(log,workspace+"\\log"); delete sourceCode; return false; } writeLog(log,workspace+"\\log"); //writeLog(log,workspace+"\\log"); delete sourceCode; return true; } char updateCmd[500]; memset(updateCmd,0,sizeof(updateCmd)); sprintf(updateCmd,"svn update --force --non-interactive --username %s --password %s --accept tf \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetLocalPath().c_str()); //printf("to update"); int exitCode = 0; log.assign("<---------------------------checkout--------------------------->\n "); log += ExeCommand(updateCmd,exitCode,(char *)workspace.c_str()); //printf("svn update\n"); if (exitCode>0&&exitCode!=STILL_ACTIVE) { log += "update source code error"; if (forceFlag!="false") { writeLog(log,workspace+"\\log"); } delete sourceCode; return false; }else if (log.find("svn cleanup")!=string::npos) { char cleanupCmd[100]; memset(cleanupCmd,0,sizeof(cleanupCmd)); sprintf(cleanupCmd,"svn cleanup"); ExeCommand(cleanupCmd,exitCode,(char *)workspace.c_str()); log = ExeCommand(updateCmd,exitCode,(char *)workspace.c_str()); if (exitCode>0&&exitCode!=STILL_ACTIVE) { log += "update source code error"; if (forceFlag!="false") { writeLog(log,workspace+"\\log"); } delete sourceCode; return false; } } int index = log.find("Updated to revision"); if (index>0) { index += 20; int in = log.find_last_of("."); sourceVersion = log.substr(index,in-index); writeLog(log,workspace+"\\log"); delete sourceCode; return true; }else { int rindex = log.rfind("At revision"); if (rindex!=string::npos) { int lindex = log.rfind("."); rindex += 12; sourceVersion = log.substr(rindex,lindex-rindex); } if (forceFlag!="false") { writeLog(log,workspace+"\\log"); } delete sourceCode; return false; } }
// Examine the first (few?) fragments of a unitig, evaluate if they indicate a join should be made. static bool joinUnitigs_examineEnd(UnitigVector &unitigs, Unitig *fr, uint32 idx, bool frFirstEnd, vector<joinEntry> &joins) { uint32 frgIdx = (frFirstEnd) ? (idx) : (fr->ufpath.size() - 1 - idx); ufNode *frg = &fr->ufpath[frgIdx]; bool frgRev = (frg->position.end < frg->position.bgn); // Grab the best edge for this end frag. The last arg requests the 3' end if true. // // If we're looking at the first read, we want to get: // 5' - if the frag is forward // 3' - if the frag is reverse (frgRev == true) // // If we're looking at the lat read, we want to get: // 5' - if the frag is reverse // 3' - if the frag is forward (frgRev == false) // BestEdgeOverlap *bestEdge = OG->getBestEdgeOverlap(frg->ident, (frgRev == frFirstEnd)); uint32 tgtId = bestEdge->fragId(); bool tgt3p = bestEdge->frag3p(); if (tgtId == 0) // No best edge? Skip it. return(false); // Grab the unitig for that best edge. uint32 toID = fr->fragIn(tgtId); Unitig *to = unitigs[toID]; if (to->ufpath.size() == 1) // Joining to something teeny? Don't bother checking further. return(false); if (to->id() == fr->id()) // Join to myself? Nope. return(false); // Grab the read we have an edge to, an compute the overlapping length and left over length. ufNode *tgt = &to->ufpath[to->pathPosition(tgtId)]; bool tgtRev = (tgt->position.end < tgt->position.bgn); // If tgt3p (we overlap to the 3' end) is the same as tgtRev (read is reverse) then the unitig is oriented // correctly. Otherwise, positions need to be reverse-complemented. bool toFlip = false; if ((frFirstEnd == true) && (tgt3p == false) && (tgtRev == false)) // source read is at the start, overlap to 5' and the read is forward, need to flip the target unitig toFlip = true; if ((frFirstEnd == true) && (tgt3p == true) && (tgtRev == true)) // source read is at the start, overlap to 3' and the read is reverse, need to flip the target unitig toFlip = true; if ((frFirstEnd == false) && (tgt3p == false) && (tgtRev == true)) // source read is at the end, overlap to 5' and the read is reverse, need to flip the target unitig toFlip = true; if ((frFirstEnd == false) && (tgt3p == true) && (tgtRev == false)) // source read is at the end, overlap to 3' and the read is forward, need to flip the target unitig toFlip = true; uint32 toMin = MIN(tgt->position.bgn, tgt->position.end); uint32 toMax = MAX(tgt->position.bgn, tgt->position.end); uint32 toLen = to->getLength(); uint32 frLen = fr->getLength(); if (toFlip) { toMin = toLen - MAX(tgt->position.bgn, tgt->position.end); toMax = toLen - MIN(tgt->position.bgn, tgt->position.end); } assert(toMin < toMax); // Our two unitigs are of length frLen and toLen. We are appending some portion of 'to' onto // 'fr', and 'discarding' the rest. If the 'discarded' piece is larger than the 'fr' unitig, we // don't want to do the join. // // We err on the side of the discarded piece. uint32 joinLen = 0; uint32 discLen = 0; if (frFirstEnd == true) { joinLen = toMin + frLen; // Prepend the start of 'to' onto 'fr'. discLen = toLen - toMin; } else { joinLen = frLen + toLen - toMax; // Append the end of 'to' onto 'fr'. discLen = toMax; } // If the discard is bigger than us, we do damage by joining. if (discLen > frLen) return(false); // The joined should be much larger and the discarded much smaller. uint32 maxLen = MAX(frLen, toLen); uint32 minLen = MIN(frLen, toLen); double joinChange = (double)joinLen / maxLen; double discChange = (double)discLen / minLen; bool isBad = false; if ((joinChange < 1.10) || (0.75 < discChange)) // Bad if we didn't really change sizes. isBad = true; if ((1.0 < joinChange) && (discChange < 0.5)) // But good if discard is tiny. This occurs if we merge a small with a big. The join change // is somewhat small (1.05 say) yet most of the smaller unitig is used. isBad = false; if (isBad) { writeLog("joinUnitigs_examineEnd()-- join unitig %6u (%7ubp) frag %6u %s <-> unitig %6u (%7ubp) frag %6u %s <-> length %5.2f %7u and %5.2f %7u BAD\n", fr->id(), fr->getLength(), frg->ident, (frgRev) ? "rev" : "fwd", to->id(), to->getLength(), tgt->ident, (tgtRev) ? "rev" : "fwd", joinChange, joinLen, discChange, discLen); return(false); } // OK, join. writeLog("joinUnitigs_examineEnd()-- join unitig %6u (%7ubp) frag %6u %s <-> unitig %6u (%7ubp) frag %6u %s <-> length %5.2f %7u and %5.2f %7u\n", fr->id(), fr->getLength(), frg->ident, (frgRev) ? "rev" : "fwd", to->id(), to->getLength(), tgt->ident, (tgtRev) ? "rev" : "fwd", joinChange, joinLen, discChange, discLen); joins.push_back(joinEntry(frg->ident, frFirstEnd, tgt->ident, toFlip, joinLen)); return(true); }
Widget::Widget() { // This class is the host of the whole application. This is BAD. Needs to be rectified. Should split this up into either: More classes OR More Files firstComp = NULL; //Setup the linked list //Spawn a QMainWindow, and set its attributes mainWindow = new QMainWindow(); mainWindow->resize(400, 400); mainWindow->setWindowTitle("Lan Party Manager " + releaseType + " " + releaseVer); setup = new QSettings(QSettings::IniFormat, QSettings::SystemScope, "Alldritt Coding", "LanParty Manager", this); QStringList keys = setup->allKeys(); if(keys.length() != 8) { setup->clear(); setup->setValue("udpBroadcast", 1000); setup->setValue("tcpBroadcast", 5000); setup->setValue("udpPort", 45454); setup->setValue("tcpPort", 1337); setup->setValue("debug", false); setup->setValue("releaseType", releaseType); setup->setValue("releaseVer", releaseVer); setup->setValue("networkUpdateRate", 1000); } else { udpBroadcastRate = setup->value("udpBroadcast", 1000).toInt(); tcpCheckRate = setup->value("tcpBroadcast", 5000).toInt(); standardUdpPort = setup->value("udpPort", 45454).toInt(); standardTcpPort = setup->value("tcpPort", 1337).toInt(); debugMode = setup->value("debug", false).toBool(); //releaseType = setup->value("releaseType", "").toString(); //releaseVer = setup->value("releaseVer", "").toString(); networkUpdateRate = setup->value("networkUpdateRate", 1000).toInt(); } settings = new QWidget(mainWindow, Qt::Dialog); settings->resize(300, 300); settings->setWindowTitle("Settings"); settings->hide(); QLabel * la = new QLabel(settings); la->move(15, 15); la->setText("UDP Broadcast Delay"); QLabel * lb = new QLabel(settings); lb->move(15, 45); lb->setText("TCP Broadcast Delay"); QLabel * lc = new QLabel(settings); lc->move(15, 75); lc->setText("Default UDP Port (Advanced)"); QLabel * ld = new QLabel(settings); ld->move(15, 105); ld->setText("Default TCP Port (Advanced)"); QLabel * le = new QLabel(settings); le->move(15, 165); le->setText("Debug Mode"); QLabel * lf = new QLabel(settings); lf->move(15, 135); lf->setText("Total Bytes Refresh Rate"); uPort = new QLineEdit(settings); uPort->setGeometry(200, 75, 50, 20); uPort->setText(QString().number(standardUdpPort)); tPort = new QLineEdit(settings); tPort->setGeometry(200, 105, 50, 20); tPort->setText(QString().number(standardTcpPort)); uDelay = new QLineEdit(settings); uDelay->setGeometry(200, 15, 50, 20); uDelay->setText(QString().number(udpBroadcastRate)); tDelay = new QLineEdit(settings); tDelay->setGeometry(200, 45, 50, 20); tDelay->setText(QString().number(tcpCheckRate)); nDelay = new QLineEdit(settings); nDelay->setGeometry(200, 135, 50, 20); nDelay->setText(QString().number(networkUpdateRate)); debugOn = new QCheckBox(settings); debugOn->move(200, 165); debugOn->setChecked(debugMode); QPushButton * apply = new QPushButton(settings); apply->setGeometry(200, 200, 60, 30); apply->setText("Apply"); QObject::connect(apply, SIGNAL(clicked()), this, SLOT(apply())); QWidget * passWindow = new QWidget(mainWindow, Qt::Tool); passWindow->resize(200, 80); passWindow->hide(); QLabel * passLabel = new QLabel(passWindow); passLabel->move(50, 10); passLabel->setText("Enter Password"); passBox = new QLineEdit(passWindow); passBox->setGeometry(40, 25, 130, 20); QPushButton * enter = new QPushButton(passWindow); enter->setGeometry(40, 50, 50, 25); enter->setText("Enter"); QObject::connect(enter, SIGNAL(clicked()), this, SLOT(passEnter())); QObject::connect(enter, SIGNAL(clicked()), passWindow, SLOT(hide())); QObject::connect(passBox, SIGNAL(returnPressed()), this, SLOT(passEnter())); QObject::connect(passBox, SIGNAL(returnPressed()), passWindow, SLOT(hide())); icon = new QIcon(":/images/icon.png"); sysIcon = new QSystemTrayIcon(*icon, this); sysIcon->show(); sysMenu = new QMenu(mainWindow); QAction * exitAction = sysMenu->addAction("Exit"); sysIcon->setContextMenu(sysMenu); connect(exitAction, SIGNAL(triggered(bool)), qApp, SLOT(quit())); connect(exitAction, SIGNAL(triggered(bool)), this, SLOT(close())); bool success = connect(sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconClicked(QSystemTrayIcon::ActivationReason))); if(success != true) { sysIcon->showMessage("System Tray Error", "Window Respawn Connection Failed", QSystemTrayIcon::Information, 10000 ); } QMenu* file = mainWindow->menuBar()->addMenu(tr("&File")); QMenu* help = mainWindow->menuBar()->addMenu(tr("&Help")); QAction* exitAct = new QAction(tr("&Exit"), this); exitAct->setStatusTip(tr("Quit")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(quit())); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); QAction* settingAct = new QAction(tr("&Settings"), this); settingAct->setStatusTip(tr("Access the Settings page")); connect(settingAct, SIGNAL(triggered()), this, SLOT(settingsWindow())); QAction* aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); QAction* aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); help->addAction(aboutQtAct); help->addAction(aboutAct); file->addAction(settingAct); file->addAction(exitAct); mainWindow->show(); server = new QPushButton(mainWindow); client = new QPushButton(mainWindow); log = new QFile("log.txt"); currentTime = new QDateTime(); //create the log timestamp *currentTime = QDateTime::currentDateTime(); //get system time if(!log->open(QIODevice::ReadWrite|QIODevice::Append)) { QMessageBox::information(0, "Error", "Can't open logfile. Reason: " + log->errorString()); } if(debugMode) { writeLog("LanMan " + releaseType + " " + releaseVer + " Logfile Start"); writeLog("Time Format is: DD/MM/YYYY - HOUR:MIN:SEC AM/PM"); } server->setGeometry(10, 30, 100, 30); client->setGeometry(290, 30, 100, 30); server->setText("SERVER MODE"); client->setText("CLIENT MODE"); client->show(); server->show(); connect(client, SIGNAL(released()), this, SLOT(startClient())); connect(server, SIGNAL(released()), passWindow, SLOT(show())); mainLabel = new QLabel("", mainWindow); mainLabel->move(165, 40); mainLabel->show(); udpSocket = new QUdpSocket(this); }
void CGameAI::doBackToCity() { int x = 0; int y = 0; if(script.x == 0 || script.y == 0) return; writeLog(TEXT("回城开始")); while(TRUE && isAIStart) { if(!leader->mapWindow->isExists()) { fuckingMouse(); Sleep(TALK_INTERVAL); continue; } ++backToCityCounter; Sleep(TALK_INTERVAL); x = leader->mapWindow->getX(); y = leader->mapWindow->getY(); if((x == script.x && y == script.y) || (x == script.targetX && y == script.targetY)) break; TRACE("Do back city: %d,%d %d,%d\n", script.x, script.y, script.targetX, script.targetY); if((script.x == 72 && script.y == 123) || (script.x == 233 && script.y == 78) || (script.x == 162 && script.y == 130) || (script.targetX == 72 && script.targetY == 123) || (script.targetX == 233 && script.targetY == 78) || (script.targetX == 162 && script.targetY == 130)) { if(x == 72 && y == 123) { rightClickTager(73, 123); continue; } else if(x == 233 && y == 78) { rightClickTager(233, 77); continue; } else if(x == 162 && y == 130 ) { rightClickTager(163, 130); continue; } } if((script.x == 63 && script.y == 79) || (script.x == 242 && script.y == 100) || (script.x == 141 && script.y == 148) || (script.targetX == 63 && script.targetY == 79) || (script.targetX == 242 && script.targetY == 100) || (script.targetX == 141 && script.targetY == 148)) { if(x == 63 && y == 79) { rightClickTager(63, 78); continue; } else if(x == 242 && y == 100) { rightClickTager(243, 100); continue; } else if(x == 141 && y == 148) { rightClickTager(141, 147); continue; } } leader->bottomWindow->openSystemWindow(); Sleep(TALK_INTERVAL); if(leader->systemWindow->isExists()) { leader->systemWindow->clickBackToCity(); } else { TRACE("System window not exists\n"); } } writeLog(TEXT("回城完成")); }
void CGameAI::doSale() { RECT rect = {0}; int goodsCounter = 0; int times = 0; BOOL done = FALSE; int tmp = 0; int currX = 0; int currY = 0; makeSureLocation(); writeLog(TEXT("出售魔石")); while(!done && isAIStart) { ++times; rightClickTager(script.targetX, script.targetY); Sleep(TALK_INTERVAL/2); fuckingMouse(); Sleep(TALK_INTERVAL/2); tmp = leader->getScreen()->colorDeviation(&SALE_CONDITION, RGB(255,255,255)); if(tmp >=30 && tmp < 50) { CSystem::leftClick(&SALE_CONDITION); Sleep(TALK_INTERVAL); } else if (tmp < 30 && tmp > 5) { CSystem::leftClick(&SALE_CONDITION2); Sleep(TALK_INTERVAL); } for(int i = 0; i < LOOP_TIMES; ++i) { if(leader->getScreen()->locate(IDB_ALL, &rect, &SALE_ALL_CONDITION)) { TRACE("Found Sale all\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); for( int x = 0; x < LOOP_TIMES; ++x) { if(leader->getScreen()->locate(IDB_SURE, &rect, &SALE_SURE_CONDITION)) { TRACE("Found sale sure\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->locate(IDB_YES, &rect, &SALE_YES_CONDITION)) { TRACE("Found sale yes\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); break; } Sleep(TALK_INTERVAL); } checkGoods(&goodsCounter); if(goodsCounter < 10) { done = TRUE; break; } } if(leader->getScreen()->locate(IDB_CANCEL, &rect, &SALE_CANCEL_CONDITION)) { TRACE("Found Sale Cancel\n"); CSystem::leftClick(&rect); Sleep(TALK_INTERVAL); } if(leader->getScreen()->colorDeviation(&NOT_SALE_CONDITION, RGB(255,255,255)) > 5) { CSystem::leftClick(&NOT_SALE_CONDITION); Sleep(TALK_INTERVAL); done = TRUE; break; } else if(leader->getScreen()->colorDeviation(&NOT_SALE_CONDITION2, RGB(255,255,255)) > 5) { CSystem::leftClick(&NOT_SALE_CONDITION2); Sleep(TALK_INTERVAL); done = TRUE; break; } Sleep(TALK_INTERVAL); } } writeLog(TEXT("出售魔石完成")); fuckingNP(); }
void CGameAI::doFindEnemy() { CCgxMapWindow* pMap = leader->mapWindow; int lastX = 0; int lastY = 0; int endOfNorth = 0; int endOfSouth = 0; int walkStep = 0; BOOL stepFlag = TRUE; int currX = 0; int currY = 0; int notExistCounter = 0; BOOL isEndOfWest = FALSE; BOOL isPress = FALSE; int goodsCounter = 0; int nowMinu = 0; int failCounter = 0; CString logTmp; writeLog(TEXT("开始遇敌")); //统计 int fightingCounter = 0; int fightingRound = fightRound; //end 统计 while(isAIStart) { if(pMap->isExists()) { if(isFighting == TRUE) { isFighting = FALSE; // 到点重置 if(!isReseted && resetMinu != 0) { nowMinu = getMinu(); TRACE("Now is %d reset minu %d\n", nowMinu, resetMinu); if(resetMinu == nowMinu) { writeLog(TEXT("到达重置时间,重新开始。")); script.resetPos(); script.nextStep(); isReseted = TRUE; break; } } Sleep(300); pMap->leftClickCenter(); //防断线 fuckingNP(); notExistCounter = 0; Sleep(200); ++fightingCounter; ++fightTimes; //战斗超过10次才检查物品 if(fightingCounter > 10) { checkGoods(&goodsCounter); logTmp.Format(TEXT("战斗结束,检查物品有%d个"), goodsCounter); writeLog(logTmp); TRACE("==================Goods: %d\n", goodsCounter); if(goodsCounter == NUMBER_OF_GOODS) { if(isConfigYes(SCRIPT_CONTROLL, WHEN_FULL_GOODS_STOP_FIND_ENEMY)) { script.resetPos(); break; } } } if(!checkHPAndMP()) { break; } } currX = pMap->getX(); currY = pMap->getY(); //防止迷宫重置 if(script.lastX == currX && script.lastY == currY) { walkStep = pMap->goNext(0, 1); Sleep(walkStep* WALK_INTERVAL); } if(abs(script.lastX - currX) < 2 && abs(script.lastY - currY) < 2) { walkStep = pMap->goNext(script.lastX - currX, script.lastY - currY); Sleep(walkStep* WALK_INTERVAL); } // 无限制遇敌 if(script.x == 0 && script.y == 0) { if(!isEndOfWest) { if(lastX == currX) { isEndOfWest = TRUE; lastY = 0; continue; } walkStep = pMap->goNext(-10, 0); Sleep(walkStep* WALK_INTERVAL / 2); } else if(endOfSouth == 0) { if(lastY == currY) { endOfSouth = currY; lastY = 0; continue; } walkStep = pMap->goNext(0, 8); Sleep(walkStep* WALK_INTERVAL/ 2); } else if(endOfNorth == 0) { if(lastY == currY) { endOfNorth = currY; continue; } walkStep = pMap->goNext(0, -8); Sleep(walkStep* WALK_INTERVAL/ 2); } else { //TRACE("All found\n"); if(currY <= endOfNorth+1) walkStep = pMap->moveMouse(0, 8); else if(currY >= endOfSouth-1) walkStep = pMap->moveMouse(0, -8); else if(!isPress) walkStep = pMap->moveMouse(0, 8); if(!isPress) { isPress = TRUE; CSystem::leftPress(0, 0); } } } else // 限制遇敌 { if(stepFlag) { //TRACE("current: (%d,%d), target: (%d,%d)\n", currX, currY, script.x, script.y); if(currX == script.x && currY == script.y) stepFlag = FALSE; else walkStep = pMap->moveMouse(script.x-currX, script.y-currY); } else { if(currX == script.targetX && currY == script.targetY) stepFlag = TRUE; else walkStep = pMap->moveMouse(script.targetX-currX, script.targetY-currY); } if(!isPress) { isPress = TRUE; CSystem::leftPress(0, 0); } } // // end 限制遇敌 Sleep(WALK_INTERVAL*walkStep); //重置机制 if(lastX == currX && lastY == currY) ++failCounter; else failCounter = 0; if(failCounter > 10) { writeLog(TEXT("发现人物遇敌时卡死,尝试恢复")); isEndOfWest = FALSE; endOfNorth = 0; endOfSouth = 0; failCounter = 0; isPress = FALSE; } // end 重置机制 lastX = currX; lastY = currY; continue; } else { if(leader->isOffline()) { logTmp.Format(TEXT("执行脚本命令[%d] x: %d, y: %d 目标x: %d, 目标y: %d 时断线") , script.command, script.x, script.y, script.targetX, script.targetY); writeLog(logTmp); isAIStart = FALSE; break; } isPress = FALSE; ++notExistCounter; if(notExistCounter < 5) { Sleep(1000); continue; } } autoFight(); } logTmp.Format(TEXT("战斗结束,一共战斗%d次, %d回合"), fightingCounter, fightRound-fightingRound); writeLog(logTmp); }
void StelLogger::debugLogHandler(QtMsgType, const QMessageLogContext&, const QString& msg) { fprintf(stderr, "%s\n", msg.toUtf8().constData()); writeLog(QString(msg)); }
PDMBUILDER_API void writelog(string log,string workspace){ writeLog(log,workspace); }
void StelLogger::init(const QString& logFilePath) { logFile.setFileName(logFilePath); if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text | QIODevice::Unbuffered)) qInstallMessageHandler(StelLogger::debugLogHandler); // write timestamp writeLog(QString("%1").arg(QDateTime::currentDateTime().toString(Qt::ISODate))); // write info about operating system writeLog(StelUtils::getOperatingSystemInfo()); // write compiler version #if defined __GNUC__ && !defined __clang__ #ifdef __MINGW32__ #define COMPILER "MinGW GCC" #else #define COMPILER "GCC" #endif writeLog(QString("Compiled using %1 %2.%3.%4").arg(COMPILER).arg(__GNUC__).arg(__GNUC_MINOR__).arg(__GNUC_PATCHLEVEL__)); #elif defined __clang__ writeLog(QString("Compiled using %1 %2.%3.%4").arg("Clang").arg(__clang_major__).arg(__clang_minor__).arg(__clang_patchlevel__)); #elif defined _MSC_VER writeLog(QString("Compiled using %1").arg(getMsvcVersionString(_MSC_VER))); #else writeLog("Unknown compiler"); #endif // write Qt version writeLog(QString("Qt runtime version: %1").arg(qVersion())); writeLog(QString("Qt compilation version: %1").arg(QT_VERSION_STR)); // write addressing mode #if defined(__LP64__) || defined(_WIN64) writeLog("Addressing mode: 64-bit"); #else writeLog("Addressing mode: 32-bit"); #endif // write memory and CPU info #ifdef Q_OS_LINUX #ifndef BUILD_FOR_MAEMO QFile infoFile("/proc/meminfo"); if(!infoFile.open(QIODevice::ReadOnly | QIODevice::Text)) writeLog("Could not get memory info."); else { while(!infoFile.peek(1).isEmpty()) { QString line = infoFile.readLine(); line.chop(1); if (line.startsWith("Mem") || line.startsWith("SwapTotal")) writeLog(line); } infoFile.close(); } infoFile.setFileName("/proc/cpuinfo"); if (!infoFile.open(QIODevice::ReadOnly | QIODevice::Text)) writeLog("Could not get CPU info."); else { while(!infoFile.peek(1).isEmpty()) { QString line = infoFile.readLine(); line.chop(1); if(line.startsWith("model name") || line.startsWith("cpu MHz")) writeLog(line); } infoFile.close(); } QProcess lspci; lspci.start("lspci -v", QIODevice::ReadOnly); lspci.waitForFinished(300); const QString pciData(lspci.readAll()); QStringList pciLines = pciData.split('\n', QString::SkipEmptyParts); for (int i = 0; i<pciLines.size(); i++) { if(pciLines.at(i).contains("VGA compatible controller")) { writeLog(pciLines.at(i)); i++; while(i < pciLines.size() && pciLines.at(i).startsWith('\t')) { if(pciLines.at(i).contains("Kernel driver in use")) writeLog(pciLines.at(i).trimmed()); else if(pciLines.at(i).contains("Kernel modules")) writeLog(pciLines.at(i).trimmed()); i++; } } } #endif // Aargh Windows API #elif defined Q_OS_WIN // Hopefully doesn't throw a linker error on earlier systems. Not like // I'm gonna test it or anything. if (QSysInfo::WindowsVersion >= QSysInfo::WV_2000) { #ifdef __LP64__ MEMORYSTATUSEX statex; GlobalMemoryStatusEx(&statex); writeLog(QString("Total physical memory: %1 MB (unreliable)").arg(statex.ullTotalPhys/(1024<<10))); writeLog(QString("Total virtual memory: %1 MB (unreliable)").arg(statex.ullTotalVirtual/(1024<<10))); writeLog(QString("Physical memory in use: %1%").arg(statex.dwMemoryLoad)); #else MEMORYSTATUS statex; GlobalMemoryStatus(&statex); writeLog(QString("Total memory: %1 MB (unreliable)").arg(statex.dwTotalPhys/(1024<<10))); writeLog(QString("Total virtual memory: %1 MB (unreliable)").arg(statex.dwTotalVirtual/(1024<<10))); writeLog(QString("Physical memory in use: %1%").arg(statex.dwMemoryLoad)); #endif } else writeLog("Windows version too old to get memory info."); HKEY hKey = NULL; DWORD dwType = REG_DWORD; DWORD numVal = 0; DWORD dwSize = sizeof(numVal); // iterate over the processors listed in the registry QString procKey = "Hardware\\Description\\System\\CentralProcessor"; LONG lRet = ERROR_SUCCESS; int i; for(i = 0; lRet == ERROR_SUCCESS; i++) { lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, qPrintable(QString("%1\\%2").arg(procKey).arg(i)), 0, KEY_QUERY_VALUE, &hKey); if(lRet == ERROR_SUCCESS) { if(RegQueryValueExA(hKey, "~MHz", NULL, &dwType, (LPBYTE)&numVal, &dwSize) == ERROR_SUCCESS) writeLog(QString("Processor speed: %1 MHz").arg(numVal)); else writeLog("Could not get processor speed."); } // can you believe this trash? dwType = REG_SZ; char nameStr[512]; DWORD nameSize = sizeof(nameStr); if (lRet == ERROR_SUCCESS) { if (RegQueryValueExA(hKey, "ProcessorNameString", NULL, &dwType, (LPBYTE)&nameStr, &nameSize) == ERROR_SUCCESS) writeLog(QString("Processor name: %1").arg(nameStr)); else writeLog("Could not get processor name."); } RegCloseKey(hKey); } if(i == 0) writeLog("Could not get processor info."); #elif defined Q_OS_MAC QProcess systemProfiler; systemProfiler.start("/usr/sbin/system_profiler -detailLevel mini SPHardwareDataType SPDisplaysDataType"); systemProfiler.waitForStarted(); systemProfiler.waitForFinished(); const QString systemData(systemProfiler.readAllStandardOutput()); QStringList systemLines = systemData.split('\n', QString::SkipEmptyParts); for (int i = 0; i<systemLines.size(); i++) { if(systemLines.at(i).contains("Model")) { writeLog(systemLines.at(i).trimmed()); } if(systemLines.at(i).contains("Processor")) { writeLog(systemLines.at(i).trimmed()); } if(systemLines.at(i).contains("Memory")) { writeLog(systemLines.at(i).trimmed()); } if(systemLines.at(i).contains("VRAM")) { writeLog(systemLines.at(i).trimmed()); } } #elif defined Q_OS_BSD4 QProcess dmesg; dmesg.start("/sbin/dmesg", QIODevice::ReadOnly); dmesg.waitForStarted(); dmesg.waitForFinished(); const QString dmesgData(dmesg.readAll()); QStringList dmesgLines = dmesgData.split('\n', QString::SkipEmptyParts); for (int i = 0; i<dmesgLines.size(); i++) { if (dmesgLines.at(i).contains("memory")) { writeLog(dmesgLines.at(i).trimmed()); } if (dmesgLines.at(i).contains("CPU")) { writeLog(dmesgLines.at(i).trimmed()); } if (dmesgLines.at(i).contains("VGA")) { writeLog(dmesgLines.at(i).trimmed()); } } #endif }
PDMBUILDER_API string process() { list<BuildStep *> * buildStep = getBuildStep(); string log; char Time[255]; char Temp[100]; int exitCode; SYSTEMTIME sys; GetLocalTime( &sys ); int minute = sys.wMinute; int second = sys.wSecond; int millisecond = sys.wMilliseconds; sprintf(Time,"%4d-%02d-%02d %02d:%02d:%02d.%03d ",sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds); for (list<BuildStep *>::iterator iter=buildStep->begin();iter != buildStep->end();++iter) { log = ""; string name = (*iter)->GetName(); string program = (*iter)->GetProgram(); string options = (*iter)->GetOptions(); environment += name +";"; //log = name + program + options; //writeLog(log,workspace+"\\log"); log += RunBuildStep(name,program,options,exitCode); //Sleep(500); int index = log.rfind("Error(s)"); if (index == -1) { index = log.rfind("error"); if (index != -1) { //string str = log.substr(index-2,1); exitError ++; } else { index = log.rfind("warning"); if (index!=-1) { //string str = log.substr(index-2,1); exitWarning ++; } else { exitSuccess ++; } } } else { string str = log.substr(index-2,1); exitError += atoi(str.c_str()); index = log.rfind("Warning(s)"); str = log.substr(index-2,1); exitWarning += atoi(str.c_str()); } //writeLog(log,workspace+"\\log"); /* if (exitCode==0) { exitSuccess++; }else if(exitCode>0&&exitCode!=STILL_ACTIVE){ exitError ++; }else if (exitCode==STILL_ACTIVE) { exitSuccess++; }*/ } GetLocalTime(&sys); //float dur = (sys.wMinute - minute)*60+second - sys.wSecond + (sys.wMilliseconds-millisecond)/1000; int dur = (sys.wMinute-minute)*60*1000+(sys.wSecond-second)*1000+(sys.wMilliseconds-millisecond); sprintf(Temp,"%d",dur); //sprintf(Temp,"%d",millisecond-sys.wMilliseconds); buildTime.assign(Time); duration.assign(Temp); if (exitError>0&&exitSuccess>0) { result = "ERROR"; }else if (exitError>0&&exitSuccess==0) { result = "FAILURE"; }else if (exitError==0&&exitSuccess ==0&&exitWarning==0) { result = "SUCCESS"; }else if (exitSuccess>0&&exitError==0) { result = "SUCCESS"; }else if (exitError==0&&exitWarning>0) { result = "WARNING"; } //result.assign("SUCCESS"); log = ""; //log = "build finish;\n"; //writeLog(log,workspace+"\\log"); FILE *fp; string filePath = workspace+"\\"+numberFile; if (!PathFileExists(filePath.c_str())) { buildNumber = 1; //log = "create next number file"; if (fp = fopen(filePath.c_str(),"w")) { if (EOF == fprintf(fp,"%d",buildNumber)) { log += "[Log-->] write build number error"; } else { log += "[Log-->] write build number success"; } fclose(fp); }else { log += "[log -->] open file error"; //writeLog(log,workspace+"\\log"); } } else if (fp=fopen(filePath.c_str(),"r+")) { if(EOF==fscanf(fp,"%d",&buildNumber)){ buildNumber = 0; } buildNumber ++; rewind(fp); //fseek(fp,0,SEEK_SET); if(EOF==fprintf(fp,"%d",buildNumber)){ //buildNumber = 0; log += "[Log-->] write build number error"; } else { log += "[Log-->] write build number success"; } fclose(fp); } writeLog(log,workspace+"\\log"); delete buildStep; return log; }
/** * Zapise do logu zapis o neuspesnem prihlaseni * @param name Prihlasovaci jmeno, ke kteremu se neuspesne prihlaseni vaze */ void Thread::writeLogWronglogin(QString name) { QString msg = name + "#" + QString::number(Message::LOG_WRONGLOGIN) + "#Attempt to unauthorized access!"; writeLog(msg); }
int main (int argc, char **argv){ // DOES NOT WORK! // // setup signal trap to catch Ctrl-C // struct sigaction new_action, old_action; // new_action.sa_handler = ctrlc_handler; // sigemptyset(&new_action.sa_mask); // new_action.sa_flags = 0; //// if( sigaction (SIGINT, NULL, &old_action) == -1) //// perror("Failed to retrieve old handle"); //// if (old_action.sa_handler != SIG_IGN) //// if( sigaction (SIGINT, &new_action, NULL) == -1) //// perror("Failed to set new Handle"); // if( sigaction (SIGTERM, NULL, &old_action) == -1) // perror("Failed to retrieve old handle"); // if (old_action.sa_handler != SIG_IGN) // if( sigaction (SIGTERM, &new_action, NULL) == -1) // perror("Failed to set new Handle"); atexit(exit_handler); // real work, long long t3, t4; t3= cci::common::event::timestampInUS(); int threading_provided; int err = MPI_Init_thread(&argc, &argv, MPI_THREAD_SINGLE, &threading_provided); MPI_Comm comm = MPI_COMM_WORLD; int rank=-1; MPI_Comm_rank(comm, &rank); time_t now = time(0); // Convert now to tm struct for local timezone tm* localtm = localtime(&now); if (rank == 0) cci::common::Debug::print("The START local date and time is: %s\n", asctime(localtm)); if (rank == 0) cci::common::Debug::print("initialized MPI\n"); // IMPORTANT: need to initialize random number generator right now. srand(rank*113 + 1); //srand(cci::common::event::timestampInUS()); long long t1, t2; t1 = cci::common::event::timestampInUS(); conf = new cci::rt::syntest::SynDataConfiguratorFull(argc, argv); cci::common::LogSession *logsession = NULL; if (conf->getLogger() != NULL) logsession = conf->getLogger()->getSession("setup"); cci::rt::Process *p = new cci::rt::Process(comm, argc, argv, conf); p->setup(); t2 = cci::common::event::timestampInUS(); if (logsession != NULL) logsession->log(cci::common::event(0, std::string("proc setup"), t1, t2, std::string(), ::cci::common::event::NETWORK_WAIT)); p->run(); t1 = cci::common::event::timestampInUS(); p->teardown(); t2 = cci::common::event::timestampInUS(); if (logsession != NULL) logsession->log(cci::common::event(0, std::string("proc teardown"), t1, t2, std::string(), ::cci::common::event::NETWORK_WAIT)); if (p != NULL) delete p; MPI_Barrier(comm); t4= cci::common::event::timestampInUS(); if (rank ==0) cci::common::Debug::print("finished processing in %lu us.\n", long(t4-t3)); writeLog(); exit(0); return 0; }
/** * Zapise do logu zaznam o uspesnem prihlaseni */ void Thread::writeLogSimulate(QString netName, QString version, QString state) { QString msg = getUsername() + "#" + QString::number(Message::LOG_SIMULATE) + "#The net \"" + netName\ + ":" + version + "\" has been simulated. Result: " + state; writeLog(msg); }
uint32 ChunkGraph::countFullWidth(FragmentEnd firstEnd) { uint64 firstIdx = getIndex(firstEnd); assert(firstIdx < _maxFragment * 2 + 2); if (_pathLen[firstIdx] > 0) return _pathLen[firstIdx]; uint32 length = 0; std::set<FragmentEnd> seen; FragmentEnd lastEnd = firstEnd; uint64 lastIdx = firstIdx; // Until we run off the chain, or we hit a fragment with a known length, compute the length FROM // THE START. // while ((lastIdx != 0) && (_pathLen[lastIdx] == 0)) { seen.insert(lastEnd); _pathLen[lastIdx] = ++length; // Follow the path of lastEnd lastEnd = OG->followOverlap(lastEnd); lastIdx = getIndex(lastEnd); } // Check why we stopped. Three cases: // // 1) We ran out of best edges to follow -- lastEnd.fragId() == 0 // 2) We encountered a fragment with known length -- _pathLen[lastEnd.index()] > 0 // 3) We encountered a self-loop (same condition as case 2) // // To distinguish case 2 and 3, we keep a set<> of the fragments we've seen in this construction. // If 'lastEnd' is in that set, then we're case 3. If so, adjust every node in the cycle to have // the same length, the length of the cycle itself. // // 'lastEnd' and 'index' are the first fragment in the cycle; we've seen this one before. // if (lastEnd.fragId() == 0) { // Case 1. Do nothing. ; } else if (seen.find(lastEnd) != seen.end()) { // Case 3, a cycle. uint32 cycleLen = length - _pathLen[lastIdx] + 1; FragmentEnd currEnd = lastEnd; uint64 currIdx = lastIdx; do { _pathLen[currIdx] = cycleLen; currEnd = OG->followOverlap(currEnd); currIdx = getIndex(currEnd); } while (lastEnd != currEnd); } else { // Case 2, an existing path. length += _pathLen[lastIdx]; } // Our return value is now whatever count we're at. uint32 lengthMax = length; // Traverse again, converting "path length from the start" into "path length from the end". Any // cycle has had its length set correctly already, and we stop at either the start of the cycle, // or at the start of any existing path. // FragmentEnd currEnd = firstEnd; uint64 currIdx = firstIdx; while (currEnd != lastEnd) { _pathLen[currIdx] = length--; currEnd = OG->followOverlap(currEnd); currIdx = getIndex(currEnd); } if (logFileFlagSet(LOG_CHUNK_GRAPH)) { seen.clear(); currEnd = firstEnd; currIdx = firstIdx; writeLog("PATH from %d,%d length %d:", firstEnd.fragId(), (firstEnd.frag3p()) ? 3 : 5, _pathLen[firstIdx]); while ((currEnd.fragId() != 0) && (seen.find(currEnd) == seen.end())) { seen.insert(currEnd); if (currEnd == lastEnd) writeLog(" LAST"); writeLog(" %d,%d(%d)", currEnd.fragId(), (currEnd.frag3p()) ? 3 : 5, _pathLen[currIdx]); currEnd = OG->followOverlap(currEnd); currIdx = getIndex(currEnd); } if (seen.find(currEnd) != seen.end()) writeLog(" CYCLE %d,%d(%d)", currEnd.fragId(), (currEnd.frag3p()) ? 3 : 5, _pathLen[currIdx]); writeLog("\n"); } if (lengthMax != _pathLen[firstIdx]) writeLog("ERROR: lengthMax %d _pathLen[] %d\n", lengthMax, _pathLen[firstIdx]); assert(lengthMax == _pathLen[firstIdx]); return(_pathLen[firstIdx]); }
/** * Zapise do logu zaznam o uspesnem prihlaseni */ void Thread::writeLogLoad(QString netName, QString state) { QString msg = getUsername() + "#" + QString::number(Message::LOG_LOAD) + "#The net " + netName + " has been loaded. Result: " + state; writeLog(msg); }
FragmentInfo::FragmentInfo(gkStore *gkp, const char *prefix, uint32 minReadLen) { if (load(prefix)) return; writeLog("FragmentInfo()-- Loading fragment information\n"); if (minReadLen > 0) writeLog("FragmentInfo()-- Reads shorter than "F_U32" bases are forced to be singleton.\n", minReadLen); _numLibraries = gkp->gkStore_getNumLibraries(); _numFragments = gkp->gkStore_getNumReads(); _fragLength = new uint32 [_numFragments + 1]; _mateIID = new uint32 [_numFragments + 1]; _libIID = new uint32 [_numFragments + 1]; _mean = new double [_numLibraries + 1]; _stddev = new double [_numLibraries + 1]; _numFragsInLib = new uint32 [_numLibraries + 1]; _numMatesInLib = new uint32 [_numLibraries + 1]; for (uint32 i=0; i<_numFragments + 1; i++) { _fragLength[i] = 0; _mateIID[i] = 0; _libIID[i] = 0; } for (uint32 i=1; i<_numLibraries + 1; i++) { _mean[i] = 0.0; _stddev[i] = 0.0; //_mean[i] = gkp->gkStore_getLibrary(i)->mean; //_stddev[i] = gkp->gkStore_getLibrary(i)->stddev; _numFragsInLib[i] = 0; _numMatesInLib[i] = 0; } uint32 numSkipped = 0; uint32 numLoaded = 0; for (uint32 fi=1; fi<=_numFragments; fi++) { gkRead *read = gkp->gkStore_getRead(fi); if (read->gkRead_sequenceLength() < minReadLen) { numSkipped++; } else { uint32 iid = read->gkRead_readID(); uint32 lib = read->gkRead_libraryID(); _fragLength[iid] = read->gkRead_sequenceLength(); _mateIID[iid] = 0; //read->gkRead_mateIID();; _libIID[iid] = lib; _numFragsInLib[lib]++; if (_mateIID[iid]) _numMatesInLib[lib]++; numLoaded++; } if (((numSkipped + numLoaded) % 10000000) == 0) writeLog("FragmentInfo()-- Loading fragment information: skipped:%9d active:%9d\n", numSkipped, numLoaded); } for (uint32 i=0; i<_numLibraries + 1; i++) _numMatesInLib[i] /= 2; // Search for and break (and complain) mates to deleted fragments. uint32 numBroken = 0; for (uint32 i=0; i<_numFragments + 1; i++) { if ((_fragLength[i] == 0) || (_mateIID[i] == 0) || (_fragLength[_mateIID[i]] > 0)) // This frag deleted, or this frag unmated, or mate of this frag is alive, all good! continue; assert(_mateIID[_mateIID[i]] == 0); if (numBroken++ < 100) writeLog("FragmentInfo()-- WARNING! Mate of fragment %d (fragment %d) is deleted.\n", i, _mateIID[i]); _mateIID[i] = 0; } if (numBroken > 0) writeLog("FragmentInfo()-- WARNING! Removed "F_U32" mate relationships.\n", numBroken); writeLog("FragmentInfo()-- Loaded %d alive reads, skipped %d short reads.\n", numLoaded, numSkipped); save(prefix); }
void Logger::debug(std::string msg) const{ if(_enabled) (_logFile == nullptr) ? printLog(DEBUG,msg) : writeLog(DEBUG,msg); }
void CGameAI::doStartGame() { int x = 0; int y = 0; RECT rect; DWORD pId = NULL; CString logStr; HWND ywtHWND = NULL; HWND crossGameHWND = NULL; //HWND ywtHWND = FindWindow(TEXT("#32770"), NULL); TRACE("game hwnd: %d\n", leader->getHWND()); if(leader->getHWND() != NULL) return; ywtHWND = FindWindow(NULL, TEXT("\u201c\u6613\u73a9\u901a\u201d\u5a31\u4e50\u5e73\u53f0")); if(ywtHWND != INVALID_HANDLE_VALUE) { TRACE("Doing start the game\n"); GetWindowThreadProcessId(ywtHWND, &pId); EnumWindows(EnumWindowCallBack, (LPARAM)&pId); ywtHWND = (HWND)pId; ShowWindow(ywtHWND, SW_SHOWNORMAL); Sleep(500); SetForegroundWindow(ywtHWND); Sleep(1000); CSystem::sendKey(VK_RETURN); Sleep(1000); if(script.x > 1 && script.x < 10) { for(int i = 1; i < script.x; ++i) { CSystem::sendKey(VK_DOWN); Sleep(1000); } } CSystem::sendKey(VK_RETURN); Sleep(4000); EnumWindows(FindCrossGateWindowsProc4Login, (LPARAM)&crossGameHWND); if(crossGameHWND) { isGameClosed = FALSE; leader->setHWND(crossGameHWND); SetForegroundWindow(ywtHWND); Sleep(500); rect.left = 140; rect.top = 140; rect.right = 170; rect.bottom = 154; while(leader->getScreen()->colorDeviation(&rect, RGB(99,36,33)) == 0) { leader->mapWindow->leftClickCenter(); Sleep(500); } rect.left = 136; rect.top = 172; rect.right = 166; rect.bottom = 186; fuckingMouse(); while(leader->getScreen()->colorDeviation(&rect, RGB(99,36,33)) == 0) { CSystem::leftClick(156, 148); Sleep(1000); } rect.left = 142; rect.top = 352; rect.right = 184; rect.bottom = 362; logStr.Format(TEXT("正在登录%d线"), script.y); writeLog(logStr); if(script.y < 1 || script.y > 10) script.y = 3; fuckingMouse(); while(leader->getScreen()->colorDeviation(&rect, RGB(255,255,255)) < 4) { if(script.y < 6) { x = 156; y = 116 + script.y*32; } else { x = 255; y = 116 + (script.y-5)*32; } CSystem::leftClick(x, y); Sleep(100); CSystem::leftClick(x, y); Sleep(100); CSystem::leftClick(x, y); Sleep(1000); } if(script.targetX != 2) CSystem::leftClick(162, 358); else CSystem::leftClick(480, 358); Sleep(8000); } } }