Ejemplo n.º 1
0
// Close OpenNI2 device
int Oni2Grabber::close() 
{
	// (1) Check
	if(!isOpened())
		return 1;

	// (2) Close camera
	try 
	{
		if(enable_depth_)
			stopAndDestroyStream_(depth_stream_);
		if(enable_infrared_)
			stopAndDestroyStream_(infrared_stream_);
		if(enable_color_)
			stopAndDestroyStream_(color_stream_);
		streams_.clear();
		device_.close();
	} 
	catch(std::exception &) 
	{
		std::cerr << openni::OpenNI::getExtendedError() << std::endl;
	}
    
	// (3) Set parameters
	if(isDebugMode())
		std::cout << " Successfully closed." << std::endl;

	setClosed_();
	return 0;
}
Ejemplo n.º 2
0
// Open and Initialize OpenNI2 device on USB Port
int Oni2Grabber::open(const char* uri) 
{
	// (1) Check
	if(isOpened()) 
	{
		if(isDebugMode())
			std::cout << " Already opened." << std::endl;
		
		return -2;
	}
	
	// (2) Open device on USB port 
	try 
	{
		openni::OpenNI::initialize();
		if(device_.open(uri ? uri : openni::ANY_DEVICE)) 
		{	// Open a first-found camera
			if(isDebugMode())
				std::cout << " Opening failed, OpenNI2 device connected?" << std::endl;

			return -1;
		}

		if(enable_depth_)
			createAndStartStream_(depth_stream_, openni::SENSOR_DEPTH);

		if(enable_infrared_)
			createAndStartStream_(infrared_stream_, openni::SENSOR_IR);

		if(enable_color_)
			createAndStartStream_(color_stream_, openni::SENSOR_COLOR);

	} 
	
	catch(std::exception &) 
	{
		std::cerr << openni::OpenNI::getExtendedError() << std::endl;
	}
	
	// (3) Set parameters
	if(isDebugMode())
		std::cout << " Successfully opened." << std::endl;

	setOpened_();
	initCamera_();
	return 0;
}
Ejemplo n.º 3
0
int ThreadLocalManager::appendDebugLog(const std::string& msg) {
  if (!isDebugMode()) return 0;
  if (!_profile) {
    LOG(ERROR) << "No profile to append message";
    return -1;
  }
  _profile->debug_log += msg;
  return 0;
}
Ejemplo n.º 4
0
void EmulApp::startFSMServer()
{
    if (fsmServerProc) delete fsmServerProc;
    fsmServerProc = new QProcess(this);
    fsmServerProc->setProcessChannelMode(QProcess::MergedChannels);        
    connect(fsmServerProc, SIGNAL(readyRead()), this, SLOT(fsmServerHasOutput()));
    connect(fsmServerProc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(fsmServerProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processDied()));
    
    QStringList args;
    if (isDebugMode()) args.push_back("-d");
#ifdef Q_OS_WIN
    fsmServerProc->start("FSMServer.exe", args, QIODevice::ReadOnly);
#elif defined(Q_OS_DARWIN)
    if (QFile::exists("FSMEmulator.app/Contents/MacOS/FSMServer"))
        fsmServerProc->start("FSMEmulator.app/Contents/MacOS/FSMServer", args, QIODevice::ReadOnly);
    else
        fsmServerProc->start("./FSMServer", args, QIODevice::ReadOnly);
#else /* LINUX */
    fsmServerProc->start("./FSMServer", args, QIODevice::ReadOnly);
#endif
    Log() << "Starting FSMServer...\n";    
    fsmServerProc->waitForStarted(10000);
    if (fsmServerProc->state() == QProcess::Running) {
#ifdef Q_OS_WIN
        int pid = fsmServerProc->pid()->dwProcessId;
#else
        int pid = fsmServerProc->pid();
#endif
        Log() << "Started FSMServer with PID " << pid << "\n";
    } else {
        QString errStr;

        switch (fsmServerProc->error()) {
        case QProcess::FailedToStart: errStr = "Process failed to start"; break;
        case QProcess::Crashed: errStr = "Process crashed after starting"; break;
        case QProcess::Timedout: errStr = "Waiting for the process timed out"; break;
        default: errStr = "Unknown error";
        }
        throw Exception("Could not start FSMServer: " + errStr);
    }
    
}
Ejemplo n.º 5
0
void Platform::boot(const QString core)
{
    QString app = adjustPath(core);

    if (!isDebugMode() && !QFile::exists(app)) {
        QMessageBox::critical(this, tr("ThinReportsEditor Booting Error"),
                              "Unable to load application.");
        exit(0);
    }

    view->load(app);

    setup();

    connect(view, SIGNAL(loadFinished(bool)), this, SLOT(init()));
    connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
            this, SLOT(populateJavaScript()));
    connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
    connect(view, SIGNAL(linkClicked(QUrl)), this, SLOT(openUrl(QUrl)));

    show();
}
Ejemplo n.º 6
0
void Platform::setup()
{
    // Load built-in fonts.
    QDirIterator it(adjustPath(QLatin1String("fonts")));
    while (it.hasNext()) {
        it.next();
        if (it.fileInfo().completeSuffix().toLower() == "ttf") {
            QFontDatabase::addApplicationFont(it.filePath());
        }
    }

    // Setup of WebView.
    setAttribute(Qt::WA_InputMethodEnabled, true);

    view->setMinimumWidth(800);
    view->setMinimumHeight(600);

    QWebSettings *settings = view->settings();

    settings->setDefaultTextEncoding("utf-8");
    settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
    settings->setLocalStoragePath(adjustPath("."));

    view->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);

    if (!isDebugMode()) {
        view->setAcceptDrops(false);
        view->setContextMenuPolicy(Qt::PreventContextMenu);
    } else {
        settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    }

    // Setup of Widget.
    setCentralWidget(view);
    resize(1000, 700);
}