void AMListAction3::startImplementation() { // if this was called by the base class, we know that we are in the Starting state. // no actions? That's easy... if(subActionCount() == 0) { setStarted(); setSucceeded(); // done and done. return; } if(subActionMode() == Sequential) { setStarted(); internalDoNextAction(); } // parallel mode else { setStarted(); foreach(AMAction3* action, subActions_) { internalConnectAction(action); } foreach(AMAction3* action, subActions_) { action->start(); } }
void AMLoopAction3::startImplementation() { // done already with nothing to do. if(subActionCount() == 0 || loopCount() == 0) { setStarted(); setSucceeded(); return; } setStarted(); setStatusText(QString("Loop %1 of %2").arg(currentIteration_+1).arg(loopCount())); internalDoNextAction(); }
void AMDetectorInitializeAction::startImplementation(){ // If you still don't have a detector, check the exposed detectors one last time. if(!detector_) detector_ = AMBeamline::bl()->exposedDetectorByInfo(*(detectorInitializeInfo()->detectorInfo())); if(!detector_) { AMErrorMon::alert(this, AMDETECTORINITIALIZEACTION_NO_VALID_DETECTOR, QString("There was an error initializing the detector '%1', because the detector was not found. Please report this problem to the Acquaman developers.").arg(detectorInitializeInfo()->name())); setFailed(); return; } if(detector_->initializationState() == AMDetector::InitializationRequired){ // connect to detector initialization signals connect(detector_, SIGNAL(initializing()), this, SLOT(onInitializeStarted())); connect(detector_, SIGNAL(initialized()), this, SLOT(onInitializeFinished())); detector_->initialize(); } else{ setStarted(); setSucceeded(); } }
BaseThread::BaseThread() : Thread(), mutexRunning(new Mutex(CODE_AT_LINE)), mutexQuit(new Mutex(CODE_AT_LINE)), mutexBeginExecution(new Mutex(CODE_AT_LINE)), mutexDeleteSelfOnExecutionDone(new Mutex(CODE_AT_LINE)), mutexThreadObjectAccessor(new Mutex(CODE_AT_LINE)), mutexThreadOwnerValid(new Mutex(CODE_AT_LINE)), mutexExecutingTask(new Mutex(CODE_AT_LINE)), mutexStarted(new Mutex(CODE_AT_LINE)), ptr(NULL), genericData(NULL) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ptr = this; MutexSafeWrapper safeMutexMasterList(&mutexMasterThreadList); masterThreadList[ptr]++; safeMutexMasterList.ReleaseLock(); uniqueID = "base_thread"; setQuitStatus(false); setRunningStatus(false); setStarted(false); setHasBeginExecution(false); setExecutingTask(false); setDeleteSelfOnExecutionDone(false); setThreadOwnerValid(true); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); }
void AMChangeToleranceAction::startImplementation() { const AMControlInfo &controlInfo = changeToleranceControlInfo()->controlInfo(); // If you still don't have a control, check the exposed controls one last time. if (!control_) control_ = AMBeamline::bl()->exposedControlByInfo(controlInfo); // Must have a control, and it must be able to move. if(!control_) { AMErrorMon::alert(this, AMCHANGETOLERANCEACTION_INVALID_CONTROL, QString("There was an error setting the tolerance for the control '%1' into position, because the control was not found. Please report this problem to the Acquaman developers.").arg(controlInfo.name())); setFailed(); return; } if (controlInfo.tolerance() <= 0.0){ AMErrorMon::alert(this, AMCHANGETOLERANCEACTION_INVALID_NEW_TOLERANCE, QString("There was an error setting the tolerance for control '%1' because the new tolerance was negative (%2). Please contact Acquaman developpers.") .arg(controlInfo.name()) .arg(controlInfo.tolerance(), 0, 'g' , 3)); setFailed(); return; } setStarted(); control_->setTolerance(changeToleranceControlInfo()->tolerance()); setSucceeded(); }
void AMDetectorCleanupAction::startImplementation(){ // If you still don't have a detector, check the exposed detectors one last time. if(!detector_) detector_ = AMBeamline::bl()->exposedDetectorByInfo(*(detectorCleanupInfo()->detectorInfo())); if(!detector_) { AMErrorMon::alert(this, AMDETECTORCLEANUPACTION_NO_VALID_DETECTOR, QString("There was an error cleaning up the detector '%1', because the detector was not found. Please report this problem to the Acquaman developers.").arg(detectorCleanupInfo()->name())); setFailed(); return; } if(detector_->cleanupState() == AMDetector::CleanupRequired){ // connect to detector cleanup signals connect(detector_, SIGNAL(cleaningUp()), this, SLOT(onCleanupStarted())); connect(detector_, SIGNAL(cleanedUp()), this, SLOT(onCleanupFinished())); detector_->cleanup(); } else{ setStarted(); setSucceeded(); } }
int DTDMAClass::start() { setStarted(true); TaskList *tl_ptr; TaskNode *ptr; while(true){ tl_ptr = tl_head; while(tl_ptr != NULL) { ptr = tl_ptr->curr; ptr->count++; if(ptr->count == ptr->delay) { ptr->task(); ptr->count = 0; if(ptr->next != NULL) tl_ptr->curr = ptr->next; else tl_ptr->curr = tl_ptr->head; } tl_ptr = tl_ptr->next; _delay_ms(1); } } }
void Insteon::run() { setStarted(); while (!stopping()) { // Make sure every devices are idle before atempting to send another command bool devicesIdle = true; for (std::map<InsteonID,InsteonDevice*>::iterator it = mModules.begin();it!=mModules.end();it++) { time_t t; time(&t); it->second->onTimer(t); if (!it->second->isIdle()) { devicesIdle = false; break; } } if (mpInsteonModem->process(devicesIdle)) { // dont sleep more than 50ms because Insteon modem expects reponses within 85ms usleep(50000); } } }
void AMControlWaitAction::startImplementation() { const AMControlInfo& setpoint = controlWaitInfo()->controlInfo(); // If you still don't have a control, check the exposed controls one last time. if (!control_) control_ = AMBeamline::bl()->exposedControlByInfo(controlWaitInfo()->controlInfo()); // Must have a control, and it must be able to move. if(!control_) { AMErrorMon::alert(this, AMCONTROLWAITACTION_INVALIDCONTROL, QString("There was an error waiting for the control '%1' into position, because the control was not found. Please report this problem to the Acquaman developers.").arg(setpoint.name())); setFailed(); return; } // check that the destination is in range... if( (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchEqual && control_->valueOutOfRange(setpoint.value())) || (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchGreaterThan && control_->maximumValue() < setpoint.value()) || (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchLessThan && control_->minimumValue() > setpoint.value()) ) { AMErrorMon::alert(this, AMCONTROLWAITACTION_WAITVALUEOUTOFRANGE, QString("There was an error waiting for the control '%1' into position, because the destination %2 %3 was outside its range with MatchType %4. Please report this problem to the beamline staff.") .arg(control_->name()) .arg(setpoint.value()) .arg(setpoint.units()) .arg(controlWaitInfo()->matchType())); setFailed(); return; } if (checkCurrentControlValue()) { setStarted(); setSucceeded(); return; } timeoutTimer_.setInterval(controlWaitInfo()->timeout()*1000); timeoutTimer_.start(); connect( control_, SIGNAL(valueChanged(double)), this, SLOT(onControlValueChanged(double)) ); connect( &timeoutTimer_, SIGNAL(timeout()), this, SLOT(onTimeoutTimerTimedOut()) ); setStarted(); }
void AMDetectorTriggerAction::onAcquisitionStarted(){ if(triggerSource_) disconnect(triggerSource_, SIGNAL(triggered(AMDetectorDefinitions::ReadMode)), this, SLOT(onAcquisitionStarted())); else disconnect(detector_, SIGNAL(acquiring()), this, SLOT(onAcquisitionStarted())); setStarted(); }
void sim::Init() { sta::Init(); gm::Init(); setStarted(false); setPaused(false); }
void AMWaitAction::startImplementation() { connect(&waitTimer_, SIGNAL(timeout()), this, SLOT(onWaitTimerTimeout())); connect(&progressTimer_, SIGNAL(timeout()), this, SLOT(onProgressTimerTimeout())); waitTimer_.start(waitActionInfo()->waitTime()*1000); waitTime_.start(); progressTimer_.start(1000); setStarted(); }
//组长转发服务器文件的线程 void FileServerThread::run() { SOCKET serverSocket = socket(AF_INET, SOCK_STREAM, 0); if(serverSocket == INVALID_SOCKET) { qDebug()<<"Start file server thread error"; return; } SOCKADDR_IN dataServerAddress; dataServerAddress.sin_family = AF_INET; dataServerAddress.sin_addr.s_addr = htonl(INADDR_ANY); dataServerAddress.sin_port = htons(0); //让内核随机选择一个可用的端口号 if(bind(serverSocket, (SA*)&dataServerAddress, sizeof(dataServerAddress)) == SOCKET_ERROR) { qDebug()<<"Start file server thread error"; return; } int addressLength = sizeof(dataServerAddress); if(getsockname(serverSocket, (SA*)&dataServerAddress, &addressLength) == SOCKET_ERROR) { qDebug()<<"Get data server socket port error"; return; } g_GroupFileServerPort = ntohs(dataServerAddress.sin_port); //转回主机字节序并保存在全局变量当中 qDebug()<<"Group file server port:"<<g_GroupFileServerPort; if(listen(serverSocket, SOMAXCONN) == SOCKET_ERROR) { qDebug()<<"Start file server thread error"; return; } setStarted(); while(true) { SOCKET clientSocket; SOCKADDR_IN clientAddress; int clientAddressSize = sizeof(clientAddress); clientSocket = accept(serverSocket, (SA*)&clientAddress, &clientAddressSize); if(clientSocket == INVALID_SOCKET) { qDebug()<<"Start file server thread error"; continue; } //如果检测到有组员连接自己 则为他建立一个通道 FileChannel* fileChannel = new FileChannel(clientSocket); fileChannel->start(); } }
// when API-information is loaded, values are extracted void TvShow::onShowInfoFilled() { setTitle(info->showInfo->value("Show Name")); setStarted(info->showInfo->value("Started")); setStatus(info->showInfo->value("Status")); setAirtime(info->showInfo->value("Airtime")); setNetwork(info->showInfo->value("Network")); setGenre(info->showInfo->value("Genres")); setLatestEpisode(info->showInfo->value("Latest Episode")); setNextEpisode(info->showInfo->value("Next Episode")); setImageUrl(info->showInfo->value("Image Url")); // All data is loaded, now show can be added to QList emit allDataLoaded(this); }
void AMDetectorSetDarkCurrentValidStateAction::startImplementation() { if (!detector_) setDetector(0); if (detector_) { setStarted(); detector_->setDarkCurrentValidState( detectorSetDarkCurrentValidStateActionInfo()->darkCurrentState() ); setSucceeded(); } else { AMErrorMon::alert(this, AMDETECTORSETDARKCURRENTVALIDSTATEACTION_DETECTOR_NOT_FOUND, "Failed to set dark current valid state--detector not found."); setFailed(); } }
void MenuPainter::openSelected() { int rc = -1, i; for (i = 0, rc = -1; rc < selected; i++) if (menabled[i]) rc++; if (mentries[i - 1] == "New game") { setStarted(true); owner->restartTetris(); } else if (mentries[i - 1] == "Resume") owner->openTetris(); else if (mentries[i - 1] == "Exit") exit(0); repaint(); }
bool REIXSXESScanController::startImplementation() { if(!config_->doNotClearExistingCounts()) { REIXSBeamline::bl()->mcpDetector()->clear(); } connect(REIXSBeamline::bl()->mcpDetector(), SIGNAL(imageDataChanged()), this, SLOT(onNewImageValues())); connect(&scanProgressTimer_, SIGNAL(timeout()), this, SLOT(onScanProgressCheck())); startTime_ = QDateTime::currentDateTime(); scanProgressTimer_.start(1000); setStarted(); return true; }
void sim::Stop() { if (!isStarted()) { return; } //Generators are stopped gm::stopAll(); sta::Stop(); setStarted(false); cout << "PetriNet timeVal: " << sta::getTotalTime() << endl; cout << "PetriNet averageTPS " << sta::getAverageTPS() << endl; //test }
void AMDetectorAcquisitionAction::onAcquisitionStarted(){ disconnect(detector_, SIGNAL(acquiring()), this, SLOT(onAcquisitionStarted())); setStarted(); /* if(acquisitionStartSuccessful) setStarted(); else{ AMErrorMon::alert(this, AMDETECTORACQUISITIONACTION_ACQUISITION_START_FAILED, QString("There was an error acquiring with the detector '%1', because the acquisition failed to start. Please report this problem to the Acquaman developers.").arg(detectorAcquisitionInfo()->name())); setFailed(); return; } */ }
void sim::Start() { setStarted(true); sta::Start(); //Generators are started gm::resumeAll(); pthread_t* thread = new pthread_t; ThreadParameters* par = new ThreadParameters(); pthread_create(thread, NULL, simulate, (void*) par); }
void AMScanAction::onControllerInitialized() { if (state() == AMAction3::Skipping){ disconnect(controller_, SIGNAL(cancelled()), this, SLOT(onControllerCancelled())); connect(controller_, SIGNAL(cancelled()), this, SLOT(onControllerSucceeded())); controller_->cancel(); } else if (!controller_->start()){ AMErrorMon::alert(this, AMSCANACTION_CANT_START_CONTROLLER, "Could not start the scan controller."); setFailed(); } else { setStarted(); } }
void CanvasGLUT::onRealize() { // Register callbacks glutDisplayFunc(&display); glutMouseFunc(&mouse); glutKeyboardFunc(&keyboard); glutSpecialFunc(&special); glutMotionFunc(&motion); // Load extensions Extensions::load(); // Set up glEnable(GL_DEPTH_TEST); glViewport(0, 0, getWidth(), getHeight()); fireEvent(CanvasEvent::INIT); // Start setStarted(true); }
/*! \fn FutureProgress::FutureProgress(QWidget *parent) \internal */ FutureProgress::FutureProgress(QWidget *parent) : QWidget(parent), d(new FutureProgressPrivate(this)) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); layout->addWidget(d->m_progress); layout->setMargin(0); layout->setSpacing(0); layout->addLayout(d->m_widgetLayout); d->m_widgetLayout->setContentsMargins(7, 0, 7, 2); d->m_widgetLayout->setSpacing(0); connect(&d->m_watcher, SIGNAL(started()), this, SLOT(setStarted())); connect(&d->m_watcher, SIGNAL(finished()), this, SLOT(setFinished())); connect(&d->m_watcher, SIGNAL(canceled()), this, SIGNAL(canceled())); connect(&d->m_watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(setProgressRange(int,int))); connect(&d->m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int))); connect(&d->m_watcher, SIGNAL(progressTextChanged(QString)), this, SLOT(setProgressText(QString))); connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel())); }
void CLSSIS3820ScalerDarkCurrentMeasurementAction::onStarted() { // Set the action as started. setStarted(); }
void AMDetectorCleanupAction::onCleanupStarted(){ disconnect(detector_, SIGNAL(cleaningUp()), this, SLOT(onCleanupStarted())); setStarted(); }
void SMTPModule::run() { mServerSocket = socket(AF_INET,SOCK_STREAM,0); sockaddr_in sockadd; sockadd.sin_family=AF_INET; sockadd.sin_addr.s_addr=INADDR_ANY; sockadd.sin_port=htons(this->mBindPort); char r = 1; setsockopt(mServerSocket,SOL_SOCKET,SO_REUSEADDR,&r,sizeof(r)); if (bind(mServerSocket,(struct sockaddr *)&sockadd,sizeof(sockadd))<0){ LOG("Could not bind SMTP server socket"); return; } listen(mServerSocket,1); char *buf = new char[BUF_SIZE+1]; setStarted(); while (!stopping()) { int clientSocket = accept(mServerSocket,0,0); if (clientSocket <0) { break; } LOG("New SMTP client connection"); send(clientSocket,"220\r\n",5,0); int size=0; bool finished = false; bool receivingData = false; char data[10000]; int n=0; while (!finished) { //TODO: right now we assume that this is comming from alarm system. We should check the From address to make sure of this size=read(clientSocket,buf,BUF_SIZE); // LOG("SMTP: Got %i bytes",size); if (size>0) { if (!strncmp(buf,"QUIT",4)){ send(clientSocket,"221\r\n",5,0); finished = true; } else if (!strncmp(buf,"DATA",4)){ send(clientSocket,"354 start message\r\n",19,0); LOG("SMTP: Getting data"); receivingData = true; } else { if (receivingData){ buf[size]=0; if (size>=5) { strcpy((char*)&data[n],buf); n+=size; if (buf[size-1]=='\n' && buf[size-2]=='\r' && buf[size-3]=='.' && buf[size-4]=='\n' && buf[size-5]=='\r') { send(clientSocket,"250 OK\r\n",8,0); } } else if (size==3) { // TODO: This could be the end of data if (buf[size-1]=='\n' && buf[size-2]=='\r' && buf[size-3]=='.') { send(clientSocket,"250 OK\r\n",8,0); } } } else { send(clientSocket,"250 OK\r\n",8,0); } } } else { finished = true; } } data[n]=0; LOG("Closing SMTP client connection"); close(clientSocket); AlarmState as; Dumais::JSON::JSON json; as.onEmail(json,(char*)&data); mpEventProcessor->processEvent(json); } delete buf; if (mServerSocket) close(mServerSocket); }
void AMSamplePlatePre2013MoveAction::onMoveListStarted(){ setStarted(); }
void AMDetectorInitializeAction::onInitializeStarted(){ disconnect(detector_, SIGNAL(initializing()), this, SLOT(onInitializeStarted())); setStarted(); }
void VESPERSBeamlineSetStringAction::start() { setStarted(true); connect(pv_, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); VESPERS::stringToPV(pv_, string_); }