//timer回调 void infoLayer::timerFunc(float dt) { Sprite* moon =(Sprite*)this->getChildByTag(10); //下降 moon->runAction(MoveBy::create(0.1f, Point(0,-2))); //透明度 moon->setOpacity(moon->getOpacity()-0.01); //达到海平面 if (moon->getPositionY() <=(backGround2->getContentSize().height-moon->getContentSize().height)) { growth=1; UserDefault::getInstance()->setIntegerForKey("GROWTH", growth); //设置age UserDefault::getInstance()->setIntegerForKey("age", 10); timeOver(); unschedule(schedule_selector(infoLayer::timerFunc)); } }
void bufManagerByLFRU::blockReset( ){//D这里到时候要在配置文件中设的,我暂时在头文件里define了。 struct timeval tv; gettimeofday(&tv,NULL); list<LFRUBlockInfoo>::iterator it; pthread_mutex_lock(&buf_mutex); t0 = tv.tv_sec * 1000000 + tv.tv_usec; for(it = buf.begin();it!=buf.end();it++){ it->weight = 0.0; it->periodCounter = 1; it->lastAccessTime = t0; } timeOver(); pthread_mutex_unlock(&buf_mutex); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; //w.show(); splashScreen *screen=new splashScreen(QPixmap(":/img1/start.png"),Qt::WindowStaysOnTopHint); screen->setWindowOpacity(1); screen->setDisabled(true); screen->startTimer(); screen->setShowSecond(1); screen->showMessage(QObject::tr("加载模块......"),Qt::AlignLeft,Qt::yellow); //loadModules()加载模块函数 screen->showMessage(QObject::tr("建立连接......"),Qt::AlignRight|Qt::AlignBottom,Qt::yellow); //establishingConnections()建立连接函数 // Widget w; QObject::connect(screen,SIGNAL(timeOver()),&w,SLOT(show())); return a.exec(); }
int main(int argc,char **argv) { double acceptRate, RunCount, acceptCount; int ResampleCount, MeasureCount; int ranIniValue = 1; iniMPI(argc, argv); loadParameters(0,false); startTimer(); if (LogLevel>1) printf("Timer started. Passed time: %f\n",timePassed()); if (LogLevel>1) printf("Number of arguments = %d\n",argc); int I; for (I=0; I<argc; I++) { if (LogLevel>1) printf("Argument %d: %s\n",I+1,argv[I]); } int JobNr = -1; if (argc>=2) { if (sscanf(argv[1],"%d",&JobNr)!=1) JobNr = -1; } int MultiProcessNr = -1; if (argc>=3) { if (sscanf(argv[2],"%d",&MultiProcessNr)!=1) MultiProcessNr= -1; } if (JobNr>0) { ranIniValue = JobNr * (ownNodeID+1); if (LogLevel>1) printf("Use Job-Nr*(ownID+1) = %d*(%d+1) = %d for rand seed generation.\n",JobNr,ownNodeID, ranIniValue); } else { ranIniValue = 5517*(ownNodeID+1); if (LogLevel>1) printf("Start rand seed from system time only.\n"); JobNr = 1; } if (MultiProcessNr>0) { if (LogLevel>1) printf("Use multi-start number: %d for simulation parameter determination.\n",MultiProcessNr); } else { if (LogLevel>1) printf("Single Job-start.\n"); MultiProcessNr = 0; } if (LogLevel>0) printf("\n"); iniTools(ranIniValue); loadParameters(MultiProcessNr,true); buildOutputFileNameExtension(JobNr); fermiOps = new FermionMatrixOperations(Parameter_L0,Parameter_L1,Parameter_L2,Parameter_L3, Parameter_RHO, Parameter_R, Parameter_Y); HMCProp = new HMCPropagator(fermiOps, Parameter_Lambda, Parameter_Kappa, Parameter_Nf, 1.0); if (Parameter_FLAG_xFFT==1) { fermiOps->setxFFTusage(true); } else { fermiOps->setxFFTusage(false); } if (ownNodeID>0) { HMCProp->SlaveController(); if (LogLevel>1) printf("Hybrid Monte Carlo Slave finished!!! ==> EXITING !!!\n"); exit(0); } readCurrentStateDescriptor(); fermiOps->testFourierTrafo(true); if ((Parameter_AutomaticPreconditioningMetros>0) && (AutomaticPreconRunCount<Parameter_AutomaticPreconditioningMetros)) { double swapFrac = 0.25; if (LogLevel>1) printf("Performing %d Automatic Preconditioning Metroplis steps...\n",Parameter_AutomaticPreconditioningMetros-AutomaticPreconRunCount); if (AutomaticPreconRunCount==0) { fermiOps->setPreconditioner(true, 1, 0); } for (ResampleCount=0; true; ResampleCount++) { RunCount = 0; acceptCount = 0; for (MeasureCount=0; MeasureCount<Parameter_Measurements; MeasureCount++) { HMCProp->samplePhiMomentumField(); HMCProp->sampleOmegaFields(); if (propagateFields(Parameter_Iterations, Parameter_Epsilon, Parameter_PropTOL, Parameter_FinalTOL)) { if (AutomaticPreconRunCount<swapFrac*Parameter_AutomaticPreconditioningMetros) { HMCProp->improvePreconditioningParameters(10, 5, Parameter_PropTOL); } acceptCount++; AutomaticPreconRunCount++; writeCurrentStateDescriptor(1); } RunCount++; } if (AutomaticPreconRunCount>=swapFrac*Parameter_AutomaticPreconditioningMetros) { HMCProp->improvePreconditioningParameters(10*Parameter_Measurements, 10*Parameter_Measurements, Parameter_PropTOL); } acceptRate = acceptCount / RunCount; if (LogLevel>2) printf("Average (preconditioning) update quote: %1.2f\n",acceptRate); automaticAdaption(acceptRate); if (AutomaticPreconRunCount>Parameter_AutomaticPreconditioningMetros) break; if (timeOver()) { writeCurrentStateDescriptor(0); if (LogLevel>1) printf("Time limit reached. ==> EXITING!\n"); desini(); exit(0); } } double PrecM, PrecS; bool PrecUse; fermiOps->getPreconditionerParameter(PrecUse, PrecM, PrecS); if (LogLevel>1) printf("...Preconditioning ready. Best Preconditioning Parameters PrecM = %1.3f, PrecS = %1.3f\n", PrecM, PrecS); } if (ThermalizingRunCount<Parameter_ThermalizingMetros) { if (LogLevel>1) printf("Performing %d thermalizing Metroplis steps...\n",Parameter_ThermalizingMetros-ThermalizingRunCount); fermiOps->printPreconditionerParameter(); for (ResampleCount=0; true; ResampleCount++) { RunCount = 0; acceptCount = 0; for (MeasureCount=0; MeasureCount<Parameter_Measurements; MeasureCount++) { HMCProp->samplePhiMomentumField(); HMCProp->sampleOmegaFields(); if (propagateFields(Parameter_Iterations, Parameter_Epsilon, Parameter_PropTOL, Parameter_FinalTOL)) { acceptCount++; ThermalizingRunCount++; writeCurrentStateDescriptor(1); } RunCount++; } acceptRate = acceptCount / RunCount; if (LogLevel>2) printf("Average (thermalizing) update quote: %1.2f\n",acceptRate); automaticAdaption(acceptRate); if (ThermalizingRunCount>Parameter_ThermalizingMetros) break; if (timeOver()) { writeCurrentStateDescriptor(0); if (LogLevel>1) printf("Time limit reached. ==> EXITING!\n"); desini(); exit(0); } } if (LogLevel>1) printf("...Thermalizing ready.\n"); } if (TotallyMeasuredConfigurationsCount<Parameter_TotalData) { if (LogLevel>1) printf("Performing %d Measurements...\n",Parameter_TotalData-TotallyMeasuredConfigurationsCount); fermiOps->printPreconditionerParameter(); for (ResampleCount=0; true; ResampleCount++) { RunCount = 0; acceptCount = 0; for (MeasureCount=0; MeasureCount<Parameter_Measurements; MeasureCount++) { HMCProp->samplePhiMomentumField(); HMCProp->sampleOmegaFields(); if (propagateFields(Parameter_Iterations, Parameter_Epsilon, Parameter_PropTOL, Parameter_FinalTOL)) { if (Parameter_FLAG_WriteConditionNumber==1) { writeConditionNumber(); } measureAndWrite(); acceptCount++; TotallyMeasuredConfigurationsCount++; writeCurrentStateDescriptor(1); } else { if (LogLevel>1) printf("No measurement.\n"); } RunCount++; } acceptRate = acceptCount / RunCount; if (LogLevel>1) printf("-->Update quote: %1.2f\n\n",acceptRate); automaticAdaption(acceptRate); if (TotallyMeasuredConfigurationsCount>=Parameter_TotalData) break; if (timeOver()) { writeCurrentStateDescriptor(0); if (LogLevel>1) printf("Time limit reached. ==> EXITING!\n"); desini(); exit(0); } } } writeCurrentStateDescriptor(0); if (LogLevel>1) printf("Hybrid Monte Carlo ready. Collected %d data samples!!!\n", TotallyMeasuredConfigurationsCount); desini(); }
//触摸监控 bool infoLayer::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event) { k++; switch (k) { case 1: jiantou->setPosition(stars->starsVector.back()->getPosition()+Point(0,5)); infoLabel->setTexture("info2.png"); infoLabel->setPosition(jiantou->getPosition()+Point(0,70)); break; case 2: infoLabel->setPosition(size.width/2,size.height/2); infoLabel->setTexture("info3.png"); this->schedule(schedule_selector(infoLayer::timerFunc), 0.1f); break; case 3: this->removeChildByTag(1); this->removeChildByTag(2); break; default: break; } //触摸点位置 auto touchPoint=touch->getLocation(); if (stars->starsVector.empty()) { return false; } //判断触摸点是否在其他星星上 for (int i=0; i<stars->starsVector.size(); i++) { //触摸点在星星上且不在正确的星星上 if ((stars->starsVector.at(i)->getBoundingBox().containsPoint(touchPoint))&& stars->starsVector.at(i)!=stars->starsVector.back()) { //提示线 if (lineShow==false) { lineNum++; } if (lineNum>=3&&lineShow==false) { //提示线条 line=DrawNode::create(); line->drawLine(Point(215,95), (stars->starsVector.back())->getPosition(), Color4F::WHITE); this->addChild(line,2); lineNum=0; lineShow=true; } //错误提示效果 auto act1=ScaleTo::create(0.3, 2.5); auto act2=ScaleTo::create(0.3, 1.5); stars->starsVector.at(i)->runAction(Sequence::create(act1,act2, NULL)); } } //触摸指向的星星back() if ((stars->starsVector.back())->getBoundingBox().containsPoint(touchPoint)) { //若点击了星座 if (stars->starsVector.back()==stars->constellation) { //写入plist writToPlist(); conllGeted=true; //记录获取了的星座,以其序号为key switch (collensation) { case 1: //baiyang { //提示信息 //显示连线 stars->constellation->getChildByTag(1)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); stars->constellation->getChildByTag(2)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); stars->constellation->getChildByTag(3)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); break; } case 2: //jinniu { for (int i=1; i<=17; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; } case 3: //shuangzi for (int i=0; i<=15; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 4: //shuangyu for (int i=0; i<=18; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 5: //mojie for (int i=0; i<=10; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 6: //chunv for (int i=0; i<=13; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 7: //sheshou for (int i=0; i<=21; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 8: //shuiping for (int i=0; i<=14; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 9: //tianping for (int i=0; i<=7; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 10: //shizi for (int i=0; i<=10; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 11: //tianxie for (int i=0; i<=4; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; case 12: //juxie for (int i=0; i<=6; i++) { stars->constellation->getChildByTag(i)->runAction(Sequence::create(Show::create(),Blink::create(1.0f, 3), NULL)); } break; default: break; } auto collact1=DelayTime::create(2.0f); auto collact2=ScaleTo::create(2.0f, 1.5); // stars->starsVector.back()->runAction(Sequence::create(Spawn::create(collact1, collact2,NULL), RemoveSelf::create(),NULL)); } else { //若点在星星上,则移除此星星 //移除特效 auto act1=MoveTo::create(1.0f, Point(size.width/2,size.height/2)); auto act2=ScaleTo::create(1.0f, 3.0f); //爆炸效果 auto act3=ParticleExplosion::create(); act3->setPosition(Point::ZERO); act3->setLife(1.0f); act3->setScale(0.2f); (stars->starsVector.back())->addChild(act3); //EASESINEOUT:正弦加速 (stars->starsVector.back())->runAction(Sequence::create(EaseSineOut::create(Spawn::create(act1,act2, NULL)),RemoveSelf::create(), NULL)); } //清除提示线条 if (lineShow) { line->removeFromParent(); lineShow=false; } //得分 score++; //亲密值增加 Relation++; UserDefault::getInstance()->setIntegerForKey("RELATION", Relation); //弹出点击正确的星星 //stars->starsVector.pop_back(); stars->starsVector.popBack(); //错误计数清零 lineNum=0; pointer->setRotation(0); // 若空,则胜利 if (stars->starsVector.empty()) { //成长值++ growth=1; UserDefault::getInstance()->setIntegerForKey("GROWTH", growth); //设置age UserDefault::getInstance()->setIntegerForKey("age", 10); timeOver(); } else { pointToStar(); } } return false; }
NotifyManager::NotifyManager() { ui = new NotifyUI(); connect(ui, SIGNAL(signalTimeOver()), this, SLOT(timeOver())); }