Beispiel #1
0
void
workerService_t::processRequests(void)
{
	
	if (false == m_http->start()) {
		m_log->error("workerService_t::processRequests(): Error while calling http::worker_t::start()", eventlog_cat_t::CAT_WORKER, false);
		m_http->stop();
		onStop();
		return;
	}

	while (QSERVICE_RUNNING == getState()) {
		try {
			if (false == m_http->inputQueueIsEmpty()) { 
				http::req_sptr_t			req(m_http->getRequestFromInputQueue());
				http::resp_sptr_t			resp(http::resp_sptr_t(new http::resp_t(*m_log)));

				if (nullptr == req) {
					m_log->error("workerService_t::processRequests(): Error while calling low_level_http_t::getRequestFromInputQueue()", eventlog_cat_t::CAT_WORKER, false);
					m_http->stop();
					onStop();
					return;	
				}

				resp->setId(req->getId());

				if (false == m_handlers->executeHandlers(http::req_wptr_t(req), http::resp_wptr_t(resp))) {
					m_log->error("workerService_t::processRequests(): Error while calling http::handler_mgr_t::executeHandlers()", eventlog_cat_t::CAT_WORKER, false);
					req = nullptr;
					resp = nullptr;
					continue;
				}

				resp->addHeader(QString("Server"), QString("WINHTTPD v0.1"));
				resp->addHeader(QString("X-Unknown-Header-Type"), QString("UnknownHeaderTypeValue"));

				m_http->putResponseOnOutputQueue(resp);
				resp	= nullptr; 
				req		= nullptr;

			} else 
				QThread::msleep(250);

		} catch (std::runtime_error& e) {
				QString err("workerService_t::processRequests() Error: ");

				err += e.what();
				m_log->error(err, eventlog_cat_t::CAT_WORKER, false);

		} catch (...) {
			m_log->error("workerService_t::processRequests(): unknown exception caught");
		}
	}

	m_http->stop();
	return;
}
Beispiel #2
0
int CwxAppFramework::run()
{
    if (this->initRunEnv() == -1)
    {
        this->destroy();
		pid_t pid=getppid();
		if (1 != pid){
			kill(pid, SIGQUIT);
		}
        return -1;
    }
    if (this->reactor())
    {
        m_bStopped = false;
        pid_t  pid=getpid();
        this->reactor()->run(CwxAppFramework::hook, this, false);
        if (pid != ::getpid())
        {//it's child
           return 0;
        }
        onStop();
    }
    this->destroy();
    return 0;
}
void Stoppable::stopAsyncRecursive ()
{
    onStop ();
    for (Children::const_iterator iter (m_children.cbegin ());
        iter != m_children.cend(); ++iter)
        iter->stoppable->stopAsyncRecursive ();
}
void SimpleQt::createActions()
{
    m_playAct = new QAction(QIcon(":/SimpleQt/Resources/media_play.ico"), tr("&Play"), this);
    m_playAct->setStatusTip(tr("Turn on image streaming"));
    m_playAct->setCheckable(true);
    connect(m_playAct, SIGNAL(triggered()), this, SLOT(onPlay()));

    m_stopAct = new QAction(QIcon(":/SimpleQt/Resources/media_stop.ico"), tr("&Stop"), this);
    m_stopAct->setStatusTip(tr("Turn off image streaming"));
    m_stopAct->setCheckable(true);
    connect(m_stopAct, SIGNAL(triggered()), this, SLOT(onStop()));

    m_exitAct = new QAction(QIcon(":/SimpleQt/Resources/exit.ico"), tr("E&xit"), this);
    m_exitAct->setShortcuts(QKeySequence::Quit);
    m_exitAct->setStatusTip(tr("Exit the application"));
    connect(m_exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));

    m_viewToolbarAct = new QAction(tr("Toolbar"), this);
    m_viewToolbarAct->setStatusTip(tr("Show or hide the toolbar"));
    m_viewToolbarAct->setCheckable(true);
    m_viewToolbarAct->setChecked(true);
    connect(m_viewToolbarAct, SIGNAL(triggered()), this, SLOT(toggleToolbar()));

    m_viewCtrlbarAct = new QAction(QIcon(":/SimpleQt/Resources/gear.ico"), tr("Control Bar"), this);
    m_viewCtrlbarAct->setStatusTip(tr("Show or hide the register control bar"));
    m_viewCtrlbarAct->setCheckable(true);
    m_viewCtrlbarAct->setChecked(true);
    connect(m_viewCtrlbarAct, SIGNAL(triggered()), this, SLOT(toggleCtrlbar()));

    m_aboutAct = new QAction(QIcon(":/SimpleQt/Resources/about.ico"), tr("&About"), this);
    m_aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
Beispiel #5
0
bool SoundRecorder::setDevice(const std::string& name)
{
    // Store the device name
    if (name.empty())
        m_deviceName = getDefaultDevice();
    else
        m_deviceName = name;

    if (m_isCapturing)
    {
        // Stop the capturing thread
        m_isCapturing = false;
        m_thread.wait();

        // Open the requested capture device for capturing 16 bits mono samples
        captureDevice = alcCaptureOpenDevice(name.c_str(), m_sampleRate, AL_FORMAT_MONO16, m_sampleRate);
        if (!captureDevice)
        {
            // Notify derived class
            onStop();

            err() << "Failed to open the audio capture device with the name: " << m_deviceName << std::endl;
            return false;
        }

        // Start the capture
        alcCaptureStart(captureDevice);

        // Start the capture in a new thread, to avoid blocking the main thread
        m_isCapturing = true;
        m_thread.launch();
    }

    return true;
}
/*! \brief Create the context menu for the modules tree. */
void ApplicationViewWidget::createModulesViewContextMenu()
{
    modRunAction = new QAction("Run",this);
    modStopAction = new QAction("Stop",this);
    modkillAction = new QAction("Kill",this);
    modSeparator = new QAction(this);
    modSeparator->setSeparator(true);
    modRefreshAction = new QAction("Refresh Status",this);
    modSelectAllAction = new QAction("Select All Modules",this);
    modAttachAction = new QAction("Attach to stdout",this);
    modAssignAction = new QAction("Assign Hosts",this);

    modRunAction->setIcon(QIcon(":/images/run_ico.png"));
    modStopAction->setIcon(QIcon(":/images/stop_ico.png"));
    modkillAction->setIcon(QIcon(":/images/kill_ico.png"));
    modRefreshAction->setIcon(QIcon(":/images/progress_ico.png"));
    modSelectAllAction->setIcon(QIcon(":/images/selectall_ico.png"));
    modAssignAction->setIcon(QIcon(":/images/yesres_ico.png"));


    ui->moduleList->addAction(modRunAction);
    ui->moduleList->addAction(modStopAction);
    ui->moduleList->addAction(modkillAction);
    ui->moduleList->addAction(modSeparator);
    ui->moduleList->addAction(modRefreshAction);
    ui->moduleList->addAction(modSelectAllAction);
    ui->moduleList->addAction(modAttachAction);
    ui->moduleList->addAction(modAssignAction);

    connect(modRunAction,SIGNAL(triggered()),this,SLOT(onRun()));
    connect(modStopAction,SIGNAL(triggered()),this,SLOT(onStop()));
    connect(modkillAction,SIGNAL(triggered()),this,SLOT(onKill()));
    connect(modRefreshAction,SIGNAL(triggered()),this,SLOT(onRefresh()));
    connect(modSelectAllAction,SIGNAL(triggered()),this,SLOT(selectAllModule()));
}
Beispiel #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), _ui(new Ui::MainWindow), _nextScene(QString::null)
{
    _ui->setupUi(this);

    Camera* camera = new Camera;
    camera->set(config->defaultCameraVerticalFOV(), config->defaultCameraAspectRatio());
    camera->setAperture(config->defaultCameraAperture());
    camera->setFocalPlane(config->defaultCameraFocusPlane());

    _ui->renderer->setCamera(camera);
    _setConfig();
    _ui->sceneNames->addItems(sceneGenerator->scenes());
    _ui->sceneNames->setCurrentIndex(0);
    logger->setConsole(_ui->console);
    logger->setStatusBar(_ui->statusBar);

    onLoadScene();

    connect(_ui->action_Save, SIGNAL(triggered()), SLOT(onSaveImage()));
    connect(_ui->action_Play_Pause, SIGNAL(triggered()), SLOT(onPlayPause()));
    connect(_ui->action_Stop, SIGNAL(triggered()), SLOT(onStop()));
    connect(_ui->action_Reload, SIGNAL(triggered()), SLOT(onLoadScene()));

    connect(_ui->sceneNames, SIGNAL(currentIndexChanged(QString)), SLOT(onLoadScene()));
    connect(_ui->integrator, SIGNAL(currentTextChanged(QString)), SLOT(onIntegratorChanged()));

    connect(_ui->renderer, SIGNAL(renderingFinished()), SLOT(onRenderingFinished()));
    connect(_ui->renderer, SIGNAL(renderingStarted()), SLOT(onRenderingStarted()));
    connect(_ui->renderer, SIGNAL(clicked(Intersection)), SLOT(onClick(Intersection)));

    QTimer* progressTimer = new QTimer(this);
    connect(progressTimer, SIGNAL(timeout()), SLOT(onUpdateProgress()));
    progressTimer->start(35);
}
Beispiel #8
0
fileList::fileList(QWidget *parent) : QWidget(parent)
{
	ui.setupUi(this);

	pReader = new WavReader;
	pIqReader = new WavReader;
	pIqWriter = new WavWriter;

	connect(pIqReader, SIGNAL(isStart(bool)), this, SLOT(onStart(bool)));

	ui.twList->horizontalHeader()->setStretchLastSection(true);
	ui.twList->setSelectionMode(QAbstractItemView::SingleSelection);
	connect(ui.twList, SIGNAL(cellDoubleClicked (int, int)), this, SLOT(onTwDoubleClick(int, int)));
	lastRow = 1;
	loopMode = 0;
	isPlayed = false;
	isRecorded = false;
	isPause = false;

	connect(ui.pbAddFile, SIGNAL(clicked()), this, SLOT(onAddFile()));
	connect(ui.pbDelFile, SIGNAL(clicked()), this, SLOT(onDelFile()));
	connect(ui.pbRec, SIGNAL(clicked()), this, SLOT(onRec()));
	connect(ui.pbPlay, SIGNAL(clicked()), this, SLOT(onPlay()));
	connect(ui.pbPause, SIGNAL(clicked()), this, SLOT(onPause()));
	connect(ui.pbStop, SIGNAL(clicked()), this, SLOT(onStop()));
	connect(ui.pbBack, SIGNAL(clicked()), this, SLOT(onBack()));
	connect(ui.pbLoop, SIGNAL(clicked(bool)), this, SLOT(onLoop(bool)));

	ui.pbPause->setEnabled(false);
}
Beispiel #9
0
void
processEvents(void) {
	while (XPending(x_dpy)) {
		XEvent ev;
		XNextEvent(x_dpy, &ev);
		switch (ev.type) {
		case ButtonPress:
			onTouchBegin((float)ev.xbutton.x, (float)ev.xbutton.y);
			break;
		case ButtonRelease:
			onTouchEnd((float)ev.xbutton.x, (float)ev.xbutton.y);
			break;
		case MotionNotify:
			onTouchMove((float)ev.xmotion.x, (float)ev.xmotion.y);
			break;
		case ConfigureNotify:
			onResize(ev.xconfigure.width, ev.xconfigure.height);
			break;
		case ClientMessage:
			if (wm_delete_window != None && (Atom)ev.xclient.data.l[0] == wm_delete_window) {
				onStop();
				return;
			}
			break;
		}
	}
}
Beispiel #10
0
void BaseThread::nonBlockStop()
{
	if (!m_pPrivates->m_pThread)
		return;

	m_pPrivates->m_bStop = true;
	onStop();
}
Beispiel #11
0
void SoundRecorder::stop()
{
    // Stop the capturing thread
    m_isCapturing = false;
    m_thread.wait();

    // Notify derived class
    onStop();
}
Beispiel #12
0
void AmSession::setStopped(bool wakeup) {
  if (!sess_stopped.get()) {
    sess_stopped.set(true); 
    onStop();
  }
  if (wakeup) 
    AmSessionContainer::instance()->postEvent(getLocalTag(), 
					      new AmEvent(0));
}
Beispiel #13
0
void Serializer::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatAddSource:
        {
            ssize_t index = onAddSource(msg);

            sp<AMessage> response = new AMessage;

            if (index < 0) {
                response->setInt32("err", index);
            } else {
                response->setSize("index", index);
            }

            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            response->postReply(replyID);
            break;
        }

        case kWhatStart:
        case kWhatStop:
        {
            status_t err = (msg->what() == kWhatStart) ? onStart() : onStop();

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);

            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            response->postReply(replyID);
            break;
        }

        case kWhatPoll:
        {
            int32_t generation;
            CHECK(msg->findInt32("generation", &generation));

            if (generation != mPollGeneration) {
                break;
            }

            int64_t delayUs = onPoll();
            if (delayUs >= 0ll) {
                schedulePoll(delayUs);
            }
            break;
        }

        default:
            TRESPASS();
    }
}
Beispiel #14
0
void ApplicationContext::stop()
{
  if (_app_state == ApplicationLifeState::RUNNING
      || _app_state == ApplicationLifeState::RUNNABLE || _app_state == ApplicationLifeState::PAUSED)
  {
    _event_listener.deactivate();
    onStop();
    _app_state = ApplicationLifeState::STOPPED;
  }
}
Beispiel #15
0
void HttpServer::stop()
{
  if( m_stop ) return;
  m_stop = true;
  onStop();

  if( m_threadid )
    thread_join( m_threadid );
  m_threadid = 0;
}
void DownloadToolTask::decreaseRefCount(bool forced)
{
	m_uiRefCount--;

	if (m_uiRefCount == 0)
	{
		if (m_uiPercent < 75 || forced)
			onStop();
	}
}
Beispiel #17
0
void MainWindow::onLoadScene()
{
    onStop();
    if (_ui->renderer->isRendering()) {
        _nextScene = _ui->sceneNames->currentText();
    } else {
        _loadScene(_ui->sceneNames->currentText());
        onPlayPause();
    }
}
Beispiel #18
0
int main(void)
{
    onPlay();
    onPause();
    onPlay();
    onPlay();
    onStop();
    onPause();
    return 0;
}
void ActorStateMachine::stop()
{
    assert(running);
    assert(currentState);

    onStop();

    running = false;
    currentState->onLeave();
    currentState = 0;
}
TelemetryManager::TelemetryManager()
{
    moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
    // Get UAVObjectManager instance
    ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
    objMngr = pm->getObject<UAVObjectManager>();

    // connect to start stop signals
    connect(this, SIGNAL(myStart()), this, SLOT(onStart()),Qt::QueuedConnection);
    connect(this, SIGNAL(myStop()), this, SLOT(onStop()),Qt::QueuedConnection);
}
Beispiel #21
0
 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 IServer::stop() {
     boost::mutex lock_;
     lock_.lock();
     if (!isRunning_) {
         BOOST_LOG_TRIVIAL(warning) << "Server not running skip stop!!!\n";
         return;
     } else {
         isRunning_ = false;
         onStop();
     }
     lock_.unlock();
 }
Beispiel #23
0
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;
    }
}
Beispiel #24
0
void Modifier::stop( StopState state ) {
	startTime = NULL;
	int i;
	for(i = 0; i < impersonators.size(); i++) {
		impersonators.at(i)->stop();
	}
	for(i = 0; i < followers.size(); i++) {
		followers.at(i)->start();
	}
	if(target != nullptr)
		target->onModifierStop(name, state);
	onStop();
}
void
controllerService_t::processRequests(void)
{

	if (false == m_http->start()) {
		m_log->error("Error while starting HTTP server", eventlog_cat_t::CAT_CONTROLLER, false);
		onStop();
		return;
	}

	while (QSERVICE_RUNNING == getState()) {
		if (false == m_http->waitForRequest()) {
			m_log->error("Error while waiting for HTTP client", eventlog_cat_t::CAT_CONTROLLER, false);
			onStop();
			return;
		}
	}

	m_http->stop();

	return;
}
		void Live555ClientEngine::onDescribeResponse(RTSPClient* rtspClient, int resultCode, char* resultString)
		{
			string result(resultString);
			delete[] resultString;

			if (resultCode != 0)
			{
				Logs::error("simplicity::live555", "Failed to get a SDP description: %s", result.c_str());
				onStop();
				return;
			}

			// Create a session.
			// TODO Memory leak?
			session = MediaSession::createNew(*environment, result.c_str());
			if (session == nullptr)
			{
				Logs::error("simplicity::live555",
						"Failed to create a MediaSession object from the SDP description: %s",
						environment->getResultMsg());
				onStop();
				return;
			}

			// Create the sub-sessions.
			// TODO Handle multiple sub-sessions
			unique_ptr<MediaSubsessionIterator> iterator(new MediaSubsessionIterator(*session));
			subSession = iterator->next();

			if (!subSession->initiate())
			{
				Logs::error("simplicity::live555", "Failed to initiate the \"%s\" sub-session: %s",
						subSession->mediumName(), environment->getResultMsg());
				onStop();
				return;
			}

			rtspClient->sendSetupCommand(*subSession, live555::onSetupResponse);
		}
Beispiel #27
0
void fileList::onTwDoubleClick(int row, int colum)
{
    if(lastRow < ui.twList->rowCount())
    {
        reinterpret_cast<wavSample*>(ui.twList->cellWidget(lastRow ,0))->setActive(false);
        reinterpret_cast<wavSample*>(ui.twList->cellWidget(lastRow ,0))->setStyleSheet("QLabel{background-color: transparent; color: rgb(220, 220, 220);}");
    }
	reinterpret_cast<wavSample*>(ui.twList->cellWidget(row ,0))->setActive(true);
	reinterpret_cast<wavSample*>(ui.twList->cellWidget(row ,0))->setStyleSheet("QLabel{background-color: transparent; color: rgb(255, 106, 0);}");
	lastRow = row;

	onStop();
	onPlay();
}
Beispiel #28
0
ControlPanelWidget::ControlPanelWidget(Context& ctx, QWidget *parent) :
	QDockWidget(parent), ui(new Ui::ControlPanelWidget), ctx(ctx) {

	ui->setupUi(this);

	connect(ui->btnStop, SIGNAL(clicked()), this, SLOT(onStop()));
	connect(ui->btnPlay, SIGNAL(clicked()), this, SLOT(onPlay()));
	connect(ui->btnRec, SIGNAL(clicked()), this, SLOT(onRec()));
	connect(ui->spnBPM, SIGNAL(valueChanged(int)), this, SLOT(onBPM()));

	ctx.getSequencer()->addStatusListener(this);
	ctx.getSequencer()->addBeatListener(this);

}
Beispiel #29
0
LoadManager::~LoadManager ()
{
    try
    {
        UptimeTimer::getInstance ().endManualUpdates ();
        onStop ();
    }
    catch (std::exception const& ex)
    {
        // Swallow the exception in a destructor.
        JLOG(journal_.warning) << "std::exception in ~LoadManager.  "
            << ex.what();
    }
}
Beispiel #30
0
void RTMFPServer::run() {

    try {
        _pSocket->bind(SocketAddress("0.0.0.0",_port));
        _mainSockets.add(*_pSocket,*this);

        NOTE("RTMFP server starts on %u port",_port);
        onStart();

        RTMFPManager manager(*this);
        bool terminate=false;
        while(!terminate)
            handle(terminate);

    } catch(Exception& ex) {
        FATAL("RTMFPServer, %s",ex.displayText().c_str());
    } catch (exception& ex) {
        FATAL("RTMFPServer, %s",ex.what());
    } catch (...) {
        FATAL("RTMFPServer, unknown error");
    }

    _mainSockets.remove(*_pSocket);

    // terminate handle
    terminate();

    // clean sessions, and send died message if need
    _handshake.clear();
    _sessions.clear();

    // stop receiving and sending engine (it waits the end of sending last session messages)
    poolThreads.clear();

    // close UDP socket
    delete _pSocket;

    sockets.clear();
    _mainSockets.clear();
    _port=0;
    onStop();

    if(_pCirrus) {
        delete _pCirrus;
        _pCirrus = NULL;
    }

    NOTE("RTMFP server stops");
}