void CThreadQueue::run() { LOG(INFO) + "Starting main routine..."; int nLastPollInterval = getLastPollInterval(); while( !isStopping() ) { unsigned int nWait = m_nPollInterval > 0 ? m_nPollInterval : QUEUE_POLL_INTERVAL_INFINITE; if ( m_nPollInterval > 0 && nLastPollInterval > 0 ) { int nWait2 = m_nPollInterval - nLastPollInterval; if ( nWait2 <= 0 ) nWait = QUEUE_STARTUP_INTERVAL_SECONDS; else nWait = nWait2; } if ( nWait >= 0 && !isStopping() && isNoCommands() ) { LOG(INFO) + "ThreadQueue blocked for " + nWait + " seconds..."; if ( wait(nWait) == 1 ) onTimeout(); } nLastPollInterval = 0; if ( !isStopping() ) processCommands(); } LOG(INFO) + "Thread shutdown"; }
/*------------------------------------------------------------------------------ | OpenMAXILPlayerControl::onSceneGraphInitialized +-----------------------------------------------------------------------------*/ void OpenMAXILPlayerControl::onSceneGraphInitialized() { LOG_DEBUG(LOG_TAG, "Renderer thread is: 0x%x.", (unsigned int)QThread::currentThread()); m_sceneGraphInitialized = true; processCommands(); }
void CThreadQueue::run() { if(__rhoCurrentCategory.getName() == "NO_LOGGING") m_logThreadId = getThreadID(); LOG(INFO) + "Starting main routine..."; int nLastPollInterval = getLastPollInterval(); while( !isStopping() ) { unsigned int nWait = m_nPollInterval > 0 ? m_nPollInterval : QUEUE_POLL_INTERVAL_INFINITE; if ( m_nPollInterval > 0 && nLastPollInterval > 0 ) { int nWait2 = m_nPollInterval - nLastPollInterval; if ( nWait2 <= 0 ) nWait = QUEUE_STARTUP_INTERVAL_SECONDS; else nWait = nWait2; } if ( !m_bNoThreaded && !isStopping() && isNoCommands() ) { LOG(INFO) + "ThreadQueue blocked for " + nWait + " seconds..."; if ( wait(nWait*1000) == 1 ) onTimeout(); } nLastPollInterval = 0; if ( !m_bNoThreaded && !isStopping() ) processCommands(); } LOG(INFO) + "Thread shutdown"; }
void Report::setData(const QString& data) { if (data == data_) { return; } clear(); data_ = data; processCommands(); // Count the number of rows/cols if (rows_ == 0 || cols_ == 0) { const QSize size = Text::pageSize(data_); rows_ = size.height(); cols_ = size.width(); } // Load pictures if (!pictures_.isEmpty()) { DownloadPictures* download = new DownloadPictures(this); connect(download, SIGNAL(downloaded(QUrl,QPixmap)), this, SLOT(pictureDownloaded(QUrl,QPixmap))); connect(download, SIGNAL(finished()), this, SIGNAL(loaded())); connect(download, SIGNAL(finished()), download, SLOT(deleteLater())); foreach (const QUrl& url, pictures_.uniqueKeys()) { download->download(url); } }
int main(int argc, char *argv[]) { // We don't expect a command argument if (argc > 1) errExit("Usage: pell < inputFile"); processCommands(stdin); return 0; }
int main(void) { init(); while(1) { processCommands(); } }
void CThreadQueue::addQueueCommandToFront(IQueueCommand* pCmd) { addQueueCommandToFrontInt(pCmd); if ( isNoThreadedMode() ) processCommands(); else if ( isAlive() ) stopWait(); }
/** * Read in a character to be read by the command handler * A terminator character prompts the buffer to be processed */ void CommandHandler::readIn(char inChar) { if (inChar == _terminator){ // Check for the terminator (default '\r') meaning end of command processCommands(); } else{ writeCache(inChar); } }
void Game::Update(float delta) { if (mPause) return; if (start == 0) startTimer(); // Process any commands received from clients processCommands(); // Run physics update loop SimulationLoop(delta); }
void Editor_timedUpdate() { int processed_commands = 0; RemoteConnection_updateListner(getRowPos()); updateTrackStatus(); while (RemoteConnection_pollRead()) processed_commands |= processCommands(); if (!RemoteConnection_isPaused() || processed_commands) { Editor_update(); } }
bool QScriptDebuggerFrontendPrivate::event(QEvent *e) { Q_Q(QScriptDebuggerFrontend); if (e->type() == QEvent::User+1) { QScriptDebuggerEventEvent *de = static_cast<QScriptDebuggerEventEvent*>(e); bool handled = q->notifyEvent(de->event()); if (handled) { q->scheduleCommand(QScriptDebuggerCommand::resumeCommand(), /*responseHandler=*/0); } return true; } else if (e->type() == QEvent::User+2) { processCommands(); return true; } return false; }
/* ----------------------------------------------------------------------------*/ int main(int argc,char* argv[]) { int i; char directory[1024]; strcpy(soundCardName,"HPSDR"); strcpy(server_address,"127.0.0.1"); // localhost processCommands(argc,argv); fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION); setSoundcard(getSoundcardId(soundCardName)); // initialize DttSP if(getcwd(directory, sizeof(directory))==NULL) { fprintf(stderr,"current working directory path is > 1024 bytes!"); exit(1); } Setup_SDR(directory); Release_Update(); SetTRX(0,0); // thread 0 is for receive SetTRX(1,1); // thread 1 is for transmit SetRingBufferOffset(0,offset); SetThreadProcessingMode(0,2); SetThreadProcessingMode(1,2); SetSubRXSt(0,0,1); SetRXOutputGain(0,0,0.20); reset_for_buflen(0,1024); reset_for_buflen(1,1024); client_init(receiver); audio_stream_init(receiver); // initialize ozy ozy_init(); while(1) { sleep(10000); } return 0; }
int main(int arc, char **argv) { run = 1; int ret = 0; ret = init(); if(ret != 0) return ret; signal(SIGINT, &sighandler); ret = processCommands(); if(ret != 0) return ret; ps_free(psDecoder); return 0; }
int main() { char* linePointer = malloc(150); //A typical long line in the sample is 96 chars, 150 should be safe. struct annual_stats* allYearData = processData(linePointer); printf("\nRead Successful\n"); printf("\nProcessing Commands\n"); processCommands(linePointer, allYearData); for(int i = 0; i < numYears; i++) free(allYearData[i].teams); free(allYearData); free(linePointer); allYearData = NULL; linePointer = NULL; return 0; }
void sctpClient::run() { mSocket = new QTcpSocket(); if (!mSocket->setSocketDescriptor(mSocketDescriptor)) { qDebug() << "Can't process socket descriptor " << mSocketDescriptor; delete mSocket; return; } qDebug() << "Client connected: " << mSocket->peerAddress(); sctpStatistic::getInstance()->clientConnected(); mCommand = new sctpCommand(); mCommand->init(); while (mSocket->waitForReadyRead()) { processCommands(); } mCommand->shutdown(); if (mSocket->state() == QTcpSocket::ConnectedState) { mSocket->waitForBytesWritten(); mSocket->waitForDisconnected(); } mSocket->close(); delete mSocket; mSocket = 0; delete mCommand; mCommand = 0; //deleteLater(); // shedule destroy in main thread }
void Transport::eventIteration( int64_t &now) { IOEvent events[MAX_SOCKET_EVENTS]; int cnt = _socketEvent.getEvents(100, events, MAX_SOCKET_EVENTS); now = TimeUtil::getTime(); for (int i = 0; i < cnt; i++) { IOComponent *ioc = events[i]._ioc; assert(ioc); bool rc = true; if (events[i]._errorOccurred) { // 错误发生了 rc = ioc->handleErrorEvent(); } // 读写 if (rc && events[i]._readOccurred) { rc = ioc->handleReadEvent(); } if (rc && events[i]._writeOccurred) { rc = ioc->handleWriteEvent(); } ioc->updateUseTime(now); } processCommands(); }
/*------------------------------------------------------------------------------ | OpenMAXILPlayerControl::onBeforeRendering +-----------------------------------------------------------------------------*/ void OpenMAXILPlayerControl::onAfterRendering() { processCommands(); }
void CCEThread::run() { while(isLive()) { processCommands(-1); } }
int main(int argc,char* argv[]) { struct dspserver_config config; memset(&config, 0, sizeof(config)); // Register signal and signal handler signal(SIGINT, signal_shutdown); char directory[MAXPATHLEN]; strcpy(config.soundCardName,"HPSDR"); strcpy(config.server_address,"127.0.0.1"); // localhost strcpy(config.share_config_file, getenv("HOME")); strcat(config.share_config_file, "/dspserver.conf"); processCommands(argc,argv,&config); fprintf(stderr, "Reading conf file %s\n", config.share_config_file); init_register(config.share_config_file); // we now read our conf always // start web registration if set if (toShareOrNotToShare) { fprintf(stderr, "Activating Web register\n"); } fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION); printversion(); setSoundcard(getSoundcardId(config.soundCardName)); // initialize DttSP if(getcwd(directory, sizeof(directory))==NULL) { fprintf(stderr,"current working directory path is > MAXPATHLEN"); exit(1); } Setup_SDR(directory); Release_Update(); SetTRX(0,0); // thread 0 is for receive SetTRX(1,1); // thread 1 is for transmit SetRingBufferOffset(0,config.offset); SetThreadProcessingMode(0,RUN_PLAY); SetThreadProcessingMode(1,RUN_PLAY); SetSubRXSt(0,1,1); SetRXOutputGain(0,0,0.20); SetRXOsc(0,0, -LO_offset); SetRXOsc(0,1, -LO_offset); reset_for_buflen(0,1024); reset_for_buflen(1,1024); client_init(receiver); audio_stream_init(receiver); audio_stream_reset(); codec2 = codec2_create(); G711A_init(); ozy_init(config.server_address); SetMode(1, 0, USB); SetTXFilter(1, 150, 2850); SetTXOsc(1, LO_offset); SetTXAMCarrierLevel(1, 0.5); tx_init(); // starts the tx_thread while(1) { sleep(10000); } // codec2_destroy(codec2); return 0; }
int main(int argc,char* argv[]) { memset(&config, 0, sizeof(config)); // Register signal and signal handler signal(SIGINT, signal_shutdown); char directory[MAXPATHLEN]; strcpy(config.soundCardName,"HPSDR"); strcpy(config.server_address,"127.0.0.1"); // localhost strcpy(config.share_config_file, getenv("HOME")); strcat(config.share_config_file, "/dspserver.conf"); processCommands(argc,argv,&config); #ifdef THREAD_DEBUG sdr_threads_init(); #endif /* THREAD_DEBUG */ fprintf(stderr, "Reading conf file %s\n", config.share_config_file); init_register(config.share_config_file); // we now read our conf always // start web registration if set if (toShareOrNotToShare) { fprintf(stderr, "Activating Web register\n"); } fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION); printversion(); setSoundcard(getSoundcardId(config.soundCardName)); // initialize DttSP if(getcwd(directory, sizeof(directory))==NULL) { fprintf(stderr,"current working directory path is > MAXPATHLEN"); exit(1); } Setup_SDR(directory); Release_Update(); SetTRX(0,0); // thread 0 is for receive SetTRX(1,1); // thread 1 is for transmit SetRingBufferOffset(0,config.offset); SetThreadProcessingMode(0,RUN_PLAY); SetThreadProcessingMode(1,RUN_PLAY); SetSubRXSt(0,1,1); SetRXOutputGain(0,0,0.20); SetRXOsc(0,0, -LO_offset); SetRXOsc(0,1, -LO_offset); reset_for_buflen(0,1024); reset_for_buflen(1,1024); client_init(receiver); // create the main thread responsible for listen TCP socket // on the read callback: // accept and interpret the commands from remote GUI // parse mic data from remote and enque them into Mic_audio_stream queue // see client.c // // on the write callback: // read the audio_stream_queue and send into the TCP socket // audio_stream_init(receiver); audio_stream_reset(); codec2 = codec2_create(CODEC2_MODE_3200); G711A_init(); ozy_init(config.server_address); // create and starts iq_thread in ozy.c in order to // receive iq stream from hardware server // process it in DttSP // makes the sample rate adaption for resulting audio // puts audio stream in a queue (via calls to audio_stream_queue_add // in audio_stream_put_samples() in audiostream.c) // // in case of HPSDR hardware (that is provided with a local D/A converter // sends via ozy_send() the audio back to the hardware server SetMode(1, 0, USB); SetTXFilter(1, 150, 2850); SetTXOsc(1, LO_offset); SetTXAMCarrierLevel(1, 0.5); tx_init(); // create and starts the tx_thread (see client.c) // the tx_thread reads the Mic_audio_stream queue, makes the sample rate adaption // process the data into DttSP in order to get the modulation process done, // and sends back to the hardware server process (via ozy_send() ) #ifdef THREAD_DEBUG /* Note that some thread interactions will be lost at startup due to * the fact that the subsystem threads are all started. We can't * init this until late, though, or we'll catch initializations * performed at boot time as errors. */ if (config.thread_debug) { sdr_threads_debug(TRUE); } #endif /* THREAD_DEBUG */ while(1) { sleep(10000); } // codec2_destroy(codec2); return 0; }
/* ----------------------------------------------------------------------------*/ int main(int argc,char* argv[]) { gboolean retry; GtkWidget* dialog; gint result; int i; gtk_init(&argc,&argv); fprintf(stderr,"gHermes Version %s\n",VERSION); strcpy(propertyPath,"gHermes.properties"); // strcpy(soundCardName,"HPSDR"); ozy_set_interface("eth0"); processCommands(argc,argv); loadProperties(propertyPath); #ifdef ALEX_TEST alex_rx_test_load("alex_rx_test.csv"); alex_tx_test_load("alex_tx_test.csv"); #endif //init_cw(); // initialize DttSP Setup_SDR(); Release_Update(); SetTRX(0,FALSE); // thread 0 is for receive SetTRX(1,TRUE); // thread 1 is for transmit SetThreadProcessingMode(0,2); // set thread 0 to RUN SetThreadProcessingMode(1,2); // set thread 1 to RUN SetSubRXSt(0,0,TRUE); reset_for_buflen(0,buffer_size); reset_for_buflen(1,buffer_size); // initialize ozy (default 48K) //ozyRestoreState(); do { switch(ozy_init()) { case -1: // cannot find ozy dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "Cannot locate Ozy!\n\nIs it powered on and plugged in?"); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?"); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: retry=TRUE; break; default: exit(1); break; } gtk_widget_destroy (dialog); break; case -2: // found but needs initializing result=fork(); if(result==0) { // child process - exec initozy fprintf(stderr,"exec initozy\n"); result=execl("initozy",NULL,NULL); fprintf(stderr,"exec returned %d\n",result); exit(result); } else if(result>0) { // wait for the forked process to terminate dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, "Initializing Ozy"); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Please Wait ..."); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); gtk_widget_show_all (dialog); while (gtk_events_pending ()) gtk_main_iteration (); wait(&result); fprintf(stderr,"wait status=%d\n",result); retry=TRUE; } gtk_widget_destroy (dialog); break; case -3: // did not find metis dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "Cannot locate Metis on interface %s!", ozy_get_interface()); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?"); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: retry=TRUE; break; default: exit(1); break; } gtk_widget_destroy (dialog); break; default: retry=FALSE; break; } } while(retry); mainRootX=0; mainRootY=0; cwPitch =600; restoreInitialState(); //SetKeyerResetSize(4096); //NewKeyer(600.0f,TRUE,0.0f,3.0f,25.0f,48000.0f); //SetKeyerPerf(FALSE); //StartKeyer(); initColors(); //gtk_key_snooper_install((GtkKeySnoopFunc)keyboardSnooper,NULL); //bandscopeRestoreState(); //bandscopeWindow=buildBandscopeUI(); //bandscope_controlRestoreState(); //bandscope_controlWindow=buildBandscope_controlUI(); meterRestoreState(); meterWindow=buildMeterUI(); vfoRestoreState(); vfoWindow=buildVfoUI(); bandRestoreState(); bandWindow=buildBandUI(); modeRestoreState(); modeWindow=buildModeUI(); filterRestoreState(); filterWindow=buildFilterUI(); displayRestoreState(); displayWindow=buildDisplayUI(); audioRestoreState(); audioWindow=buildAudioUI(); agcRestoreState(); agcWindow=buildAgcUI(); preampWindow=buildPreampUI(); zoomWindow=buildZoomUI(); receiverRestoreState(); receiverWindow=buildReceiverUI(); volumeRestoreState(); volumeWindow=buildVolumeUI(); keyerRestoreState(); keyerWindow=buildKeyerUI(); cwPitch =(int)cw_sidetone_frequency; transmitRestoreState(); transmitWindow=buildTransmitUI(); mic_meterWindow=buildMic_MeterUI(); subrxRestoreState(); subrxWindow=buildSubRxUI(); restoreState(); // build the Main UI buildMainUI(); //setSoundcard(getSoundcardId(soundCardName)); audio_stream_init(); hamlibserv_init(); gtk_main(); return 0; }
static void uartCallback(uint8 port, uint8 event) { uint16 len; uint8 buf[8]; uint8 i; switch(event) { case HAL_UART_RX_FULL: case HAL_UART_RX_ABOUT_FULL: case HAL_UART_RX_TIMEOUT: #if (HAL_UART_ISR == 1) len = Hal_UART_RxBufLen(HAL_UART_PORT_0); HalUARTRead(HAL_UART_PORT_0, buf, len); #else len = Hal_UART_RxBufLen(HAL_UART_PORT_1); HalUARTRead(HAL_UART_PORT_1, buf, len); #endif /* Proposing states: - If 3 consequence @'s, ie. @@@ is sent, put device into command mode (0) - If 3 consequent $'s, ie. $$$ is sent, put device into translation mode (1) - In command mode, use U<value>, D<value>, M<value><value><value><value>, S<value>,<value> all followed by a line return - In translation mode, if the buffer is within ASCII printable, create reports with corresponding USB HID keycode and send to host (translate). Mouse data is sent with 0x03 <state> <x> <y> <z> */ for(i = 0; i < len; i++) { //Detects if a mode is being selected if((buf[i] == '@') || (buf[i] == '$')) { //not to waste time //printf("strIndex: %i\r\n",strIndex); modeSelStr[strIndex++] = buf[i]; if(strIndex == 3) { //printf("Testing for selection\r\n"); if((modeSelStr[0] == '@') && (modeSelStr[1] == '@') && (modeSelStr[2] == '@')) { //printf("CMD"); mode = 0; } else if((modeSelStr[0] == '$') && (modeSelStr[1] == '$') && (modeSelStr[2] == '$')) { //printf("TRANS"); mode = 1; } strIndex = 0; memset(modeSelStr, 0, 3); break; //stops filling buffer if a new mode is selected } } else { //printf("Gallifrey Falls No More\r\n"); memset(modeSelStr, 0, 3); strIndex = 0; } if(mode == COMMAND_MODE) { //command mode is selected if((buf[i] != 0x0D) && (buf[i] != 0x0A)) { rxBuffer[rxBufferIndex++] = buf[i]; } else { processCommands(); if(sleepModeEnabled) { sleepMode(); } break; } } else { sendKbdReportsWith(buf[i]); } } break; //break for case(HAL_UART_RX_TIMEOUT) } }