예제 #1
0
void APP_Run(void){
	/* SD card detection: PTE6 with pull-down! */
	  PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
	  PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

	  if (FAT1_Init()!=ERR_OK) { 								/* initialize FAT driver */
	      Err();
	   }
	  if (FAT1_mount(&fileSystemObject, (const TCHAR*)"0", 1) != FR_OK) { /* mount file system */
	      Err();
	  }
	  initH3LI(); 												/* init accelerometer */
	  startLog();												/* start the logger */
	  while(counter<((MEASDUR/TICK_MS)-1)){
		  isNewDataAvailable(Z_AXIS_DA, &newDataAvailableFlag); /* check if new data available */
		  if(newDataAvailableFlag == TRUE){
			  logAccData();										/* read sensor and save on SD card */
		  }
		  dataOverrun(Z_AXIS_OR, &dataOverrunFlag);				/* data overrun? */
		  if(dataOverrunFlag == TRUE){
			  count_or++;										/* count overruns */
		  }

	  }
	  stopLog();												/* stop the logger */
	  TI2_Disable();											/* disable the counter */
	  LED_G_Off();
}
예제 #2
0
void CoreImpl::init() {
	coreParamPack = paramPackFactory->load("cfg/ccor.config");
    startLog();
    // loading ids database
    if (idset.load("sys/iddb.dat")) {
        // Create triggers listed in database
        std::vector<trigid_t> ids;
        idset.enumTriggers(ids);
        for (unsigned int i=0; i < ids.size(); ++i) {
            tm.createTrigger(ids[i],trigImmediate | trigValueable,NULL);
        }
    }
    else logMessage("ccor : warning : can't open id database!");
    resMgr.loadPathMap("cfg/resmgr.config");
    // reset random seed
    paramid_t pidRandomize = coreParamPack->find("randomize");
    if (pidRandomize >= 0) {
        if (strcmp(coreParamPack->getv(pidRandomize,""), "timer")==0) 
            randToolkit.resetSeed();
        else {
            int seed;
            coreParamPack->get(pidRandomize,seed);
            randToolkit.setSeed(seed);
        }
    }
}
예제 #3
0
파일: Logger.hpp 프로젝트: susu/goodies
 void operator()(LogDetails details, Args&&...args)
 {
     if (details.loglevel <= m_logLevel)
     {
         startLog(details.loglevel, details.file, details.line, details.pretty);
         print(std::forward<Args>(args)...);
     }
 }
예제 #4
0
void MainWindow::on_startButton_clicked()
{
    if(ui->startButton->text()=="Start")
    {

        QString portName(ui->COMComboBox->currentText());
        if ("" == portName)
            QMessageBox::information(this, "startButtonClicked", "No COM selected.", QMessageBox::Ok);

        //定时截屏
        qDebug() << "Start timer";
        try {
            mp_sitLogic->start();
            mp_faceLogic->start();
        } catch(const QString &e)
        {
            QMessageBox::information(this, "start button clicked", e, QMessageBox::Ok);
            return ;
        }
        mp_cameraTimer->start(4000);
        mp_sitProcTimer->start(3000);
        ui->COMComboBox->setEnabled(false);
        ui->startButton->setText("Stop");
        ui->startInfo->setPlainText("Classification Starts");

        // logger
        mp_logger = new Logger(mp_faceLogic, mp_sitLogic);
        connect(this, &MainWindow::startLog, mp_logger, &Logger::start);
        connect(this, &MainWindow::stopLog, mp_logger, &Logger::stop);
        connect(mp_logger, &Logger::stopped, this, &MainWindow::deleteLogger);

        emit startLog();
    }
    else
    {
        emit stopLog();
        mp_cameraTimer->stop();
        mp_sitProcTimer->stop();
        mp_sitLogic->stop();
        mp_faceLogic->stop();
        ui->COMComboBox->setEnabled(true);
        ui->startButton->setText("Start");
        ui->startInfo->setPlainText("Classification Stopped");
    }
}
예제 #5
0
int main( int argc, char **argv )
{
#if defined(Q_WS_WIN)
     qt_ntfs_permission_lookup = 0;
#endif

    // Initialize the BehavePlus QApplication.
    BehavePlusApp *app = new BehavePlusApp( argc, argv );
    Q_CHECK_PTR( app );
    app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) );

    // Start the logger
    startLog( argc, argv );

    // Show the splash page
    app->showSplashPage( /* saveSplashPage */ false );
    app->updateSplashPage( "Initializing..." );

    // Create the application main window
    AppWindow *appWin = new AppWindow( app, app->m_program, app->m_version,
        app->m_build, app->m_releaseNote );
    Q_CHECK_PTR( appWin );
    app->setMainWidget( appWin );

#if defined( _WS_X11 )
    qt_wait_for_window_manager( appWin );
#endif

    // Run the application.
    int result = app->exec();

    // Cleanup
    stopLog();
    delete app;         app = 0;
    return( result );
}
int main(int argc, char* argv[])
{
	START_EASYLOGGINGPP(argc, argv);

	el::Configurations conf("config/launcher_logging.cfg");
	el::Loggers::reconfigureAllLoggers(conf);

	startLog();

	if (!al_init()) {
		LOG(FATAL) << "failed to initialize allegro!";
		return -1;
	}

	DWORD exitCode = startup("bin/Box2D SFML Engine.exe");

	LOG(INFO) << "Game exited with code: " << exitCode;

	if (exitCode == 0)
	{
		LOG(INFO) << "Game exited succesfully!";
	}
	else if (exitCode == -1)
	{
		LOG(WARNING) << "Game failed to start!";
		LOG(WARNING) << "Check that Box2D SFML Engine.exe is in the bin folder";
	}

	endLog();

	std::cout << std::endl;
	std::cout << "Press enter to exit";
	std::cin.ignore();

	return 0;
}
예제 #7
0
파일: Logger.hpp 프로젝트: susu/papyrus-war
 void operator()(LogDetails details, Args...args)
 {
   startLog(details.loglevel, details.file, details.line, details.pretty);
   print(args...);
 }
예제 #8
0
int main(void)
{
    time_t rawtime;
    struct tm * timeinfo;
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    stringstream p;
    p<<"[" << timeinfo->tm_hour<< ":"<< timeinfo->tm_min << ":" << timeinfo->tm_sec <<"]";
	std::string logname = "/home/robot/Desktop/LOG";
	logname+=p.str();
    startLog(logFile,logname);

	for (int i=0; i<BrainBall.x_detail ;i++)
	{
		BrainBall.x_place[i] = 0;
	}



    printf( "\n===== Action script for DARwIn =====\n\n");
    change_current_dir();
    minIni* ini = new minIni(INI_FILE_PATH);
    Action::GetInstance()->LoadFile(MOTION_FILE_PATH);

    //////////////////// Framework Initialize ////////////////////////////
    if(MotionManager::GetInstance()->Initialize(&cm730) == false)
    {
		linux_cm730.SetPortName("/dev/ttyUSB1");
		if(MotionManager::GetInstance()->Initialize(&cm730) == false)
			{
				printf("Fail to initialize Motion Manager!\n");
				return 0;
			}
    }
    Walking::GetInstance()->LoadINISettings(ini);
    MotionManager::GetInstance()->LoadINISettings(ini);
	
    MotionManager::GetInstance()->AddModule((MotionModule*)Action::GetInstance());
    MotionManager::GetInstance()->AddModule((MotionModule*)Head::GetInstance());
    MotionManager::GetInstance()->AddModule((MotionModule*)Walking::GetInstance());	
    LinuxMotionTimer linuxMotionTimer;
    linuxMotionTimer.Initialize(MotionManager::GetInstance());
    linuxMotionTimer.Start();
    /////////////////////////////////////////////////////////////////////

    Walking::GetInstance()->m_Joint.SetEnableBody(false);
    Head::GetInstance()->m_Joint.SetEnableBody(false);
    Action::GetInstance()->m_Joint.SetEnableBody(true);
    MotionManager::GetInstance()->SetEnable(true);

    Action::GetInstance()->Start(1);     //Init(stand up) pose

    Action::GetInstance()->Brake();
    while(Action::GetInstance()->IsRunning()) usleep(8*1000);

    cm730.WriteByte(CM730::P_LED_PANNEL, 0x02, NULL);
   MotionManager::GetInstance()->ResetGyroCalibration();

   printf("Press the ENTER key to begin!\n");
   getchar();

//////
    writeToLog(logFile,"started");

printf("0-Play\n");
printf("1-Kick\n");
printf("2-stand\n");
printf("3-Straight walking\n");
printf("4-Turn right\n");
printf("5-Turn left\n");
printf("6-stop walking\n");
printf("7-reset\n");
printf("8-GetTilt\n");
printf("9-SetTilt\n");
printf("q-Exit\n");

Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true);

	while(1)
	{
		char c =getchar();

		if (c == '0')
		{
			play();
		}
		else if (c == '1')
		{
			writeToLog(logFile,"kick");
			Action::GetInstance()->Start(2);
			while(Action::GetInstance()->IsRunning()) usleep(8*1000);
		}
		else if(c == '2')
		{
			writeToLog(logFile,"stand");
			Action::GetInstance()->Start(1);
			while(Action::GetInstance()->IsRunning()) usleep(8*1000);
		}
		else if(c == '3')
		{
			if(Walking::GetInstance()->IsRunning() == false )
			{
				fprintf(stderr, "STARTING\n");
				Action::GetInstance()->Start(9);
				while(Action::GetInstance()->IsRunning()) usleep(8*1000);
				//Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true);
				Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true,true);
				Walking::GetInstance()->X_MOVE_AMPLITUDE = 0;
				Walking::GetInstance()->Y_MOVE_AMPLITUDE = 0;
				Walking::GetInstance()->A_MOVE_AMPLITUDE = 0;
				Walking::GetInstance()->Start();
			}
			else
				Walking::GetInstance()->A_MOVE_AMPLITUDE = 0;
		}
		else if(c == '4')
		{
			if(Walking::GetInstance()->IsRunning() == true )
			{
				fprintf(stderr, "TURNING RIGHT\n");
				Walking::GetInstance()->A_MOVE_AMPLITUDE = -5;

			}
		}
		else if(c == '5')
		{
			if(Walking::GetInstance()->IsRunning() == true )
			{
				fprintf(stderr, "TURNING LEFT\n");
				Walking::GetInstance()->A_MOVE_AMPLITUDE = 5;
			}
		}
		else if(c == '6')
		{
			if(Walking::GetInstance()->IsRunning() == true )
			{
				fprintf(stderr, "STOPPING\n");		
				Walking::GetInstance()->Stop();
				while(Walking::GetInstance()->IsRunning() == 1) usleep(8000);
				Walking::GetInstance()->m_Joint.SetEnableBody(false);
				Head::GetInstance()->m_Joint.SetEnableBody(false);
				Action::GetInstance()->m_Joint.SetEnableBody(true);
				MotionManager::GetInstance()->SetEnable(true);
			}
		}
		else if(c == '7')
		{
			for(int i=JointData::ID_R_SHOULDER_PITCH; i<JointData::NUMBER_OF_JOINTS; i++)
											Reset(&cm730, i);

									Reset(&cm730, CM730::ID_CM);
		}
		else if(c == '8')
		{

			float tilt;
			tilt = GetTilt();
			printf("%f\n", tilt);

		}
		else if(c == '9')
		{
			float tilt,pan;
			cout<<"enter tilt\n";
			cin>>tilt;
			cout<<"enter pan\n";
			cin>>pan;
			SetTilt(pan,tilt);
		}
		else if(c == 'q')	
예제 #9
0
int main(int argc, char* argv[])
{
	START_EASYLOGGINGPP(argc, argv);

	Py_Initialize();
	PyRun_SimpleString("print pow(2, 3)");
	Py_Finalize();

	el::Configurations conf("config/logging.cfg");
	el::Loggers::reconfigureAllLoggers(conf);

	startLog();

	LOG(INFO) << "Initialising SFML Render Window with a resolution of " << windowWidth << "x" << windowHeight;

	LOG(INFO) << "IGNORE OPENGL MISSING EXTENSION!";

	sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), windowTitle, sf::Style::Close, settings);

	window.setVerticalSyncEnabled(false); // vsync messes with updates

	sf::View viewPort(sf::Vector2f(windowWidth / 2, windowHeight / 2), sf::Vector2f(windowWidth, windowHeight));

	// Initialise physics
	//b2Vec2 gravity(0.0f, 0.0f);
	//b2World world(gravity);

	// scripting init here!
	/*script::FalconEngine scripting;

	// load resource paths
	try
	{
		scripting.embed("resources.fal");
	}
	catch (Falcon::Error *err)
	{
		Falcon::AutoCString edesc(err->toString());
		LOG(FATAL) << edesc.c_str() << std::endl;
		err->decref();
		return 1;
	}

	try
	{
		scripting.embed("test.fal");
	}
	catch (Falcon::Error *err)
	{
		Falcon::AutoCString edesc(err->toString());
		LOG(FATAL) << edesc.c_str() << std::endl;
		err->decref();
		return 1;
	}*/
	

	texture.loadFromFile("data/abstract liquify thing.png");
	sprite.setTexture(texture);

	int testMusic = loadMusic("data/audio/music/Three_Days_Grace_-_The_High_Road_(mp3.pm).ogg");
	int channel2 = loadMusic("data/audio/music/Kygo - Firestone (feat. Conrad).ogg");
	int channel3 = loadMusic("data/audio/music/Seether - Broken (Featuring Amy Lee).ogg");
	int channel4 = loadMusic("data/audio/music/New Found Glory - This Disaster.ogg");
	int channel5 = loadMusic("data/audio/music/Story of the Year - Until the Day I Die.ogg");

	Player player(sf::Vector2f(windowWidth / 2, windowHeight / 2));
	
	FriendlyTrader test(sf::Vector2f(64, 128));

	sf::Clock clock;
	sf::Clock seconds;

	while (window.isOpen())
	{
		sf::Time elapsed = clock.getElapsedTime();

		bool fadeCompleted;

		if (elapsed.asMicroseconds() >= updateRate.asMicroseconds())
		{
			clock.restart();
			update(&window, &player, &viewPort);
			if (!getFadeCompleted())
			{
				fadeCompleted = true;
				//windowFade = fadeOut(&window);
			}
			test.Update();
		}
		elapsed = seconds.getElapsedTime();
		if (elapsed.asSeconds() >= 1)
		{
			UPS = tick;
			FPS = frame;

//#ifdef _DEBUG
			char windowTitle[128] = "SFML and Box2D";
			char buffer[8];
			strcat_s(windowTitle, " | ");
			_itoa_s(UPS, buffer, 10);
			strcat_s(windowTitle, "UPS: ");
			strcat_s(windowTitle, buffer);
			strcat_s(windowTitle, ", FPS: ");
			_itoa_s(FPS, buffer, 10);
			strcat_s(windowTitle, buffer);
			window.setTitle(windowTitle);
//#endif
			
			//std::cout << "UPS: " << UPS << ", FPS: " << FPS << std::endl;
			tick = 0;
			frame = 0;
			seconds.restart();
		}

		render(&window, viewPort);
	}

	LOG(INFO) << "Unloading SFML";
	
	sf::sleep(sf::seconds(0.5));
	//LogWhiteSpace();
	endLog();

	std::cout << std::endl;

	return 0;
}
예제 #10
0
int main(int argc, char *argv[])
{
	char *configuration = NULL;
	char *infile = NULL;
	char *outfile = NULL;
	char *verbose = NULL;
	int version_opt = 0;
	char *logdir = NULL;
	char *logfile = NULL;
	char *home = NULL;
	int help_opt = 0;

	int c;
	
	static struct option long_options[] = {
		{"configuration",	required_argument, 0, 'c'},
		{"silent", no_argument, 0, 1},
		{"verbose", no_argument, 0, 'v'},
		{"version", no_argument, 0, 'V'},
		{"logdir", required_argument, 0, 'l'},
		{"logfile", required_argument, 0, 'L'},
		{"home", required_argument, 0, 2},
		{"infile", required_argument, 0, 'i'},
		{"outfile", required_argument, 0, 'o'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}
	};

#ifdef XCP	
	int is_bash_exist = system("command -v bash");

	if ( is_bash_exist != 0 )
	{
		fprintf(stderr, "Cannot find bash. Please ensure that bash is "
				"installed and available in the PATH\n");
		exit(2);
	}
#endif

	strcpy(progname, argv[0]);
	init_var_hash();

	while(1) {
		int option_index = 0;

		c = getopt_long(argc, argv, "i:o:c:vVl:L:h", long_options, &option_index);

		if (c == -1)
			break;
		switch(c)
		{
			case 1:
				verbose = "n";
				break;
			case 2:
				if (home)
					free (home);
				home = strdup(optarg);
				break;
			case 'i':
				if (infile)
					free(infile);
				infile = strdup(optarg);
				break;
			case 'o':
				if (outfile)
					free(outfile);
				outfile = strdup(optarg);
				break;
			case 'v':
				verbose = "y";
				break;
			case 'V':
				version_opt = 1;
				break;
			case 'l':
				if (logdir)
					free(logdir);
				logdir = strdup(optarg);
				break;
			case 'L':
				if (logfile)
					free(logfile);
				logfile = strdup(optarg);
				break;
			case 'c':
				if (configuration)
					free(configuration);
				configuration = strdup(optarg);
				break;
			case 'h':
				help_opt = 1;
				break;
			default:
				fprintf(stderr, "Invalid optin value, received code 0%o\n", c);
				exit(1);
		}
	}
	if (version_opt || help_opt)
	{
		if (version_opt)
			print_version();
		if (help_opt)
			print_help();
		exit(0);
	}
	setup_my_env();		/* Read $HOME/.pgxc_ctl */
	build_pgxc_ctl_home(home);
	if (infile)
		reset_var_val(VAR_configFile, infile);
	if (logdir)
		reset_var_val(VAR_logDir, logdir);
	if (logfile)
		reset_var_val(VAR_logFile, logfile);
	startLog(sval(VAR_logDir), sval(VAR_logFile));
	prepare_pgxc_ctl_bash(pgxc_ctl_bash_path);
	build_configuration_path(configuration);
	read_configuration();
	check_configuration();
	/*
	 * Setop output
	 */
	if (outfile)
	{
		elog(INFO, "Output file: %s\n", outfile);
		if ((outF = fopen(outfile, "w")))
			dup2(fileno(outF),2);
		else
			elog(ERROR, "ERROR: Cannot open output file %s, %s\n", outfile, strerror(errno));
	}
	else
		outF = stdout;
	/* 
	 * Startup Message
	 */
	elog(NOTICE, "   ******** PGXC_CTL START ***************\n\n");
	elog(NOTICE, "Current directory: %s\n", pgxc_ctl_home);
	/*
	 * Setup input
	 */
	if (infile)
	{
		elog(INFO, "Input file: %s\n", infile);
		inF =  fopen(infile, "r");
		if(inF == NULL)
		{
			elog(ERROR, "ERROR: Cannot open input file %s, %s\n", infile, strerror(errno));
			exit(1);
		}
	}
	else
		inF = stdin;
	/*
	 * If we have remaing arguments, they will be treated as a command to do.  Do this
	 * first, then handle the input from input file specified by -i option.
	 * If it is not found, then exit.
	 */
#if 0
	print_vars();
#endif
	if (optind < argc)
	{
		char orgBuf[MAXLINE + 1];
		char wkBuf[MAXLINE + 1];
		orgBuf[0] = 0;
		while (optind < argc)
		{
			strncat(orgBuf, argv[optind++], MAXLINE);
			strncat(orgBuf, " ", MAXLINE);
		}
		strncpy(wkBuf, orgBuf, MAXLINE);
		do_singleLine(orgBuf, wkBuf);
		if (infile)
			do_command(inF, outF);
	}
	else
		do_command(inF, outF);
	exit(0);
}
예제 #11
0
void *agoMasterProcess()
{

  int i_workerId = 1, i_numBlocks = (NUM_BLOCKS - 1), i_offSetidPackage = 1, i_numBlocksOrig = NUM_BLOCKS, i_idFail = 0;

  unsigned int ui_sync1 = 0, ui_sync2 = 0, ui_loopMaster = FLAG_START, ui_timeSignal = 0, ui_workerList[NUM_WORKERS];

  double d_masterTime100 = 0.0, da_masterTime[4] = {0, 0, 0, 0}, d_countBlock = 0.0;

#if TURN_ON_OFF_FAIL == 1
  int    i_idFailTmp = 0, i_falhaPerc = 0;
  double d_timeFail = 0.0;
#endif

  Matrix *d_matrixA, *d_matrixB, *d_matrixC;

  agoDataPackageStr *agoDataPackageMaster;
  agoLogStr *agoLog;

  agoLog = (agoLogStr *) malloc (sizeof(agoLogStr));
  agoDataPackageMaster = (agoDataPackageStr *) calloc (sizeof(agoDataPackageStr), NUM_BLOCKS);

#ifdef VERBOSE
  if ((agoDataPackageMaster == NULL) || (agoLog == NULL)) {
    snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Erro Alocando Mem. agoDataPackageMaster ou agoLog - VERBOSE");
    registerLog(agoLog,  si_myidMaster);
  }
#endif

  startLog(agoLog, si_myidMaster);

  // Inicia o Pacote de Dados a serem processados
  // Informacoes Gerais do Processamento / Inicializando o Mestre
  (void) snprintf(agoLog->logMsg, LOG_SIZE,
                  "Tamanho Matriz: %d - Tamanho Pacote (Chunk): %d - Num de Pacotes: %d - Quantidade Workers: %d",
                  MAX_MATRIX_SIZE, CHUNKSIZE, i_numBlocks, (si_numprocsMaster - 1));
  registerLog(agoLog, si_myidMaster);

#ifdef VERBOSE
  (void) snprintf(agoLog->logMsg, LOG_SIZE,
                  "Tamanho Matriz: %d - %d bytes", sizeof(*d_matrixA), sizeof(*d_matrixB));
  registerLog(agoLog, si_myidMaster);
#endif

  // Aloca Memoria para as Matrizes
  d_matrixA = (Matrix *) malloc ((MAX_MATRIX_SIZE * MAX_MATRIX_SIZE) * sizeof(double));
  d_matrixB = (Matrix *) malloc ((MAX_MATRIX_SIZE * MAX_MATRIX_SIZE) * sizeof(double));
  d_matrixC = (Matrix *) malloc ((MAX_MATRIX_SIZE * MAX_MATRIX_SIZE) * sizeof(double));

  snprintf(agoLog->logMsg, LOG_SIZE, "Alocado Memoria para as Matrizes");
  registerLog(agoLog,  si_myidMaster);

#ifdef VERBOSE
  if ((d_matrixA == NULL) || (d_matrixB == NULL) || (d_matrixC == NULL)) {
    snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Erro Alocando Mem. Matrizes (A, B, C) - VERBOSE");
    registerLog(agoLog,  si_myidMaster);
  }
#endif

  matrixCreate(d_matrixA, d_matrixB, (MAX_MATRIX_SIZE * MAX_MATRIX_SIZE), si_myidMaster, agoLog);

#if TURN_ON_OFF_FAIL == 1
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(FT) - Tolerancia a Falhas Ativo - Mandando Sinal para %s\n", MASTER_ADDR_AGO_FT);
  registerLog(agoLog, si_myidMaster);
#else
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(FT) - Tolerancia a Falhas Nao Ativo\n");
  registerLog(agoLog, si_myidMaster);
#endif

  // Informacoes Gerais do Processamento / Inicializando o Mestre
  agoInitDataPackage(agoDataPackageMaster, NUM_BLOCKS, si_myidMaster, agoLog);

  i_workerId = 1;
  while (i_workerId < i_offSetidPackage) {
    agoDataPackageMaster[i_workerId].status = FLAG_DONE;
    i_workerId++;
  }

  ui_workerList[0] = 0;

  // Lista de Trabalhadores
  while (i_workerId < si_numprocsMaster) {
    ui_workerList[i_workerId] = i_workerId;
    i_workerId++;
  }

#ifdef VERBOSE
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoWorkerProcess) - Lista de Workers Concluida %d (%d) - (VERBOSE)",
                  i_workerId, si_numprocsMaster);
  registerLog(agoLog, si_myidMaster);

  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Numero de Blocos %d - (VERBOSE)", i_numBlocks);
  registerLog(agoLog, si_myidMaster);
#endif

  (void) snprintf(agoLog->logMsg, LOG_SIZE, "Iniciando Contagem do Tempo do Mestre Local");
  registerLog(agoLog, si_myidMaster);

  // Inicio Contagem de Tempo do Processo Mestre
  d_masterTime100 = MPI_Wtime();

  // Inicio Tarefa Mestre
  do {
    while (i_numBlocks) {
      // Sinaliza Inicio de Trabalho aos Workers
      agoSignalWorkers(ui_workerList, NUM_WORKERS, FLAG_START, 1, si_myidMaster, workerStatus_ago_ft, agoLog);

      (void) snprintf(agoLog->logMsg, LOG_SIZE, "Iniciando Envio de Pacotes para Workers (%d)\n",  (si_numprocsMaster - 1));
      registerLog(agoLog, si_myidMaster);

      // Envio de Dados para Trabalhadores
      agoSendDataToWorker(agoDataPackageMaster, i_numBlocksOrig, d_matrixA, d_matrixB, &i_offSetidPackage,
                          ui_workerList, NUM_WORKERS, 1, i_idFail, si_myidMaster, workerStatus_ago_ft, agoLog);


      (void) snprintf(agoLog->logMsg, LOG_SIZE, "Bloco(s) Distribuido(s) para os Workers (%d)\n",  (si_numprocsMaster - 1));
      registerLog(agoLog, si_myidMaster);

#if TURN_ON_OFF_FAIL == 1
      if (i_idFail > 0) {
        i_falhaPerc = ui_timeSignal;
        d_timeFail = (MPI_Wtime() - d_masterTime100);

        (void) snprintf(agoLog->logMsg, LOG_SIZE, "Introducao da Falha Completa - worker id %d no tempo %f",  i_idFail, d_timeFail);
        registerLog(agoLog, si_myidMaster);

        sleep(WAIT_TIME_FAIL_AGO_FT);

        d_masterTime100 = (d_masterTime100 - WAIT_TIME_FAIL_AGO_FT);
        i_idFailTmp = i_idFail;
        i_idFail = 0;
      }
#endif

      i_workerId = 1;
      while (i_workerId < si_numprocsMaster) {
#ifdef VERBOSE
        (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - worker id %d (%d) - (VERBOSE)",
                        i_workerId, ui_workerList[i_workerId]);
        registerLog(agoLog, si_myidMaster);
#endif

        agoRecvDataFromWorker(agoDataPackageMaster, d_matrixC, ui_workerList, si_myidMaster, agoLog);

        d_countBlock++;
        i_workerId++;

        agoGetCount(&ui_timeSignal, i_numBlocksOrig, d_countBlock, d_masterTime100, da_masterTime, si_myidMaster, agoLog);

#ifdef VERBOSE
        (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Blocos Recebidos %f - worker id %d - (VERBOSE)",
                        d_countBlock, i_workerId);
        registerLog(agoLog, si_myidMaster);
#endif
      }

      i_numBlocks = i_numBlocks - (si_numprocsMaster - 1);

#if TURN_ON_OFF_FAIL == 1
      if (reconfigWorker_ago_ft == 1) {
        (void) snprintf(agoLog->logMsg, LOG_SIZE, "(FT) - Ocorreu uma Falha: %d Ativos", (si_numprocsMaster - 1));
        registerLog(agoLog, si_myidMaster);
      }
#endif

      (void) snprintf(agoLog->logMsg, LOG_SIZE, "Faltam %d Bloco(s) a serem Distribuido(s) para os Workers (%d)\n",
                      i_numBlocks, (si_numprocsMaster - 1));
      registerLog(agoLog, si_myidMaster);

      if ((i_numBlocks < (si_numprocsMaster - 1)) && (i_numBlocks > 0)) {
        if ((ui_sync1 == 0)
#if TURN_ON_OFF_FAIL == 1
            && (reconfigWorker_ago_ft == 0)
#endif
           ) {
          ui_sync1 = ui_sync2 = (i_numBlocks + 1);

          agoSignalWorkers(ui_workerList, ui_sync2, FLAG_START, 1, si_myidMaster, workerStatus_ago_ft, agoLog);

          (void) snprintf(agoLog->logMsg, LOG_SIZE, "Iniciando Envio de Pacotes para Workers (%d)\n",  (si_numprocsMaster - 1));
          registerLog(agoLog, si_myidMaster);

          i_idFail = 0;
          agoSendDataToWorker(agoDataPackageMaster, i_numBlocksOrig, d_matrixA, d_matrixB, &i_offSetidPackage,
                              ui_workerList, ui_sync2, 1, i_idFail, si_myidMaster, workerStatus_ago_ft, agoLog);


          (void) snprintf(agoLog->logMsg, LOG_SIZE, "Bloco(s) Distribuido(s) para os Workers (%d)\n",  (si_numprocsMaster - 1));
          registerLog(agoLog, si_myidMaster);

          i_workerId = 1;

          while (i_workerId < (int) ui_sync2) {
            agoRecvDataFromWorker(agoDataPackageMaster, d_matrixC, ui_workerList, si_myidMaster, agoLog);
            d_countBlock++;
            i_workerId++;

            agoGetCount(&ui_timeSignal, i_numBlocksOrig, d_countBlock, d_masterTime100, da_masterTime, si_myidMaster, agoLog);
          }
          i_numBlocks = 0;
        }
#if TURN_ON_OFF_FAIL == 1
        if (reconfigWorker_ago_ft == 1) {
          i_numBlocks = 0;
        }
#endif
      }

#if TURN_ON_OFF_FAIL == 1
      i_idFail = agoPutFaultOnWorker(ui_timeSignal, agoLog);
#endif
    }
    // Termina o Thread para Verificar Falhas atraves de Socket
#if TURN_ON_OFF_FAIL == 1
    syncWorker_ago_ft = waitWorker_ago_ft = FLAG_STOP;
#endif

    // Se foi detectado erro (reconfigWorker_ago_ft = 1) reconfigure o Cluster
#if TURN_ON_OFF_FAIL == 1
    if (reconfigWorker_ago_ft == 1) {
      agoReconfigCluster(agoDataPackageMaster, d_matrixA, d_matrixB, d_matrixC, ui_workerList, i_numBlocksOrig, agoLog);
    }
#endif

    ui_loopMaster = FLAG_STOP;

  } while (ui_loopMaster);

  agoSignalWorkers(ui_workerList, NUM_WORKERS, FLAG_STOP, 1, si_myidMaster, workerStatus_ago_ft, agoLog);

  // Finaliza Contagem de Tempo do Processo Mestre
  d_masterTime100 = (MPI_Wtime() - d_masterTime100);

  (void) snprintf(agoLog->logMsg, LOG_SIZE, "Finalizado a Contagem do Tempo (%f) do Mestre Local\n", d_masterTime100);
  registerLog(agoLog, si_myidMaster);

#if TURN_ON_OFF_FAIL == 1
  // Termina o Thread o i_syncMaster (Servidor Sinalizacao)
  masterSocketLoop_ago_ft = FLAG_STOP;
#endif

  free(d_matrixA);
  free(d_matrixB);
  free(d_matrixC);
  free(agoDataPackageMaster);

#ifdef VERBOSE
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Liberado (free) memoria alocada (A, B, C) - (VERBOSE)");
  registerLog(agoLog, si_myidMaster);
#endif

  (void) snprintf(agoLog->logMsg, LOG_SIZE,
                  "Tempo de Processamento\n - Tempo 25%%: %f\n - Tempo 50%%: %f\n - Tempo 75%%: %f\n - Tempo 95%%: %f",
                  da_masterTime[PERCENT_25], da_masterTime[PERCENT_50], da_masterTime[PERCENT_75], da_masterTime[PERCENT_95]);
  registerLog(agoLog, si_myidMaster);

  (void) snprintf(agoLog->logMsg, LOG_SIZE, "Finalizado - Tempo Total Local (100%%): %f", d_masterTime100);
  registerLog(agoLog, si_myidMaster);

#if TURN_ON_OFF_FAIL == 1
  if (reconfigWorker_ago_ft == 1) {
    (void) snprintf(agoLog->logMsg, LOG_SIZE, "Falha no id %d introduzida com (%d%%) do trabalho no tempo: %f",
                    i_idFailTmp, i_falhaPerc, d_timeFail);
    registerLog(agoLog, si_myidMaster);

    (void) snprintf(agoLog->logMsg, LOG_SIZE, "Finalizado - Tempo Total (100%%) Com Falha: %f", d_masterTime100);
    registerLog(agoLog, si_myidMaster);
  }
#endif

#ifdef VERBOSE
#if TURN_ON_OFF_FAIL == 1
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Tolerancia a Falha Ativo - (VERBOSE)");
  registerLog(agoLog, si_myidMaster);
#else
  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Tolerancia a Falha Nao Ativo - (VERBOSE)");
  registerLog(agoLog, si_myidMaster);
#endif

  (void) snprintf(agoLog->logMsg, LOG_SIZE, "(agoMasterProcess) - Chamando MPI_Finalize - (VERBOSE)");
  registerLog(agoLog, si_myidMaster);
#endif

  closeLog(agoLog);
  free(agoLog);

  return(NULL);
}
예제 #12
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Errors ret = CommonData::getInstance()->readIni();
    switch (ret) {
        case INIFILE_NOTFOUND: {
            qWarning() << "File ini non trovato";
        }
            break;
        case INIFILE_WRONG: {
            qWarning() << "File ini errato";
        }
            break;
        case INIFILE_NOERR: {
            //tutto ok
        }
            break;
    }

    //inizia il logging
    startLog();

    //mette nel log (trace) il nome dell'applicazione
    Log::Logger::getInstance()->log(CommonData::getInstance()->getAppId(), Log::TRACE);

    /* splash screen */
    QPixmap pixmap(":/icons/splash.png");
    splash = new QSplashScreen(pixmap);



    splash->show();
    splash->showMessage("Wait...", Qt::AlignBottom|Qt::AlignRight);
    a.processEvents();//This is used to accept a click on the screen so that user can cancel the screen

    MainWindow w;

    /*
    QFile styleSheet("style.css");
    if (styleSheet.open(QIODevice::ReadOnly)) {
        w.setStyleSheet(styleSheet.readAll());
    }
    styleSheet.close();
    */

    //chiude lo splash screen
    splash->finish(&w);

    w.showMaximized();
    //w.show();
    if (ret == INIFILE_WRONG) {
        /* todo aprire la finestra opzioni */
        w.on_actionOpzioni_triggered();
    }

    int x = a.exec();
    if (splash != NULL)
    {
        delete splash;
        splash = NULL;
    }
    //qWarning() << x;
    return x;
}