AlwaysLocationUpdatePolicy::AlwaysLocationUpdatePolicy(const String& args)
    : LocationUpdatePolicy(),
      mServerSubscriptions(this),
      mObjectSubscriptions(this)
{
    OptionSet* optionsSet = OptionSet::getOptions(ALWAYS_POLICY_OPTIONS,NULL);
    optionsSet->parse(args);
}
Exemple #2
0
static OH::Storage* createCassandraStorage(ObjectHostContext* ctx, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("cassandrastorage",NULL);
    optionsSet->parse(args);

    String host = optionsSet->referenceOption("host")->as<String>();
    int32 port = optionsSet->referenceOption("port")->as<int32>();

    return new OH::CassandraStorage(ctx, host, port);
}
Exemple #3
0
static ObjectFactory* createCassandraObjectFactory(ObjectHostContext* ctx, ObjectHost* oh, const SpaceID& space, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("cassandrafactory",NULL);
    optionsSet->parse(args);

    String host = optionsSet->referenceOption("host")->as<String>();
    int32 port = optionsSet->referenceOption("port")->as<int32>();
    String ohid = optionsSet->referenceOption("ohid")->as<String>();

    return new CassandraObjectFactory(ctx, oh, space, host, port, ohid);
}
Exemple #4
0
static OH::PersistedObjectSet* createCassandraPersistedObjectSet(ObjectHostContext* ctx, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("cassandrapersistedset",NULL);
    optionsSet->parse(args);

    String host = optionsSet->referenceOption("host")->as<String>();
    int32 port = optionsSet->referenceOption("port")->as<int32>();
    String ohid = optionsSet->referenceOption("ohid")->as<String>();

    return new OH::CassandraPersistedObjectSet(ctx, host, port, ohid);
}
Exemple #5
0
void ParseOptions(int argc, char** argv, const String& config_file_option) {
    OptionSet* options = OptionSet::getOptions(SIRIKATA_OPTIONS_MODULE,NULL);

    // Parse command line once to make sure we have the right config
    // file. On this pass, use defaults so everything gets filled in.
    options->parse(argc, argv, true);

    // Get the config file name and parse it. Don't use defaults to
    // avoid overwriting.
    String fname = GetOptionValue<String>(config_file_option.c_str());
    if (!fname.empty())
        options->parseFile(fname, false, false);

    // And parse the command line args a second time to overwrite any settings
    // the config file may have overwritten. Don't use defaults to
    // avoid overwriting.
    options->parse(argc, argv, false);

    setLogOutput();
}
Exemple #6
0
SaveFilter::SaveFilter(const String& args) {
    Sirikata::InitializeClassOptions ico("save_filter", NULL,
        new OptionValue("filename","",Sirikata::OptionValueType<String>(),"Name of file to save to."),
        new OptionValue("format","colladamodels",Sirikata::OptionValueType<String>(),"Format to save to."),
        NULL);

    OptionSet* optionSet = OptionSet::getOptions("save_filter",NULL);
    optionSet->parse(args);

    mFilename = optionSet->referenceOption("filename")->as<String>();
    mFormat = optionSet->referenceOption("format")->as<String>();
}
Prox::QueryHandler<SimulationTraits>* QueryHandlerFactory(const String& type, const String& args) {
    static OptionValue* branching = NULL;
    static OptionValue* rebuild_batch_size = NULL;
    if (branching == NULL) {
        branching = new OptionValue("branching", "10", Sirikata::OptionValueType<uint32>(), "Number of children each node should have.");
        rebuild_batch_size = new OptionValue("rebuild-batch-size", "10", Sirikata::OptionValueType<uint32>(), "Number of queries to transition on each iteration when rebuilding. Keep this small to avoid long latencies between updates.");
        Sirikata::InitializeClassOptions ico("query_handler", NULL,
            branching,
            rebuild_batch_size,
            NULL);
    }

    assert(branching != NULL);

    // Since these options end up being shared if you instantiate multiple
    // QueryHandlers, reset them each time.
    branching->unsafeAs<uint32>() = 10;

    OptionSet* optionsSet = OptionSet::getOptions("query_handler", NULL);
    optionsSet->parse(args);

    if (type == "brute") {
        return new Prox::RebuildingQueryHandler<SimulationTraits>(
            Prox::BruteForceQueryHandler<SimulationTraits>::Constructor(), rebuild_batch_size->unsafeAs<uint32>()
        );
    }
    else if (type == "rtree") {
        return new Prox::RebuildingQueryHandler<SimulationTraits>(
            Prox::RTreeAngleQueryHandler<SimulationTraits>::Constructor(branching->unsafeAs<uint32>()), rebuild_batch_size->unsafeAs<uint32>()
        );
    }
    else if (type == "rtreedist" || type == "dist") {
        return new Prox::RebuildingQueryHandler<SimulationTraits>(
            Prox::RTreeDistanceQueryHandler<SimulationTraits>::Constructor(branching->unsafeAs<uint32>()), rebuild_batch_size->unsafeAs<uint32>()
        );
    }
    else if (type == "rtreecut") {
        return new Prox::RebuildingQueryHandler<SimulationTraits>(
            Prox::RTreeCutQueryHandler<SimulationTraits>::Constructor(branching->unsafeAs<uint32>(), false), rebuild_batch_size->unsafeAs<uint32>()
        );
    }
    else if (type == "rtreecutagg") {
        return new Prox::RebuildingQueryHandler<SimulationTraits>(
            Prox::RTreeCutQueryHandler<SimulationTraits>::Constructor(branching->unsafeAs<uint32>(), true), rebuild_batch_size->unsafeAs<uint32>()
        );
    }
    else {
        return NULL;
    }
}
ByteTransferScenario::ByteTransferScenario(const String &options):mStartTime(Time::epoch()){
    mNumTotalPings=0;
    mContext=NULL;
    mObjectTracker = NULL;

    BTSInitOptions(this);
    OptionSet* optionsSet = OptionSet::getOptions("DistributedPingScenario",this);
    optionsSet->parse(options);
    mSameObjectHostPings=optionsSet->referenceOption("allow-same-object-host")->as<bool>();
    mForceSameObjectHostPings=optionsSet->referenceOption("force-same-object-host")->as<bool>();
    mPacketSize=optionsSet->referenceOption("packet-size")->as<size_t>();

    mPort=OBJECT_PORT_PING;
    mGeneratePings=std::tr1::bind(&ByteTransferScenario::generatePings,this);
}
Exemple #9
0
OSegScenario::OSegScenario(const String &options)
 : mStartTime(Time::epoch())
{
    mNumTotalPings=0;
    mContext=NULL;
    mObjectTracker = NULL;
    mPingID=0;
    DPSInitOptions(this);
    OptionSet* optionsSet = OptionSet::getOptions("OSegScenario",this);
    optionsSet->parse(options);

    mNumPingsPerSecond=optionsSet->referenceOption("num-pings-per-second")->as<double>();
    mPingPayloadSize=optionsSet->referenceOption("ping-size")->as<uint32>();
    mFloodServer = optionsSet->referenceOption("flood-server")->as<uint32>();
    mSourceFloodServer = optionsSet->referenceOption("source-flood-server")->as<bool>();
    mNumObjectsPerServer=optionsSet->referenceOption("num-objects-per-server")->as<uint32>();
    mLocalTraffic = optionsSet->referenceOption("local")->as<bool>();
    mFractionMessagesUniform= optionsSet->referenceOption("prob-messages-uniform")->as<double>();
    mNumGeneratedPings = 0;
    mGeneratePingsStrand = NULL;
    mGeneratePingPoller = NULL;
    mPings = // We allocate space for 1/4 seconds worth of pings
        new Sirikata::SizedThreadSafeQueue<PingInfo,CountResourceMonitor>(
            CountResourceMonitor(std::max((uint32)(mNumPingsPerSecond / 4), (uint32)2))
        );
    mWeightCalculator =
        RegionWeightCalculatorFactory::getSingleton().getConstructor(GetOptionValue<String>(OPT_REGION_WEIGHT))(GetOptionValue<String>(OPT_REGION_WEIGHT_ARGS))
        ;
    mPingPoller = NULL;
    // NOTE: We have this limit because we can get in lock-step with the
    // generator, causing this to run for excessively long when we fall behind
    // on pings.  This allows us to burst to catch up when there is time (and
    // amortize the constant overhead of doing 1 round), but if
    // there is other work to be done we won't make our target rate.
    mMaxPingsPerRound = 40;
    // Do we want to vary this based on mNumPingsPerSecond? 20 is a decent
    // burst, but at 10k/s can take 2ms (we're seeing about 100us/ping
    // currently), which is potentially a long delay for other things in this
    // strand.  If we try to get to 100k, that can be up to 20ms which is very
    // long to block other things on the main strand.
}
Exemple #10
0
int main(int argc, char** argv)
{
	string src_conn_name = "unknown";
	string dst_conn_name = "hdmi";
	PixelFormat pixfmt = PixelFormat::XRGB8888;

	OptionSet optionset = {
		Option("s|src=", [&](string s)
		{
			src_conn_name = s;
		}),
		Option("d|dst=", [&](string s)
		{
			dst_conn_name = s;
		}),
		Option("f|format=", [&](string s)
		{
			pixfmt = FourCCToPixelFormat(s);
		}),
		Option("h|help", [&]()
		{
			puts(usage_str);
			exit(-1);
		}),
	};

	optionset.parse(argc, argv);

	if (optionset.params().size() > 0) {
		puts(usage_str);
		exit(-1);
	}

	VideoDevice vid("/dev/video11");

	Card card;
	ResourceManager resman(card);

	auto src_conn = resman.reserve_connector(src_conn_name);
	auto src_crtc = resman.reserve_crtc(src_conn);

	uint32_t src_width = src_crtc->mode().hdisplay;
	uint32_t src_height = src_crtc->mode().vdisplay;

	printf("src %s, crtc %ux%u\n", src_conn->fullname().c_str(), src_width, src_height);

	auto dst_conn = resman.reserve_connector(dst_conn_name);
	auto dst_crtc = resman.reserve_crtc(dst_conn);
	auto dst_plane = resman.reserve_overlay_plane(dst_crtc, pixfmt);
	FAIL_IF(!dst_plane, "Plane not found");

	uint32_t dst_width = min((uint32_t)dst_crtc->mode().hdisplay, src_width);
	uint32_t dst_height = min((uint32_t)dst_crtc->mode().vdisplay, src_height);

	printf("dst %s, crtc %ux%u, plane %ux%u\n", dst_conn->fullname().c_str(),
	       dst_crtc->mode().hdisplay, dst_crtc->mode().vdisplay,
	       dst_width, dst_height);

	for (int i = 0; i < CAMERA_BUF_QUEUE_SIZE; ++i) {
		auto fb = new DumbFramebuffer(card, src_width, src_height, pixfmt);
		s_fbs.push_back(fb);
		s_free_fbs.push_back(fb);
	}

	// get one fb for initial setup
	s_ready_fbs.push_back(s_free_fbs.back());
	s_free_fbs.pop_back();

	// This draws a moving bar to SRC display
	BarFlipState barflipper(card, src_crtc);
	barflipper.start_flipping();

	// This shows the captures SRC frames on DST display
	WBFlipState wbflipper(card, dst_crtc, dst_plane);
	wbflipper.setup(0, 0, dst_width, dst_height);

	WBStreamer wb(vid.get_capture_streamer(), src_crtc, src_width, src_height, pixfmt);
	wb.start_streaming();

	vector<pollfd> fds(3);

	fds[0].fd = 0;
	fds[0].events =  POLLIN;
	fds[1].fd = wb.fd();
	fds[1].events =  POLLIN;
	fds[2].fd = card.fd();
	fds[2].events =  POLLIN;

	while (true) {
		int r = poll(fds.data(), fds.size(), -1);
		ASSERT(r > 0);

		if (fds[0].revents != 0)
			break;

		if (fds[1].revents) {
			fds[1].revents = 0;

			wb.Dequeue();
			wbflipper.queue_next();
		}

		if (fds[2].revents) {
			fds[2].revents = 0;

			card.call_page_flip_handlers();
			wb.Queue();
		}
	}

	printf("exiting...\n");
}
static SpaceModule* createEnvironment(SpaceContext* ctx, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("space_environment",NULL);
    optionsSet->parse(args);

    return new Environment(ctx);
}
Exemple #12
0
void ParseOptions(int argc, char** argv) {
    OptionSet* options = OptionSet::getOptions(SIRIKATA_OPTIONS_MODULE,NULL);
    options->parse(argc, argv);
    setLogOutput();
}
Exemple #13
0
void FakeParseOptions() {
    OptionSet* options = OptionSet::getOptions(SIRIKATA_OPTIONS_MODULE,NULL);
    int argc = 1; const char* argv[2] = { "bogus", NULL };
    options->parse(argc, argv);
}
static PintoServerQuerier* createLocalPintoServerQuerier(SpaceContext* ctx, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("space_local",NULL);
    optionsSet->parse(args);

    return new LocalPintoServerQuerier(ctx);
}
static ObjectSegmentation* createLocalOSeg(SpaceContext* ctx, Network::IOStrand* oseg_strand, CoordinateSegmentation* cseg, OSegCache* cache, const String& args) {
    OptionSet* optionsSet = OptionSet::getOptions("space_local",NULL);
    optionsSet->parse(args);

    return new LocalObjectSegmentation(ctx, oseg_strand, cseg, cache);
}
Exemple #16
0
int main(int argc, char **argv)
{
	string dev_path;
	unsigned id = 0;

	OptionSet optionset = {
		Option("|device=",
		[&](string s)
		{
			dev_path = s;
		}),
		Option("|id=",
		[&](string s)
		{
			id = stoul(s);
		}),
		Option("p", [&](string s)
		{
			opts.print_props = true;
		}),
		Option("m", [&](string s)
		{
			opts.print_modes = true;
		}),
		Option("r", [&](string s)
		{
			opts.recurse = true;
		}),
		Option("h|help", [&]()
		{
			usage();
			exit(-1);
		}),
	};

	optionset.parse(argc, argv);

	if (optionset.params().size() > 0) {
		usage();
		exit(-1);
	}

	Card card;

	/* No options impliles recursion */
	if (id == 0) {
		opts.recurse = true;
		for (auto conn : card.get_connectors())
			print_connector(*conn, 0);
		return 0;
	} else {
		auto ob = card.get_object(id);
		if (!ob) {
			cerr << "kmsprint" << ": Object id " <<
				id << " not found." << endl;
			return -1;
		}

		if (auto co = dynamic_cast<Connector*>(ob))
			print_connector(*co, 0);
		else if (auto en = dynamic_cast<Encoder*>(ob))
			print_encoder(*en, 0);
		else if (auto cr = dynamic_cast<Crtc*>(ob))
			print_crtc(*cr, 0);
		else if (auto pl = dynamic_cast<Plane*>(ob))
			print_plane(*pl, 0);
		else {
			cerr << "kmsprint" << ": Unkown DRM Object type" <<
				endl;
			return -1;
		}

		return 0;
	}
}