Exemplo n.º 1
0
void crashHandler(int sig)
{
    std::lock_guard<std::mutex> lock(mutex);

    initLoggingSystem();

    switch (sig)
    {
    case SIGSEGV:
    {
        logFatal("SIGSEGV\nBacktrace:\n");
        break;
    }
    case SIGABRT:
    {
        logFatal("SIGABRT\nBacktrace:\n");
        break;
    }
    }

    unsigned int depth = 0;
    const char **backtrace = getBacktrace(depth);

    for (size_t i = 0; i < depth-1; ++i)
    {
        logFatal("    %s\n", backtrace[i]);
    }

    deinitLoggingSystem();

    std::exit(1);
}
Exemplo n.º 2
0
Ball::Ball(SDL_Renderer *renderer, MovingRect &state) {
	this->renderer = renderer;
	this->tex = loadTexture("ball.png", renderer);
	if (this->tex == nullptr) {
		logFatal("loadTexture");
	}
	int w, h;
	if (SDL_QueryTexture(this->tex, nullptr, nullptr, &w, &h) != 0) {
		logFatal("QueryTexture");
	}
	state.size.x = static_cast<float>(w);
	state.size.y = static_cast<float>(h);
}
Exemplo n.º 3
0
MainWindow::MainWindow(Logger* log, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    pLogger = log;

    ui->statusBar->showMessage("Ready to be used");

    // Récupération des valeur possibles pour le calcul des voies depuis l'énumération
    for (int i = 0; i < WayMethods::numMethods; i++) {
        ui->methodComboBox->addItem(WayMethods::MethodeVoies_name[i]);
    }
    ui->methodComboBox->setCurrentIndex(WayMethods::ANGLE_MIN); // valeur par défaut

    // Connexion des messages émis depuis le logger ou la database
    connect(pLogger,SIGNAL(information(QString)),this,SLOT(logInformation(QString)));
    connect(pLogger,SIGNAL(debug(QString)),this,SLOT(logDebug(QString)));
    connect(pLogger,SIGNAL(warning(QString)),this,SLOT(logWarning(QString)));
    connect(pLogger,SIGNAL(fatal(QString)),this,SLOT(logFatal(QString)));

    connect(ui->calculatePushButton,SIGNAL(clicked()),this,SLOT(calculate()));
    connect(ui->modifyPushButton,SIGNAL(clicked()),this,SLOT(modify()));

    connect(ui->browsePushButton, SIGNAL(clicked()), this, SLOT(browse()));

    connect(ui->classificationRadioButton, SIGNAL(toggled(bool)), this, SLOT(optionsModification(bool)));

}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
  /* dbgmsg()
  ** You can use '|dbgmsg()| exactly as if it was '|printf()| the difference
  ** is that the output will go on the file defined with '|utlSetOuput()| 
  ** (or '|stderr| if no file has been specified)     
  */  
  
  dbgmsg("This message will go on stderr %d\n",1);
  utlSetOutput("utlh1.dbg");
  dbgmsg("This message is on utlh1.log");
  utlSetOutput("utlh2.dbg"); /* the previous file is closed and the new one is opened*/
  dbgmsg("This message is on utlh2.log");
  utlSetOutput(NULL); 
  dbgmsg("This message will go on stderr %d",2);

  
  /* Logging is different from debugging messages in that the logging will
  ** remain in your production code and you will be able to enable it to
  ** monitor the application behavior.  
  */
    
  logSetLevel(logALL);
  logDebug("This is a log debug message. (%d)",logLevel);
  logSetLevel(logINFO);
  logDebug("This will not appear");
  logMessage("\n%s...continuing",logIndent);
  logWarn("And now a warning (%d)",5);
  logSetFile("utlh1.log","w");
  logError("An error!");
  logFatal("An unrecoverable error");
   
  return (0);
}
Exemplo n.º 5
0
bool Graphics::selectPainterEngine(PainterEngine painterEngine)
{
    bool found = false;
#ifdef PAINTER_OGL2
    // always prefer OpenGL 2 over OpenGL 1
    if(!found && g_painterOGL2 && (painterEngine == Painter_OpenGL2 || painterEngine == Painter_Any)) {
        m_selectedPainterEngine = Painter_OpenGL2;
        g_painter = g_painterOGL2;
        found = true;
    }
#endif

#ifdef PAINTER_OGL1
    // fallback to OpenGL 1 in older hardwares
    if(!found && g_painterOGL1 && (painterEngine == Painter_OpenGL1 || painterEngine == Painter_Any)) {
        m_selectedPainterEngine = Painter_OpenGL1;
        g_painter = g_painterOGL1;
        found = true;
    }
#endif

    if(!found)
        logFatal("Neither OpenGL 1.0 nor OpenGL 2.0 painter engine is supported by your platform, "
                 "try updating your graphics drivers or your hardware and then run again.");

    // switch painters GL state
    if(g_painter)
        g_painter->unbind();
    g_painter->bind();

    if(painterEngine == Painter_Any)
        return true;
    return getPainterEngine() == painterEngine;
}
Exemplo n.º 6
0
int Cabinet::listenOnPort(int port) {
    int listenFd;
    if ((listenFd = Util::listenTcp(port)) == CABINET_ERR) {
        logFatal("listen on port error, port[%d]", port);
        return CABINET_ERR;
    }
    return listenFd;
}
Exemplo n.º 7
0
Player::Player(SDL_Renderer *renderer, MovingRect &state) {
	this->renderer = renderer;
	this->tex = loadTexture("paddle.png", renderer);
	if (this->tex == nullptr) {
		logFatal("loadTexture");
	}
	int w, h;
	if (SDL_QueryTexture(this->tex, nullptr, nullptr, &w, &h) != 0) {
		logFatal("QueryTexture");
	}
	std::cout << "texture size = " << w << "," << h << std::endl;
	state.size.x = static_cast<float>(w);
	state.size.y = static_cast<float>(h);
	state.speed.x = 0;
	state.speed.y = 0;
	this->score = 0;
}
Exemplo n.º 8
0
void *processShutDown(int sigo) {
    if (cluster == nullptr) {
        return nullptr;
    }
    logFatal("receive signal to shutdown cabint-cluster");
    cluster->shutDown();
    exit(1);
    return nullptr;
}
Exemplo n.º 9
0
void vhalt(const char *message)
{
	stop_recording();
        logFatal("vhalt: %s", message);
	GetCurrentLogger()->flush();
	shutdown_application();
	system_alert_user(message, fatalError);
	abort();
}
Exemplo n.º 10
0
void ModuleManager::autoLoadModules(int maxPriority)
{
    for(auto& pair : m_autoLoadModules) {
        int priority = pair.first;
        if(priority > maxPriority)
            break;
        ModulePtr module = pair.second;
        if(!module->isLoaded() && !module->load())
            logFatal("A required module has failed to load, cannot continue to run.");
    }
}
Exemplo n.º 11
0
int main()
{
    if (signal(SIGTERM, (__sighandler_t)processShutDown) == SIG_ERR) {
        logFatal("install shut down function fail");
        exit(1);
    }
    cluster = new Cluster;
    cluster->initConfig();
    cluster->init();
    cluster->onFire();
    return 0;
}
Exemplo n.º 12
0
void alert_user(short severity, short resid, short item, int error)
{
  char str[256];
  getcstr(str, resid, item);
  char msg[300];
  sprintf(msg, "%s (error %d)", str, error);
  if (severity == infoError) {
    logError("alert (ID=%hd): %s", error, str);
  } else if (severity == fatalError) {
    logFatal("fatal alert (ID=%hd): %s", error, str);
  }
  alert_user(msg, severity);
}
Exemplo n.º 13
0
void Graphics::init()
{
#ifndef OPENGL_ES2
    // init GL extensions
    GLenum err = glewInit();
    if(err != GLEW_OK)
        logFatal("Unable to init GLEW: ", glewGetErrorString(err));
    if(!GLEW_ARB_vertex_program || !GLEW_ARB_vertex_shader ||
            !GLEW_ARB_fragment_program || !GLEW_ARB_fragment_shader ||
            !GLEW_ARB_framebuffer_object ||
            !GLEW_ARB_multitexture)
        logFatal("Your video driver is not supported");
#endif

    glEnable(GL_BLEND);

    logInfo("GPU ", glGetString(GL_RENDERER));
    logInfo("OpenGL ", glGetString(GL_VERSION));

    m_emptyTexture = TexturePtr(new Texture);

    g_painter.init();
}
Exemplo n.º 14
0
Shader::Shader(Shader::ShaderType shaderType)
{
    m_shaderType = shaderType;
    switch(shaderType) {
        case Vertex:
            m_shaderId = glCreateShader(GL_VERTEX_SHADER);
            break;
        case Fragment:
            m_shaderId = glCreateShader(GL_FRAGMENT_SHADER);
            break;
    }

    if(!m_shaderId)
        logFatal("Unable to create GL shader");
}
Exemplo n.º 15
0
int main(int argc, const char *argv[])
{
    signal(SIGSEGV, crashHandler);
    signal(SIGABRT, crashHandler);
    signal(SIGFPE, fpeHandler);

    initBacktrace();
    initLoggingSystem();
    initJobSystem(SDL_GetCPUCount()+1);

    int result = EXIT_FAILURE;

    try
    {
        result = unsafeMain(argc, argv);
    } catch (std::exception& e)
    {
        logFatal("Unhandled exception caught: %s\n", e.what());
    } catch (scripting::UnhandledExcException& e)
    {
        scripting::Value exc = e.getException();

        logFatal("Unhandled script exception:\n");

        if (exc.type == scripting::ValueType::Exception)
        {
            logFatal("    %s\n", ((scripting::ExceptionData *)exc.p)->error.getData());
        }
    } catch (const Exception& e)
    {
        logFatal("Unhandled exception caught: %s\n", e.getString());
        logFatal("    File: %s\n", e.getFile());
        logFatal("    Line: %d\n", e.getLine());
        logFatal("    Function: %s\n", e.getFunction());
    } catch (...)
    {
        logFatal("Unhandled exception caught.");
    }

    deinitJobSystem();
    deinitLoggingSystem();
    deinitBacktrace();

    return result;
}
Exemplo n.º 16
0
void Graphics::init()
{
    logInfo("GPU ", glGetString(GL_RENDERER));
    logInfo("OpenGL ", glGetString(GL_VERSION));

#if OPENGL_ES==2
    g_painterOGL2 = new PainterOGL2;
#elif OPENGL_ES==1
    g_painterOGL1 = new PainterOGL1;
#else
    // init GL extensions
    GLenum err = glewInit();
    if(err != GLEW_OK)
        logFatal("Unable to init GLEW: ", glewGetErrorString(err));

    // overwrite framebuffer API if needed
    if(GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {
        glGenFramebuffers = glGenFramebuffersEXT;
        glDeleteFramebuffers = glDeleteFramebuffersEXT;
        glBindFramebuffer = glBindFramebufferEXT;
        glFramebufferTexture2D = glFramebufferTexture2DEXT;
        glCheckFramebufferStatus = glCheckFramebufferStatusEXT;
        glGenerateMipmap = glGenerateMipmapEXT;
    }

    // opengl 1 is always supported
    g_painterOGL1 = new PainterOGL1;

    // opengl 2 is only supported in newer hardware
    if(GLEW_VERSION_2_0)
        g_painterOGL2 = new PainterOGL2;
#endif

    // blending is always enabled
    glEnable(GL_BLEND);

    // determine max texture size
    static GLint maxTextureSize = -1;
    if(maxTextureSize == -1)
        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
    if(m_maxTextureSize == -1 || m_maxTextureSize > maxTextureSize)
        m_maxTextureSize = maxTextureSize;

    selectPainterEngine(m_prefferedPainterEngine);
    m_emptyTexture = TexturePtr(new Texture);

}
Exemplo n.º 17
0
int main (int argc, char *argv[])
{
  int x = 3;
  logWarn(logStderr,"Hello");
  logFatal(logStderr,"Hello (fatal)");
  x+=4;
  { utlAssume(sizeof(short) == 2);
    utlAssume(sizeof(int) == sizeof(long));
    utlAssume(sizeof(unsigned int) == sizeof(long));
    
    x -=2;
  }
   
  printf("%d\n",sizeof(log_abbrev));
  logAssert(logStderr, x>0 );
  logAssert(logStderr, x<0 );
  
  
  exit(0);
} 
Exemplo n.º 18
0
void ModuleManager::discoverModulesPath()
{
    // search for modules directory
    std::string possibleDirs[] = { "modules",
                                    g_resources.getBaseDir() + "modules",
                                    g_resources.getBaseDir() + "../modules",
                                    g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules",
                                    "" };
    bool found = false;
    for(const std::string& dir : possibleDirs) {
        // try to add module directory
        if(g_resources.addToSearchPath(dir)) {
            logInfo("Using modules directory '", dir.c_str(), "'");
            found = true;
            break;
        }
    }

    if(!found)
        logFatal("Could not find modules directory");
}
Exemplo n.º 19
0
void LuaInterface::createLuaState()
{
    // creates lua state
    L = luaL_newstate();
    if(!L)
        logFatal("Unable to create lua state");

    // load lua standard libraries
    luaL_openlibs(L);
    
    // load bit32 lib for bitwise operations
    luaopen_bit32(L);

    // creates weak table
    newTable();
    newTable();
    pushString("v");
    setField("__mode");
    setMetatable();
    m_weakTableRef = ref();

    // installs script loader
    getGlobal("package");
    getField("loaders");
    pushCFunction(&LuaInterface::luaScriptLoader);
    rawSeti(5);
    pop(2);

    // replace dofile
    pushCFunction(&LuaInterface::luaScriptRunner);
    setGlobal("dofile");

    // dofiles
    pushCFunction(&LuaInterface::luaScriptsRunner);
    setGlobal("dofiles");
}
Exemplo n.º 20
0
/* The send embedded callback
 *  return : nb bytes sent, or error
 */
int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
{
    int sd = *(int*)ctx;
    int sent;
    int len = sz;
    int err;

    uint32_t timeout = 500;
    socklen_t sizeOfTimeOut = sizeof(timeout);

    int result = setsockopt (sd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeOfTimeOut);

    if (result<0) {
      logOffNominal("setsockopt SO_SNDTIMEO failed(%d).",result);
      return CYASSL_CBIO_ERR_GENERAL;
    }

    CYASSL_ENTER("EmbedSend");
    CYASSL_DEBUG("EmbedSend - lwip_send ssl=%08x sd=%08x, buf=%08x len=%u flags=%x", (unsigned)ssl, (unsigned)sd, (unsigned)&buf[sz - len], len, ssl->wflags);

    sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, ssl->wflags);
    CYASSL_DEBUG("EmbedSend - lwip_send ssl=%08x sd=%08x, buf=%08x len=%u flags=%x returned=%d", (unsigned)ssl, (unsigned)sd, (unsigned)&buf[sz - len], len, ssl->wflags, sent);

    if (sent < 0) {
        err = LastError();
        CYASSL_MSG("Embed Send error");

        if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
            CYASSL_MSG("    Would Block");
            return CYASSL_CBIO_ERR_WANT_WRITE;
        }
        else if (err == SOCKET_ECONNRESET) {
            CYASSL_MSG("    Connection reset");
            return CYASSL_CBIO_ERR_CONN_RST;
        }
        else if (err == SOCKET_EINTR) {
            CYASSL_MSG("    Socket interrupted");
            return CYASSL_CBIO_ERR_ISR;
        }
        else if (err == SOCKET_EPIPE) {
            CYASSL_MSG("    Socket EPIPE");
            return CYASSL_CBIO_ERR_CONN_CLOSE;
        }
        else {
            CYASSL_MSG("    General error");
            return CYASSL_CBIO_ERR_GENERAL;
        }
    }

    socklen_t getSizeOfTimeOut = sizeof(timeout);
    timeout = 0xdeadbeef;
    result = getsockopt (sd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
        &getSizeOfTimeOut);

    if (result<0) logFatal("getsockopt SO_SNDTIMEO failed.");

    if (timeout != 500) logFatal("getsockopt SO_SNDTIMEO did not read what we wrote %u %u.", getSizeOfTimeOut, timeout);

    CYASSL_LEAVE("EmbedSend", sent);
    return sent;
}
Exemplo n.º 21
0
void halt(void)
{
        logFatal("halt called");
	fprintf(stderr, "halt\n");
	abort();
}
Exemplo n.º 22
0
void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
{
    ModulePtr module = g_modules.getModule(moduleName);
    if(!module || !module->load())
        logFatal("Unable to load '", moduleName, "' module");
}
Exemplo n.º 23
0
void MainWindow::modify() {

    // on vide le logger d'eventuels anciens calculs
    ui->loggerTextBrowser->clear();
    ui->statusBar->showMessage("");

    /******* logger *******/
    pLogger->setDebugActive(ui->debugCheckBox->isChecked());
    QApplication::processEvents();

    /****** database ******/

    QString host = ui->dbhostLineEdit->text();
    QString name = ui->dbnameLineEdit->text();
    QString user = ui->dbuserLineEdit->text();
    QString pass = ui->dbpassswordLineEdit->text();

    pDatabase = new Database(host, name, user, pass);

    ui->statusBar->showMessage("Connexion");
    pLogger->INFO("Trying to connect you");
    if (! pDatabase->connexion()) {
        mettreEnErreur("Erreur Connexion");
        return;
    }
    pLogger->INFO("Connected !");

    // On connecte les logger de la database, pour afficher les messages dans la boite de dialogue
    connect(pDatabase,SIGNAL(information(QString)),this,SLOT(logInformation(QString)));
    connect(pDatabase,SIGNAL(debug(QString)),this,SLOT(logDebug(QString)));
    connect(pDatabase,SIGNAL(warning(QString)),this,SLOT(logWarning(QString)));
    connect(pDatabase,SIGNAL(fatal(QString)),this,SLOT(logFatal(QString)));


    QDateTime start = QDateTime::currentDateTime();
    pLogger->INFO(QString("Started : %1").arg(start.toString()));

    QString table = ui->arcstablenameLineEdit->text();
    QString att_1 = ui->inputatt1LineEdit->text();
    QString new_att1 = ui->resultattLineEdit->text();

    if (ui->classificationRadioButton->isChecked()) {
        int nb_classes = ui->classnbSpinBox->value();
        bool ascendant = ! ui->descentCheckBox->isChecked();
        if (! pDatabase->add_att_cl(table, new_att1, att_1, nb_classes, ascendant)) {
            mettreEnErreur("Erreur classification");
            return;
        }

    } else if (ui->additionRadioButton->isChecked()) {
        QString att_2 = ui->inputatt2LineEdit->text();
        if (! pDatabase->add_att_add(table, new_att1, att_1, att_2)) {
            mettreEnErreur("Erreur addition");
            return;
        }

    } else if (ui->soustractionRadioButton->isChecked()) {
        QString att_2 = ui->inputatt2LineEdit->text();
        if (! pDatabase->add_att_dif(table, new_att1, att_1, att_2)) {
            mettreEnErreur("Erreur soustraction");
            return;
        }

    } else if (ui->multiplicationRadioButton->isChecked()) {
        QString att_2 = ui->inputatt2LineEdit->text();
        if (! pDatabase->add_att_prod(table, new_att1, att_1, att_2)) {
            mettreEnErreur("Erreur multiplication");
            return;
        }

    } else if (ui->divisionRadioButton->isChecked()) {
        QString att_2 = ui->inputatt2LineEdit->text();
        if (! pDatabase->add_att_div(table, new_att1, att_1, att_2)) {
            mettreEnErreur("Erreur division");
            return;
        }

    } else if (ui->absoluteDiffRadioButton->isChecked()) {
        QString att_2 = ui->inputatt2LineEdit->text();
        if (! pDatabase->add_att_difABS(table, new_att1, att_1, att_2)) {
            mettreEnErreur("Erreur différence absolue");
            return;
        }

    } else {
        pLogger->ERREUR("Action have to be precised");
        mettreEnErreur("Nothing to do");
        return;
    }

    ui->statusBar->showMessage("It's all right");
    QApplication::processEvents();

    QDateTime end = QDateTime::currentDateTime();
    pLogger->INFO(QString("End : %1").arg(end.toString()));
    pLogger->INFO(QString("Temps total d'execution' : %1 minutes").arg(start.secsTo(end) / 60.));

}
Exemplo n.º 24
0
int main(int argc, char **argv)
#endif
{
	// Print banner (don't bother if this doesn't appear when started from a GUI)
	char app_name_version[256];
	expand_app_variables(app_name_version, "Aleph One $appLongVersion$");
	printf ("%s\n%s\n\n"
	  "Original code by Bungie Software <http://www.bungie.com/>\n"
	  "Additional work by Loren Petrich, Chris Pruett, Rhys Hill et al.\n"
	  "TCP/IP networking by Woody Zenfell\n"
	  "Expat XML library by James Clark\n"
	  "SDL port by Christian Bauer <*****@*****.**>\n"
#if defined(__MACH__) && defined(__APPLE__)
	  "Mac OS X/SDL version by Chris Lovell, Alexander Strange, and Woody Zenfell\n"
#endif
	  "\nThis is free software with ABSOLUTELY NO WARRANTY.\n"
	  "You are welcome to redistribute it under certain conditions.\n"
	  "For details, see the file COPYING.\n"
#if defined(__WIN32__)
	  // Windows is statically linked against SDL, so we have to include this:
	  "\nSimple DirectMedia Layer (SDL) Library included under the terms of the\n"
	  "GNU Library General Public License.\n"
	  "For details, see the file COPYING.SDL.\n"
#endif
#if !defined(DISABLE_NETWORKING)
	  "\nBuilt with network play enabled.\n"
#endif
#ifdef HAVE_LUA
	  "\nBuilt with Lua scripting enabled.\n"
#endif
	  , app_name_version, A1_HOMEPAGE_URL
    );

	// Parse arguments
	char *prg_name = argv[0];
	argc--;
	argv++;
	while (argc > 0) {
		if (strcmp(*argv, "-h") == 0 || strcmp(*argv, "--help") == 0) {
			usage(prg_name);
		} else if (strcmp(*argv, "-v") == 0 || strcmp(*argv, "--version") == 0) {
			printf("%s\n", app_name_version);
			exit(0);
		} else if (strcmp(*argv, "-f") == 0 || strcmp(*argv, "--fullscreen") == 0) {
			force_fullscreen = true;
		} else if (strcmp(*argv, "-w") == 0 || strcmp(*argv, "--windowed") == 0) {
			force_windowed = true;
		} else if (strcmp(*argv, "-g") == 0 || strcmp(*argv, "--nogl") == 0) {
			option_nogl = true;
		} else if (strcmp(*argv, "-s") == 0 || strcmp(*argv, "--nosound") == 0) {
			option_nosound = true;
                } else if (strcmp(*argv, "-j") == 0 || strcmp(*argv, "--nojoystick") == 0) {
                        option_nojoystick = true;
		} else if (strcmp(*argv, "-m") == 0 || strcmp(*argv, "--nogamma") == 0) {
			option_nogamma = true;
		} else if (strcmp(*argv, "-i") == 0 || strcmp(*argv, "--insecure_lua") == 0) {
			insecure_lua = true;
		} else if (strcmp(*argv, "-d") == 0 || strcmp(*argv, "--debug") == 0) {
		  option_debug = true;
		} else if (*argv[0] != '-') {
			// if it's a directory, make it the default data dir
			// otherwise push it and handle it later
			FileSpecifier f(*argv);
			if (f.IsDir())
			{
				arg_directory = *argv;
			}
			else
			{
				arg_files.push_back(*argv);
			}
		} else {
			printf("Unrecognized argument '%s'.\n", *argv);
			usage(prg_name);
		}
		argc--;
		argv++;
	}

	try {
		
		// Initialize everything
		initialize_application();

		for (std::vector<std::string>::iterator it = arg_files.begin(); it != arg_files.end(); ++it)
		{
			if (handle_open_document(*it))
			{
				break;
			}
		}

		// Run the main loop
		main_event_loop();

	} catch (exception &e) {
		try 
		{
			logFatal("Unhandled exception: %s", e.what());
		}
		catch (...) 
		{
		}
		exit(1);
	} catch (...) {
		try
		{
			logFatal("Unknown exception");
		}
		catch (...)
		{
		}
		exit(1);
	}

	return 0;
}
Exemplo n.º 25
0
void MainWindow::calculate() {

    // on vide le logger d'eventuels anciens calculs
    ui->loggerTextBrowser->clear();
    ui->statusBar->showMessage("");

    /******* logger *******/
    pLogger->setDebugActive(ui->debugCheckBox->isChecked());
    QApplication::processEvents();

    /****** database ******/

    QString host = ui->dbhostLineEdit->text();
    QString name = ui->dbnameLineEdit->text();
    QString user = ui->dbuserLineEdit->text();
    QString pass = ui->dbpassswordLineEdit->text();

    pDatabase = new Database(host, name, user, pass);

    ui->statusBar->showMessage("Connexion");
    pLogger->INFO("Trying to connect you");
    if (! pDatabase->connexion()) {
        mettreEnErreur("Erreur Connexion");
        return;
    }
    pLogger->INFO("Connected !");

    // On connecte les logger de la database, pour afficher les messages dans la boite de dialogue
    connect(pDatabase,SIGNAL(information(QString)),this,SLOT(logInformation(QString)));
    connect(pDatabase,SIGNAL(debug(QString)),this,SLOT(logDebug(QString)));
    connect(pDatabase,SIGNAL(warning(QString)),this,SLOT(logWarning(QString)));
    connect(pDatabase,SIGNAL(fatal(QString)),this,SLOT(logFatal(QString)));


    QDateTime start = QDateTime::currentDateTime();
    pLogger->INFO(QString("Started : %1").arg(start.toString()));

    //------------------------------- Définition des paramètres de l'étude

    //+++
    WayMethods::methodID methode = (WayMethods::methodID) ui->methodComboBox->currentIndex();
    double seuil_angle = ui->thresholdDoubleSpinBox->value();
    //+++

 //   for(seuil_angle = 148.; seuil_angle<=180; seuil_angle+=2){

    if (ui->dropTABLESCheckBox->isChecked()){
        pDatabase->dropTable("PIF");
        pDatabase->dropTable("PANGLES");
        pDatabase->dropTable("INFO");
        pDatabase->dropTable("PVOIES");
        pLogger->INFO("table PVOIES has been droped");
    }

    //------------------------------- Création du graphe
    Graphe *graphe_courant = new Graphe(pDatabase, pLogger, ui->BufferDoubleSpinBox->value());

    ui->statusBar->showMessage("Graph in progress");
    QApplication::processEvents();
    if (! graphe_courant->do_Graphe(ui->arcstablenameLineEdit->text())) {
        mettreEnErreur("Cannot calculate graph");
        return;
    }

    //------------------------------- Calculs sur les voies
    Voies *voies_courantes = new Voies(pDatabase, pLogger, graphe_courant, methode, seuil_angle, ui->arcstablenameLineEdit->text(), ui->directoryLineEdit->text());
    pLogger->INFO("voies creees");


    ui->statusBar->showMessage("Ways in progress");
    QApplication::processEvents();
    if (! voies_courantes->do_Voies()) {
        mettreEnErreur("Cannot calculate ways");
        return;
    }

    ui->statusBar->showMessage("Ways' attributes in progress");
    QApplication::processEvents();
    if (! voies_courantes->do_Att_Voie(ui->connexionCheckBox->isChecked(), ui->useCheckBox->isChecked(), ui->inclusionCheckBox->isChecked(), ui->gradientCheckBox->isChecked(), ui->localAccesscheckBox->isChecked())) {
        mettreEnErreur("Cannot calculate ways' attributes");
        return;
    }
/*
    ui->statusBar->showMessage("Edges' attributes in progress");
    QApplication::processEvents();
    if (! voies_courantes->do_Att_Arc()) {
        mettreEnErreur("Cannot calculate edges' attributes");
        return;
    }


    //------------------------------- Calculs sur les arcs
    Arcs *arcs_courants = new Arcs(pDatabase, pLogger, graphe_courant, voies_courantes, methode, seuil_angle);
    pLogger->INFO("arcs creees");

    ui->statusBar->showMessage("Arcs in progress");
    QApplication::processEvents();
    if (ui->arcRueCheckBox->isChecked() && ! arcs_courants->do_Arcs()) {
        mettreEnErreur("Cannot calculate arcs");
        return;
    }
*/
 //   }//end for seuil

    ui->statusBar->showMessage("It's all right");
    QApplication::processEvents();

    QDateTime end = QDateTime::currentDateTime();
    pLogger->INFO(QString("End : %1").arg(end.toString()));
    pLogger->INFO(QString("Temps total d'execution' : %1 minutes").arg(start.secsTo(end) / 60.));
}