예제 #1
0
파일: application.cpp 프로젝트: AoD314/pat
	void Application::algorithm(std::string name)
	{
		//emit print_log("create algorithm: " + name);

		if (name.compare("rnd") == 0)
		{
			if (alg == 0 && sp == 0)
			{
				sp = new SpaceParam(1024);
				alg = new RND(sp);
				connect(alg, SIGNAL(run_application(Point)),     this, SLOT(run_app(Point)));
				connect(alg, SIGNAL(publish_result(FunctionND)), this, SLOT(publish_result(FunctionND)));
                connect(alg, SIGNAL(update_status(Status)),      this, SLOT(update_status(Status)));
			}
		}
		else if (name.compare("bf") == 0)
		{
			if (alg == 0 && sp == 0)
			{
				sp = new SpaceParam(1024);
				alg = new BruteForce(sp);
				connect(alg, SIGNAL(run_application(Point)),     this, SLOT(run_app(Point)));
				connect(alg, SIGNAL(publish_result(FunctionND)), this, SLOT(publish_result(FunctionND)));
                connect(alg, SIGNAL(update_status(Status)),      this, SLOT(update_status(Status)));
            }
		}
		else if (name.compare("gr") == 0)
		{
			if (alg == 0 && sp == 0)
			{
				sp = new SpaceParam(1024);
				alg = new Gradient(sp);
				connect(alg, SIGNAL(run_application(Point)),     this, SLOT(run_app(Point)));
				connect(alg, SIGNAL(publish_result(FunctionND)), this, SLOT(publish_result(FunctionND)));
                connect(alg, SIGNAL(update_status(Status)),      this, SLOT(update_status(Status)));
            }
		}			
		else if (name.compare("dhs") == 0)
		{
			if (alg == 0 && sp == 0)
			{
				sp = new SpaceParam(1024);
				alg = new Downhill_Simplex(sp);
				connect(alg, SIGNAL(run_application(Point)),     this, SLOT(run_app(Point)));
				connect(alg, SIGNAL(publish_result(FunctionND)), this, SLOT(publish_result(FunctionND)));
                connect(alg, SIGNAL(update_status(Status)),      this, SLOT(update_status(Status)));
            }
		}
	}
예제 #2
0
static void lowLevelUsbCheck( void )
{
  PMC->PMC_PCER0 = (1<<ID_PIOC)	;	// Enable clock to PIOC
	PIOC->PIO_PER = PIO_PC25 ;		// Enable bit C25 (USB-detect)

	uint32_t i ;
	for ( i = 0 ; i < 50 ; i += 1 )
	{
		__asm("nop") ;
	}

	for ( i = 0 ; i < 10 ; i += 1 )
	{
		if ( PIOC->PIO_PDSR & 0x02000000 )
		{
  		PMC->PMC_PCDR0 = (1<<ID_PIOC)	;	// Disable clock to PIOC
			dispUSB() ;
			sam_bootx() ;
		}
	}

	uint32_t x = initReadTrims() ;
	if ( ( x & 0x42 ) != 0x42 )
	{
		run_application() ;
//		loadAndRunBoot() ;
	}
}
예제 #3
0
파일: main.c 프로젝트: osrf/wandrr
int main()
{
  led_init();
  led_on();
  systime_init();
  console_init();
  puts("===== BL RESET =====\r\n");
  uint32_t t_last_blink = SYSTIME;
  uint32_t t_start = SYSTIME;
  #define BLINK_HALF_PERIOD  100000
  #define BOOT_TIMEOUT       200000

  while (1)
  {
    if (SYSTIME - t_last_blink > BLINK_HALF_PERIOD)
    {
      t_last_blink += BLINK_HALF_PERIOD;
      led_toggle();
    }
    if (/*g_rs485_boot_requested ||*/
        (SYSTIME - t_start > BOOT_TIMEOUT /*&& !flash_writes_occurred()*/))
    {
      run_application();
    }
  }
  return 0;
}
예제 #4
0
int application::run(int argc, char* argv[])
{
    try
    {
        return run_application(argc, argv);
    }
    catch(std::exception const& e)
    {
        std::cerr << e.what() << std::endl;
    }

    return EXIT_FAILURE;
}
예제 #5
0
int main(int argc, char** argv)
{
  if (argc != 3)
  {
    std::cout << "Arguments are <socket mysqld> <connect_string cluster>.\n";
    exit(-1);
  }
  // ndb_init must be called first
  ndb_init();

  // connect to mysql server and cluster and run application
  {
    char * mysqld_sock  = argv[1];
    const char *connectstring = argv[2];
    // Object representing the cluster
    Ndb_cluster_connection cluster_connection(connectstring);

    // Connect to cluster management server (ndb_mgmd)
    if (cluster_connection.connect(4 /* retries               */,
				   5 /* delay between retries */,
				   1 /* verbose               */))
    {
      std::cout << "Cluster management server was not ready within 30 secs.\n";
      exit(-1);
    }

    // Optionally connect and wait for the storage nodes (ndbd's)
    if (cluster_connection.wait_until_ready(30,0) < 0)
    {
      std::cout << "Cluster was not ready within 30 secs.\n";
      exit(-1);
    }

    // connect to mysql server
    MYSQL mysql;
    if ( !mysql_init(&mysql) ) {
      std::cout << "mysql_init failed\n";
      exit(-1);
    }
    if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
			     0, mysqld_sock, 0) )
      MYSQLERROR(mysql);
    
    // run the application code
    run_application(mysql, cluster_connection);
  }

  ndb_end(0);

  return 0;
}
예제 #6
0
파일: algorithm.cpp 프로젝트: AoD314/pat
	FunctionND Algorithm::function(const Point &point)
	{
		*lock = 1;

		emit run_application(point);

		QEventLoop loop;
		while (*lock != 0)
		{
			loop.processEvents();
		}

		function_nd.point = point;
		return function_nd;
	}
예제 #7
0
파일: main.cpp 프로젝트: 4T-Shirt/mysql
int main(int argc, char** argv)
{
  if (argc != 5)
  {
    std::cout << "Arguments are <socket mysqld1> <connect_string cluster 1> <socket mysqld2> <connect_string cluster 2>.\n";
    exit(-1);
  }
  // ndb_init must be called first
  ndb_init();
  {
    char * mysqld1_sock  = argv[1];
    const char *connectstring1 = argv[2];
    char * mysqld2_sock = argv[3];
    const char *connectstring2 = argv[4];
    
    // Object representing the cluster 1
    Ndb_cluster_connection cluster1_connection(connectstring1);
    MYSQL mysql1;
    // Object representing the cluster 2
    Ndb_cluster_connection cluster2_connection(connectstring2);
    MYSQL mysql2;
    
    // connect to mysql server and cluster 1 and run application
    // Connect to cluster 1  management server (ndb_mgmd)
    if (cluster1_connection.connect(4 /* retries               */,
				    5 /* delay between retries */,
				    1 /* verbose               */))
    {
      std::cout << "Cluster 1 management server was not ready within 30 secs.\n";
      exit(-1);
    }
    // Optionally connect and wait for the storage nodes (ndbd's)
    if (cluster1_connection.wait_until_ready(30,0) < 0)
    {
      std::cout << "Cluster 1 was not ready within 30 secs.\n";
      exit(-1);
    }
    // connect to mysql server in cluster 1
    if ( !mysql_init(&mysql1) ) {
      std::cout << "mysql_init failed\n";
      exit(-1);
    }
    if ( !mysql_real_connect(&mysql1, "localhost", "root", "", "",
    			     0, mysqld1_sock, 0) )
      MYSQLERROR(mysql1);
    
    
    // connect to mysql server and cluster 2 and run application
    
    // Connect to cluster management server (ndb_mgmd)
    if (cluster2_connection.connect(4 /* retries               */,
				    5 /* delay between retries */,
				    1 /* verbose               */))
    {
      std::cout << "Cluster 2 management server was not ready within 30 secs.\n";
      exit(-1);
    }
    // Optionally connect and wait for the storage nodes (ndbd's)
    if (cluster2_connection.wait_until_ready(30,0) < 0)
    {
      std::cout << "Cluster 2 was not ready within 30 secs.\n";
      exit(-1);
    }
    // connect to mysql server in cluster 2
    if ( !mysql_init(&mysql2) ) {
      std::cout << "mysql_init failed\n";
      exit(-1);
    }
    if ( !mysql_real_connect(&mysql2, "localhost", "root", "", "",
    			     0, mysqld2_sock, 0) )
      MYSQLERROR(mysql2);
    
    // run the application code
    run_application(mysql1, cluster1_connection, "MYTABLENAME1", "TEST_DB_1");
    run_application(mysql2, cluster2_connection, "MYTABLENAME2", "TEST_DB_2");
  }
  // Note: all connections must have been destroyed before calling ndb_end()
  ndb_end(0);

  return 0;
}