void Bias::apply() { const unsigned noa=getNumberOfArguments(); const unsigned ncp=getNumberOfComponents(); if(onStep()) { double gstr = static_cast<double>(getStride()); for(unsigned i=0; i<noa; ++i) { getPntrToArgument(i)->addForce(gstr*outputForces[i]); } } // additional forces on the bias component std::vector<double> f(noa,0.0); std::vector<double> forces(noa); bool at_least_one_forced=false; for(unsigned i=0; i<ncp; ++i) { if(getPntrToComponent(i)->applyForce(forces)) { at_least_one_forced=true; for(unsigned j=0; j<noa; j++) f[j]+=forces[j]; } } if(at_least_one_forced && !onStep()) error("you are biasing a bias with an inconsistent STRIDE"); if(at_least_one_forced) for(unsigned i=0; i<noa; ++i) { getPntrToArgument(i)->addForce(f[i]); } }
void MS_Blueball_Decide::onNewBlobs() { LOG(LTRACE) << "MS_Blueball_Decide::onNewBlobs\n"; blobs = in_blobs.read(); onStep(); }
void ActionWithAveraging::update() { if( (clearstride!=1 && getStep()==0) || !onStep() ) return; // Clear if it is time to reset if( myaverage ) { if( myaverage->wasreset() ) clearAverage(); } // Calculate the weight for all reweighting if ( weights.size()>0 ) { double sum=0; for(unsigned i=0; i<weights.size(); ++i) sum+=weights[i]->get(); lweight=sum; cweight = exp( sum ); } else { lweight=0; cweight=1.0; } // Prepare to do the averaging prepareForAveraging(); // Run all the tasks (if required if( useRunAllTasks ) runAllTasks(); // This the averaging if it is not done using task list else performOperations( true ); // Update the norm if( myaverage ) myaverage->setNorm( cweight + myaverage->getNorm() ); // Finish the averaging finishAveraging(); // By resetting here we are ensuring that the grid will be cleared at the start of the next step if( myaverage ) { if( getStride()==0 || (clearstride>0 && getStep()%clearstride==0) ) myaverage->reset(); } }
void ExtractBlocks_Processor::onNewBlobs() { LOG(LTRACE) << "ExtractBlocks_Processor::onNewBlobs\n"; blobs_ready = true; blobs = in_blobs.read(); if (blobs_ready && hue_ready) onStep(); }
void MS_Barcode_Decide::onNewBlobs() { LOG(LTRACE) << "MS_Barcode_Decide::onNewBlobs\n"; blobs_ready = true; blobs = in_blobs.read(); //if (blobs_ready && hue_ready) onStep(); }
void ExtractBlocks_Processor::onNewImage() { LOG(LTRACE) << "ExtractBlocks_Processor::onNewImage\n"; hue_ready = true; hue_img = in_hue.read(); hue_img = hue_img.clone(); if (blobs_ready && hue_ready) onStep(); }
std::string TaskImpl::step(unsigned int arg) { qiLogDebug() << "Step " << this << ' ' << arg; std::stringstream result; result << _name << ' ' << _param << ' ' << arg << ' ' << ++_step; std::string v = result.str(); _lastResult = v; onStep(v); return v; }
void MS_Blueball_Decide::onNewImage() { LOG(LTRACE) << "MS_Blueball_Decide::onNewImage\n"; hue_ready = true; hue_img = in_hue.read(); hue_img = hue_img.clone(); if (blobs_ready && hue_ready) onStep(); }
static void doAction(LLDBPlugin* plugin, PDAction action) { switch (action) { case PDAction_Stop : onStop(plugin); break; case PDAction_Break : onBreak(plugin); break; case PDAction_Run : onRun(plugin); break; case PDAction_Step : onStep(plugin); break; case PDAction_StepOut : onStepOver(plugin); break; case PDAction_StepOver : onStepOver(plugin); break; } }
void KS_ROICrop::onNewDrawable(){ LOG(LTRACE) << "KS_ROICrop::onNewDrawable\n"; try{ container = in_container.read(); // std::cout << "Data read " << container.getSize() <<"\n" << std::endl; container_ready = true; if(img_ready && container_ready) onStep(); }catch(...){ LOG(LERROR) << "KS_ROICrop::onNewDrawable\n"; } }
void KS_ROICrop::onNewImage() { LOG(LTRACE) << "KS_ROICrop::onNewImage\n"; try { img = in_img.read(); img_ready = true; if(img_ready && container_ready) onStep(); } catch (...) { LOG(LERROR) << "KS_ROICrop::onNewImage failed\n"; } }
LifeControlsWidget::LifeControlsWidget(SimOptions *opts, SimController *ctrlr, LifeScrollWidget &scroll) : displayWidget(scroll) { options = opts; controller = ctrlr; delay = 100; play = false; QLabel *gridLabel = new QLabel("Grid Size:"); QLabel *delayLabel = new QLabel("Delay:"); genLabel = new QLabel("Generation:\t 1"); refreshGenLabel(); QSpinBox *gridSizeSpin = new QSpinBox(); gridSizeSpin->setMinimum(1); gridSizeSpin->setMaximum(1000); gridSizeSpin->setValue(opts->getBlockSize()); QSpinBox *delaySpin = new QSpinBox(); delaySpin->setMinimum(10); delaySpin->setMaximum(10000); delaySpin->setValue(delay); QPushButton *quitBtn = new QPushButton("Quit"); QPushButton *restartBtn = new QPushButton("Restart"); playBtn = new QPushButton("Play"); QPushButton *stepBtn = new QPushButton("Step"); QBoxLayout *box = new QBoxLayout(QBoxLayout::TopToBottom, this); box->addWidget(gridLabel); box->addWidget(gridSizeSpin); box->addWidget(delayLabel); box->addWidget(delaySpin); box->addWidget(genLabel); box->addWidget(quitBtn); box->addWidget(restartBtn); box->addWidget(playBtn); box->addWidget(stepBtn); box->addStretch(1); box->addSpacing(12); setLayout(box); connect(quitBtn, SIGNAL(clicked()), this, SLOT(onQuit())); connect(restartBtn, SIGNAL(clicked()), this, SLOT(onRestart())); connect(playBtn, SIGNAL(clicked()), this, SLOT(onPlay())); connect(stepBtn, SIGNAL(clicked()), this, SLOT(onStep())); connect(gridSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(onSizeChange(int))); connect(delaySpin, SIGNAL(valueChanged(int)), this, SLOT(onDelayChange(int))); }
static void doAction(DbgEngPlugin* plugin, PDAction action) { printf("DbgEngPlugin: doAction\n"); switch (action) { case PDAction_stop: onStop(plugin); break; case PDAction_break: onBreak(plugin); break; case PDAction_run: onRun(plugin); break; case PDAction_step: onStep(plugin); break; case PDAction_stepOut: onStepOut(plugin); break; case PDAction_stepOver: onStepOver(plugin); break; } }
DWORD WINAPI ThreadController::threadProc( void* argument ) { auto controller = (ThreadController*)argument; try { controller->onStart(); SetEvent( controller->mRunEvent ); while ( WaitForSingleObject( controller->mStopEvent, 0 ) != WAIT_OBJECT_0 ) { controller->onStep(); } controller->onStop(); } catch ( ... ) { controller->onStop(); return EXIT_FAILURE; } return EXIT_SUCCESS; }
void Bias::apply(){ if(onStep()) for(unsigned i=0;i<getNumberOfArguments();++i){ getPntrToArgument(i)->addForce(getStride()*outputForces[i]); } }
void CameraAnimation::onComplete(const tween::TweenerParam& param) { // Step to the final position onStep(param); endAnimation(); }
bool ApplicationManager::step() { float timeElapsed = getTimeElapsed(); m_globalTimeController->update(timeElapsed); switch(onStep()) { case APC_SYSTEM: return true; case APC_APPLICATION: break; case APC_EXIT: return false; } int numRunning = 0; int numActive = 0; for (AppsMap::iterator appIt = m_apps.begin(); appIt != m_apps.end(); ++appIt) { ApplicationNode& currNode = appIt->second; dispatchAppSignals(currNode); switch(currNode.state) { case AS_UNINITIALIZED: { // do nothing break; } case AS_BEING_HIBERNATED: { currNode.app.hibernate(); currNode.state = AS_HIBERNATED; break; } case AS_HIBERNATED: { break; } case AS_BEING_DEHIBERNATED: { currNode.app.dehibernate(); currNode.state = AS_RUNNING; break; } case AS_SCHEDULED: { currNode.app.initialize(); currNode.state = AS_RUNNING; break; } case AS_RUNNING: { currNode.app.update(timeElapsed); break; } case AS_FINISHED: { currNode.app.deinitialize(); currNode.state = AS_UNINITIALIZED; break; } } if (currNode.state == AS_RUNNING) { numRunning++; } if (currNode.state != AS_UNINITIALIZED) { numActive++; } if (numRunning > 1) { ASSERT_MSG( false, "Only one application can be running at a time"); } } return (numActive > 0); }