コード例 #1
0
void parseCmdLine(int arg_num, char *arg_vet[])
{
    if (arg_num == 1)
	cout <<
	    "Running with default parameters (use '-help' option to see how to override them)"
	    << endl;
    else {
	for (int i = 1; i < arg_num; i++) {
	    if (!strcmp(arg_vet[i], "-help")) {
		showHelp(arg_vet[0]);
		exit(0);
	    } else if (!strcmp(arg_vet[i], "-verbose"))
		NoximGlobalParams::verbose_mode = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-trace")) {
		NoximGlobalParams::trace_mode = true;
		strcpy(NoximGlobalParams::trace_filename, arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-dimx"))
		NoximGlobalParams::mesh_dim_x = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-dimy"))
		NoximGlobalParams::mesh_dim_y = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-buffer"))
		NoximGlobalParams::buffer_depth = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-size")) {
		NoximGlobalParams::min_packet_size = atoi(arg_vet[++i]);
		NoximGlobalParams::max_packet_size = atoi(arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-longconn")) {//the user defines a set of long connections
		NoximGlobalParams::long_connections_status = true;
		strcpy(NoximGlobalParams::long_connections_filename, arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-routing")) {
		char *routing = arg_vet[++i];
		if (!strcmp(routing, "xy"))
		    NoximGlobalParams::routing_algorithm = ROUTING_XY;
                else if (!strcmp(routing, "xy_naiv5"))
		    NoximGlobalParams::routing_algorithm = ROUTING_XY_naiv5;
                else if (!strcmp(routing, "xy_simple5"))
		    NoximGlobalParams::routing_algorithm = ROUTING_XY_simple5;
		else if (!strcmp(routing, "westfirst"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_WEST_FIRST;
		else if (!strcmp(routing, "northlast"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_NORTH_LAST;
		else if (!strcmp(routing, "negativefirst"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_NEGATIVE_FIRST;
		else if (!strcmp(routing, "oddeven"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_ODD_EVEN;
		else if (!strcmp(routing, "dyad")) {
		    NoximGlobalParams::routing_algorithm = ROUTING_DYAD;
		    NoximGlobalParams::dyad_threshold = atof(arg_vet[++i]);
		} else if (!strcmp(routing, "fullyadaptive"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_FULLY_ADAPTIVE;
		else if (!strcmp(routing, "table")) {
		    NoximGlobalParams::routing_algorithm =
			ROUTING_TABLE_BASED;
		    strcpy(NoximGlobalParams::routing_table_filename,
			   arg_vet[++i]);
		    NoximGlobalParams::packet_injection_rate = 0.1;	// ??? why ???
		} else
		    NoximGlobalParams::routing_algorithm = INVALID_ROUTING;
	    } else if (!strcmp(arg_vet[i], "-sel")) {
		char *selection = arg_vet[++i];
		if (!strcmp(selection, "random"))
		    NoximGlobalParams::selection_strategy = SEL_RANDOM;
		else if (!strcmp(selection, "bufferlevel"))
		    NoximGlobalParams::selection_strategy =
			SEL_BUFFER_LEVEL;
		else if (!strcmp(selection, "nop"))
		    NoximGlobalParams::selection_strategy = SEL_NOP;
		else
		    NoximGlobalParams::selection_strategy =
			INVALID_SELECTION;
	    } else if (!strcmp(arg_vet[i], "-pir")) {
		NoximGlobalParams::packet_injection_rate =
		    atof(arg_vet[++i]);
		char *distribution = arg_vet[++i];
		if (!strcmp(distribution, "poisson"))
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate;
		else if (!strcmp(distribution, "burst")) {
		    float burstness = atof(arg_vet[++i]);
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate / (1 -
								    burstness);
		} else if (!strcmp(distribution, "pareto")) {
		    float Aon = atof(arg_vet[++i]);
		    float Aoff = atof(arg_vet[++i]);
		    float r = atof(arg_vet[++i]);
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate *
			pow((1 - r), (1 / Aoff - 1 / Aon));
		} else if (!strcmp(distribution, "custom"))
		    NoximGlobalParams::probability_of_retransmission =
			atof(arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-traffic")) {
		char *traffic = arg_vet[++i];
		if (!strcmp(traffic, "random"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_RANDOM;
		else if (!strcmp(traffic, "transpose1"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TRANSPOSE1;
		else if (!strcmp(traffic, "transpose2"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TRANSPOSE2;
		else if (!strcmp(traffic, "bitreversal"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_BIT_REVERSAL;
		else if (!strcmp(traffic, "butterfly"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_BUTTERFLY;
		else if (!strcmp(traffic, "shuffle"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_SHUFFLE;
		else if (!strcmp(traffic, "table")) {
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TABLE_BASED;
		    strcpy(NoximGlobalParams::traffic_table_filename,
			   arg_vet[++i]);
		} else
		    NoximGlobalParams::traffic_distribution =
			INVALID_TRAFFIC;
	    } else if (!strcmp(arg_vet[i], "-hs")) {
		int node = atoi(arg_vet[++i]);
		double percentage = atof(arg_vet[++i]);
		pair < int, double >t(node, percentage);
		NoximGlobalParams::hotspots.push_back(t);
	    } else if (!strcmp(arg_vet[i], "-warmup"))
		NoximGlobalParams::stats_warm_up_time = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-seed"))
		NoximGlobalParams::rnd_generator_seed = atoi(arg_vet[++i]);
 	    else if (!strcmp(arg_vet[i], "-detailed"))
		NoximGlobalParams::detailed = true;
	    else if (!strcmp(arg_vet[i], "-show_buf_stats"))
		NoximGlobalParams::show_buffer_stats = true;
	    else if (!strcmp(arg_vet[i], "-volume"))
		NoximGlobalParams::max_volume_to_be_drained =
		    atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-sim"))
		NoximGlobalParams::simulation_time = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-pwr"))
	      strcpy(NoximGlobalParams::router_power_filename, arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-lpls"))
	      NoximGlobalParams::low_power_link_strategy = true;
	    else if (!strcmp(arg_vet[i], "-qos"))
		NoximGlobalParams::qos = atof(arg_vet[++i]);
	    else {
		cerr << "Error: Invalid option: " << arg_vet[i] << endl;
		exit(1);
	    }
	}
    }
    checkInputParameters();

    // Show configuration
    if (NoximGlobalParams::verbose_mode > VERBOSE_OFF)
	showConfig();
}
コード例 #2
0
ファイル: movieexporter.cpp プロジェクト: chchwy/pencil2d
/** Begin exporting the movie described by exportDesc.
 *
 * @param[in] obj An Object containing the animation to export.
 * @param[in] desc A structure containing all the export parameters.
 *            See ExportMovieDesc.
 * @param[out] majorProgress A function to update the major progress bar.
 *                          The major progress bar goes from 0-100% only
 *                          one time, representing the overall progress of
 *                          the export. The first float parameter is
 *                          the current progress %, and the second is
 *                          the desired progress when the next sub-task
 *                          completes. This should only be called at the
 *                          beginning of a subtask.
 * @param[out] minorProgress A function to update the minor progress bar.
 *                           The minor progress bar goes from 0-100% for
 *                           each sub-task of the exporting process.
 *                           It is up to minor progress to update the
 *                           major progress bar to reflect the sub-task
 *                           progress.
 * @param[out] progressMessage A function ot update the progres bar
 *                             message. The messages will describe
 *                             the current sub-task of the exporting
 *                             process.
 *
 * @return Returns Status:OK on success, or Status::FAIL on error.
 */
Status MovieExporter::run(const Object* obj,
                          const ExportMovieDesc& desc,
                          std::function<void(float, float)> majorProgress,
                          std::function<void(float)> minorProgress,
                          std::function<void(QString)> progressMessage)
{
    majorProgress(0.f, 0.03f);
    minorProgress(0.f);
    progressMessage(QObject::tr("Checking environment..."));

    clock_t t1 = clock();

    QString ffmpegPath = ffmpegLocation();
    qDebug() << ffmpegPath;
    if (!QFile::exists(ffmpegPath))
    {
#ifdef _WIN32
        qCritical() << "Please place ffmpeg.exe in " << ffmpegPath << " directory";
#else
        qCritical() << "Please place ffmpeg in " << ffmpegPath << " directory";
#endif
        return Status::ERROR_FFMPEG_NOT_FOUND;
    }

    STATUS_CHECK(checkInputParameters(desc));
    mDesc = desc;

    qDebug() << "OutFile: " << mDesc.strFileName;

    // Setup temporary folder
    if (!mTempDir.isValid())
    {
        Q_ASSERT(false && "Cannot create temp folder.");
        return Status::FAIL;
    }

    mTempWorkDir = mTempDir.path();

    minorProgress(0.f);
    if (desc.strFileName.endsWith("gif", Qt::CaseInsensitive))
    {
        majorProgress(0.03f, 1.f);
        progressMessage("Generating gif...");
        minorProgress(0.f);
        STATUS_CHECK(generateGif(obj, ffmpegPath, desc.strFileName, minorProgress));
    }
    else
    {
        majorProgress(0.03f, 0.25f);
        progressMessage("Assembling audio...");
        minorProgress(0.f);
        STATUS_CHECK(assembleAudio(obj, ffmpegPath, minorProgress));
        minorProgress(1.f);
        majorProgress(0.25f, 1.f);
        progressMessage("Generating movie...");
        STATUS_CHECK(generateMovie(obj, ffmpegPath, desc.strFileName, minorProgress));
    }
    minorProgress(1.f);
    majorProgress(1.f, 1.f);
    progressMessage(QObject::tr("Done"));
    
    clock_t t2 = clock() - t1;
    qDebug("MOVIE = %.1f sec", static_cast<double>(t2 / CLOCKS_PER_SEC));

    return Status::OK;
}