int Trick::InputProcessor::process_sim_args() { int i ; int argc ; char ** argv ; argc = command_line_args_get_argc() ; argv = command_line_args_get_argv() ; input_file = command_line_args_get_input_file() ; /* Process all other calling arguments */ for (i = 2; i < argc; i++) { /* * If there are more than 2 calling arguments */ if (!strncmp("-d", argv[i], (size_t) 2)) { /* Set the 'input verification only' and echo input flags */ verify_input = 1 ; } } return(0) ; }
int Trick::MonteCarlo::process_sim_args() { int argc = command_line_args_get_argc() ; char **argv = command_line_args_get_argv() ; if (argc > 2) { for (int i = 2; i < argc; ++i) { if (!strncmp("--monte_host", argv[i], 12)) { connection_device.hostname = strdup(argv[++i]); } else if (!strncmp("--monte_sync_port", argv[i], 17)) { sscanf(argv[++i], "%d", &master_port); } else if (!strncmp("--monte_client_id", argv[i], 12)) { sscanf(argv[++i], "%d", &slave_id); } } } return 0; }
int Trick::Sie::process_sim_args() { int argc ; char ** argv ; argc = command_line_args_get_argc() ; argv = command_line_args_get_argv() ; if (argc >= 2) { if (!strcmp(argv[1], "sie")) { /* If main is being invoked by the configuration processor (cp) to generate the sie resource file... */ /* Generate the sie resource file */ sie_print_xml(); std::cout << "Created S_sie.resource file." << std::endl ; // Silently exit the sim without printing the termination message exit(0) ; } } return(0) ; }
int Trick::SlaveInfo::start() { int arg_i; char *display; std::stringstream startup_command ; std::stringstream temp_stream ; struct passwd *passp; int argc ; char ** argv ; std::string slave = "undefined"; /** @par Detailed Design */ argc = command_line_args_get_argc() ; argv = command_line_args_get_argv() ; /** @li If the slave connection type is not specified return an error */ if ( connection == NULL ) { message_publish(MSG_ERROR , "Slave connection type not specified.\n") ; return(-1) ; } /** @li Start remote startup command with remote shell to use and remote machine name*/ switch ( remote_shell ) { case TRICK_RSH: startup_command << unix_rsh << " " << remote_shell_args ; break; case TRICK_USER_REMOTE_SH: if ( user_remote_shell.empty() ) { message_publish(MSG_WARNING , "TRICK_USER_REMOTE_SH specified for Slave startup, but no shell given.\nDefaulting to %s.\n", unix_ssh) ; user_remote_shell = unix_ssh ; } startup_command << user_remote_shell << " " << remote_shell_args ; break; case TRICK_SSH: default: startup_command << unix_ssh << " " << remote_shell_args ; break; } startup_command << " " << machine_name ; /** @li Add the remote display. If a remote display has not been specified, use the environment's */ if ( machine_display.empty() ) { if ((display = (char *) env_get_var("DISPLAY")) == NULL) { message_publish(MSG_ERROR, "Cannot get environment variable $DISPLAY for Slave.\n") ; } else { machine_display = display ; } } /** @li cd to the simulation path in the remote startup command */ if ( sim_path.empty() ) { message_publish(MSG_ERROR, "Slave startup sim_path is empty.\n") ; return(-1) ; } /** @li Set the DISPLAY environment variable in the remote startup command. Use setenv for *csh or export for all other shells */ passp = getpwuid(getuid()); if ( ! machine_display.empty() ) { if (strstr(passp->pw_shell, "csh")) { startup_command << " 'setenv DISPLAY " << machine_display ; } else { startup_command << " 'export DISPLAY=" << machine_display ; } startup_command << " ; cd " << sim_path << " ; " ; } else { startup_command << " 'cd " << sim_path << " ; " ; } if (strstr(passp->pw_shell, "csh")) { startup_command << " setenv TRICK_HOST_CPU `trick-gte TRICK_HOST_CPU` ; " ; } else { startup_command << " export TRICK_HOST_CPU=`trick-gte TRICK_HOST_CPU` ; " ; } /** @li start the simulation in the remote startup command */ if ( S_main_name.empty() ) { S_main_name = "./S_main_${TRICK_HOST_CPU}.exe" ; } startup_command << S_main_name ; /** @li add the user provided run input file if provided */ if ( ! run_input_file.empty() ) { startup_command << " " << run_input_file ; /** @li check to see if master is running with dmtcp slave */ if (run_input_file.find("dmtcp") != std::string::npos) slave_type = "dmtcp"; } /** @li Add the connection specific arguments to the startup command */ startup_command << " " << connection->add_sim_args( slave_type ) ; /* @li Add the additional user arguments to the remote command */ if ( ! other_args.empty() ) { startup_command << " -u " << other_args ; } for (arg_i = 2; arg_i < argc ; arg_i++) { startup_command << " " << argv[arg_i] ; } /* @li start the remote command in the background */ startup_command << "' &" ; message_publish(MSG_INFO, startup_command.str().c_str()) ; /* @li Execute the startup command */ if (system(startup_command.str().c_str())) { perror("Slave_start"); return (-2) ; } /* @li Wait for the slave to connect to the master */ connection->accept() ; /* @li Set the synchronization wait limit */ connection->set_sync_wait_limit(sync_wait_limit) ; /* Set slave to activated */ activated = true; return (0) ; }
RosFramework::RosFramework(std::string app_name) { int argc = command_line_args_get_argc() ; char **argv = command_line_args_get_argv() ; ros::init(argc, argv, app_name.c_str(), ros::init_options::NoSigintHandler) ; }