当前位置: 首页>>代码示例>>C++>>正文


C++ slave函数代码示例

本文整理汇总了C++中slave函数的典型用法代码示例。如果您正苦于以下问题:C++ slave函数的具体用法?C++ slave怎么用?C++ slave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了slave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Control

TestControl::TestControl(const InputParameters & parameters)
  : Control(parameters), _test_type(getParam<MooseEnum>("test_type")), _alias("this/is/alias")
{
  if (_test_type == "real")
    getControllableValue<Real>("parameter");

  else if (_test_type == "variable")
    getControllableValue<NonlinearVariableName>("parameter");

  else if (_test_type == "tid_warehouse_error")
    _fe_problem.getControlWarehouse().initialSetup(12345);

  else if (_test_type == "disable_executioner")
    getControllableValue<bool>("parameter");

  else if (_test_type == "connection")
  {
    MooseObjectParameterName master(MooseObjectName("Kernels", "diff"), "coef");
    MooseObjectParameterName slave(MooseObjectName("BCs", "left"), "value");
    _app.getInputParameterWarehouse().addControllableParameterConnection(master, slave);
  }

  else if (_test_type == "alias")
  {
    MooseObjectParameterName slave(MooseObjectName("BCs", "left"), "value");
    _app.getInputParameterWarehouse().addControllableParameterConnection(_alias, slave);
  }

  else if (_test_type == "mult")
    getControllableValue<Real>("parameter");

  else if (_test_type != "point")
    mooseError("Unknown test type.");
}
开发者ID:zachmprince,项目名称:moose,代码行数:34,代码来源:TestControl.C

示例2: main

int main(int argc, char **argv) 
{
  int rank, comm_sz, r_status;
  
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
  
  // MPI_Errhandlerset(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

  if (argc != 2) {
    fprintf(stderr, "Usage: krig n_iter\n");
    exit(1);
  }
  int n = atoi(argv[1]);
  if (rank == 0)
    printf("Begin %d iterations of %d processes\n", n, comm_sz);
  int i;
  for (i = 0; i < n; i++) {   
    slave(rank, comm_sz);
  }
  
  if (errno)
    perror("pre-finalize");
  if (MPI_Finalize() != 0) {
      perror("MPI_Finalize");
  }

  return 0;
}
开发者ID:the-fool,项目名称:fastGIS,代码行数:30,代码来源:mpikrig.c

示例3: main

int main(void) {
#else
int main(int argc, char **argv) {
#endif

#ifdef __patmos__
  // nothing special to initialize
#else /* __patmos__ */
  core_id = strtol(argv[1], NULL, 0);
  // initialize MPBs
  shm_init();
#endif /* __patmos__ */

  if (core_id == 0) {
    master();
  } else {
    slave();
  }

#ifdef __patmos__
  // nothing to clean up
#else /* __patmos__ */
  shm_clean();
#endif /* __patmos__ */

  return 0;

}
开发者ID:invisibleboy,项目名称:patmos,代码行数:28,代码来源:mandelbrot_par.c

示例4: main

int main ()
{
    I2CSlave slave(I2C_SDA, I2C_SCL);
    
    char buf[10];
    char msg[] = "Slave!";

    slave.address(LM75_ADDR);
    while (1) {
        int i = slave.receive();
        switch (i) {
            case I2CSlave::ReadAddressed:
                slave.write(msg, strlen(msg) + 1); // Includes null char
                //printf ( "read me %s.\n", msg );
                break;
            case I2CSlave::WriteGeneral:
                slave.read(buf, 3);
                //printf("Read G: %s\n", buf);
                break;
            case I2CSlave::WriteAddressed:
                slave.read(buf, 3);
                //printf("Read A: %s\n", buf);
                break;
            default:
                //printf ( "unknown ins: %d\n", i );
                //slave.stop ();
                break;
        }
        for(int i = 0; i < 10; i++) buf[i] = 0;    // Clear buffer
        
        myled = !myled;
        //wait (2);
    }
}
开发者ID:dotnfc,项目名称:arducleo,代码行数:34,代码来源:i2c_master_main.cpp

示例5: main

int main(int argc, char **argv)
{

    /* Initialize MPI */
    MPI_Init(&argc, &argv);
  
    /* Find out my identity in the default communicator */
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    /*************** SPRNG Initialization *************************/
      //init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
      //init_sprng(SPRNG_LCG, 1938 , SPRNG_DEFAULT);
	// srand(1938);
	time_t curTime = time(0);
#ifndef _NO_SPRNG
      //init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
	CSE::Math::Seeder(static_cast<unsigned int>(curTime), curTime);
#else
	CSE::Math::Seeder(static_cast<unsigned int>(curTime)*myrank, curTime);
#endif    
    //srand(static_cast<unsigned int>(curTime)*myrank);
    //printf("Process %d, print information about stream:\n", myid);
    //print_sprng();

    if (myrank == 0)
        master();
    else
        slave();

    /* Shut down MPI */
    MPI_Finalize();
  
    return 0;
}
开发者ID:Azhag,项目名称:master-thesis,代码行数:34,代码来源:parallel.cpp

示例6: main

int main(int argc, char *argv[]) {
    int    proc_id;       // Process ID number
    int    n_proc;        // Number of processes
    int    n_rows = 1000; // Number of rows
    int    n_cols = 1000; // Number of columns

    // Initialize MPI
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &n_proc);
    MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);

    if (n_proc == 1) {
        puts("Error: requires two or more processes (no work will be done).");
        MPI_Finalize();
        exit(1);
    }

    if (proc_id == MASTER) {
        master(n_proc, n_rows, n_cols);
    }
    else {
        slave(proc_id, n_rows, n_cols);
    }

    MPI_Finalize();
    return 0;
}
开发者ID:gnu-user,项目名称:mcsc-6030-assignments,代码行数:27,代码来源:matvec.c

示例7: main

main(int argc, char* argv[]) {

  int myrank;

  /* read in command-line arguments and check validity */
  if ( argc < 3 ) {
    printf( "usage: %s <matrix_size> <block_size>\n", argv[0] ) ;
    exit( -1 );
  } else {
    matrix_size = atoi( argv[1] ) ;
    block_size = atoi( argv[2] ) ;
    if ( (matrix_size == 0) || (block_size == 0) ||
	 ((matrix_size-((matrix_size/block_size)*block_size)) != 0) ) {
      printf( "arguments do not satisfy program assumptions:\n"
	      "\t matrix_size > 0, block_size > 0, and\n"
	      "\t block_size perfectly divides matrix_size\n" ) ;
      exit( -1 ) ;
    }
  }

  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);

  if (myrank==0) {
    master();
  } else {
    slave();
  }

  MPI_Finalize();
}
开发者ID:ameena3,项目名称:Anubhav_projects,代码行数:31,代码来源:luf.c

示例8: main

void main(int argc, char *argv[])
{
    char *str1 = "master";
    char *str2 = "slave";
    if(argc == 2)
        printf("The argument supplied is %s\n", argv[1]);
    else if(argc > 2)
    {
        printf("Too many arguments\n");
        exit(0);
    }
    else
    {
        printf("One argument expected (slave/master)\n");
        exit(0);
    }
    if(strcmp(argv[1], str1) == 0)
    {
        printf("This instance of the program will take the role as master\n");
        master();
    }
    else if (strcmp(argv[1], str2) == 0)
    {
        printf("This instance of the program will take the role as slave\n");
        slave();
    }
}
开发者ID:gablank,项目名称:NTNU,代码行数:27,代码来源:finaltest.c

示例9: main

int main(int argc, char *argv[])
{
  Slave slave(argc, argv);

  QStringList args = QCoreApplication::arguments();

  if (args.contains("--help")
   || args.contains("-h")) {
    printf("Usage: %s [ip of relay server]\n",
      qPrintable(QFileInfo(argv[0]).baseName()));
    return 0;
  }

  if (!slave.init()) {
	qFatal("Failed to init slave class. Exiting..");
	return 1;
  }

  QString relay = "127.0.0.1";
  if (args.length() > 1) {
	relay = args.at(1);
  }

  slave.connect(relay, 8500);

  return slave.exec();
}
开发者ID:snowcap-electronics,项目名称:snowcap-controller,代码行数:27,代码来源:main.cpp

示例10: main

/* Main */
int main(int argc, char *argv[])
{
    int rank;
    int size;
    /* Initialize MPI */
    if(MPI_Init(&argc, &argv) != MPI_SUCCESS)
    {
        fprintf(stderr, "Unable to initialize MPI!\n");
        return -1;
    }
    /* Get rank and size */
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    

    /* Populate the parameters with default values */
    Params p;

    /* Don't be verbose by default */
    p.verbose = 0;
    p.rank = rank;

    // Used for cleaner code later on
    p.size = size - 1;
    
    p.array_size = DEFAULT_ARRAY_SIZE;
    p.max_num = MAX_NUM_SIZE;
    /* Check for user options */
    parse_args(argc,argv,&p);
    slave(&p);
    MPI_Finalize();
    return 0;

}
开发者ID:Cristianf,项目名称:MPI-Examples,代码行数:35,代码来源:bucket_sort_pipeline.c

示例11: main

int main(int argc, char **argv)
{

    /* Initialize MPI */
    MPI_Init(&argc, &argv);

    /* Find out my identity in the default communicator */
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    /*************** SPRNG Initialization *************************/
    time_t curTime = time(0);
#ifndef _NO_SPRNG
    init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
#else
    CSE::Math::Seeder(static_cast<unsigned int>(curTime)*myrank, curTime);
#endif

    if (myrank == 0)
        master();
    else
        slave();

    /* Shut down MPI */
    MPI_Finalize();

    return 0;
}
开发者ID:Azhag,项目名称:master-thesis,代码行数:27,代码来源:parallel.cpp

示例12: main

task main()
{
	//waitForStart();// Waiting for start command from FCS
	while(true)// Command recieved start loop untill FCS closes program
	{
		g = SensorValue(Gyro);
		i = SensorValue(IR);
  	getJoystickSettings(joystick); //Refresh joystick values

  	if (joy1Btn(6) || joy1Btn(8)) {drive_power = drive_max_power;} //If joystick 1 button TR or BR are pushed set drive power to boost mode, otherwise set it to normal power
		else {drive_power = drive_min_power;} //If joystick 1 button TR or BR are pushed set drive power to boost mode, otherwise set it to normal power

		initial_power(); //Set the global power values

		if (joy1Btn(7) || joy1Btn(5)) {inverse_slave();} //If joystick 1 button RL or BL are pushed run the subrutine to rotate in place

		if (joy1Btn(3) || joy2Btn(3)) {reset();} //If joystick 1 or joystick 2 push the red b button set all motor speeds to 0 unitll release

		if (joy1Btn(1) || joy1Btn(2)) {slave();} //If joystick 1 button A or X are pressed, slave the two drive motors together

		if (joy2Btn(5)) {paddeler(1);} //If joystick 2 button TL is pushed, move the paddles at speed tower_paddle_power

		if (joy2Btn(7)) {paddeler(-1);} //If joystick 2 button TL is pushed, move the paddles at negative speed tower_paddle_power

		if (joy2Btn(2)) {tower_flag = tower_flag_power;} //If joystick 2 button A is pressed, run flag motor forward

		if (joy2Btn(4)) {tower_flag = -1* tower_flag_power;} //If joystick 2 button Y is pressed, run flag motor backwards

		send_debug();//Send Debugging info to debugger nxt
		enact_power();//Enact the power variables layed out by the previous subrutines
  }
}
开发者ID:ratchetrobotics,项目名称:Old-Code-Archive,代码行数:32,代码来源:FTC+RC+V7.c

示例13: main

int main(int argc, char* argv[])
{
	int proc_id;            // Process rank
	int n_proc;             // Number of processes

	// Initialize MPI
	MPI_Init(&argc, &argv);

	// Get the current process id
	MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);

	// Get the current number of processes
	MPI_Comm_size(MPI_COMM_WORLD, &n_proc);

	if (proc_id == MASTER)
	{
			master(n_proc);
	}
	else
	{
			slave(proc_id);
	}

	// Required to terminate all MPI processes
	MPI_Finalize();
	return 0;
}
开发者ID:Taylor-J-Smith,项目名称:OS-Tutorial,代码行数:27,代码来源:A-Question3.c

示例14: switch

void RoomPropertySetter::parseProperty(const QByteArray &command, const Coordinate &roomPos)
{
    QList<QByteArray> words = command.simplified().split(' ');
    AbstractAction *action = 0;
    QByteArray property = words[1];
    uint pos = propPositions[property];
    if (words.size() == 4) {
        //change exit property
        ExitDirection dir = Mmapper2Exit::dirForChar(words[2][0]);
        switch (pos) {
        case E_FLAGS:
        case E_DOORFLAGS:
            action = new ModifyExitFlags(fieldValues[property], dir, pos, FMM_TOGGLE);
            break;
        case E_DOORNAME:
            action = new UpdateExitField(property, dir, pos);
            break;
        default:
            emit sendToUser("unknown property: " + property + "\r\n");
            return;
        }
    } else if (words.size() == 3) {
        //change room property
        switch (pos) {
        case R_TERRAINTYPE:
            action = new UpdatePartial(fieldValues[property], pos);
            break;
        case R_NAME:
        case R_DESC:
            action = new UpdatePartial(property, pos);
            break;
        case R_MOBFLAGS:
        case R_LOADFLAGS:
            action = new ModifyRoomFlags(fieldValues[property], pos, FMM_TOGGLE);
            break;
        case R_DYNAMICDESC:
        case R_NOTE:
            action = new UpdateRoomField(property, pos);
            break;
        case R_PORTABLETYPE:
        case R_LIGHTTYPE:
        case R_ALIGNTYPE:
        case R_RIDABLETYPE:
            action = new UpdateRoomField(fieldValues[property], pos);
            break;
        default:
            emit sendToUser("unknown property: " + property + "\r\n");
            return;
        }

        RoomPropertySetterSlave slave(action);
        emit lookingForRooms(&slave, roomPos);

        if (slave.getResult()) {
            emit sendToUser("OK\r\n");
        } else {
            emit sendToUser("setting " + property + " failed!\r\n");
        }
    }
}
开发者ID:midoc,项目名称:MMapper,代码行数:60,代码来源:roompropertysetter.cpp

示例15: kdemain

int kdemain( int argc, char **argv )
{
  KAboutData aboutData ( ABOUT_APP_NAME,
                         ABOUT_CATALOG_NAME,
                         ki18n(ABOUT_PROGRAM_NAME),
                         ABOUT_VERSION,
                         ki18n(ABOUT_DESCRIPTION),
                         ABOUT_LICENCE_TYPE,
                         ki18n(ABOUT_COPYRIGHT),
                         ki18n(ABOUT_INFORMATION),
                         ABOUT_WEBPAGE,
                         ABOUT_EMAIL );
  KComponentData componentData ( aboutData );

  QCoreApplication app( argc, argv );

  if (argc != 4)
  {
    fprintf(stderr, i18n("Usage: ").arg("kio_klipper protocol domain-socket1 domain-socket2\n").toUtf8() );
    exit(-1);
  }

  kDebug() << QString("started kio slave '%1' with PID %2").arg(argv[0]).arg(getpid());
  KIO_CLIPBOARD::KIOKlipperProtocol slave(argv[2], argv[3]);
  slave.dispatchLoop();

  kDebug() << "slave done";
  return ( 0 );
} // kdemain
开发者ID:arkascha,项目名称:kio-clipboard,代码行数:29,代码来源:kio_klipper.cpp


注:本文中的slave函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。