Пример #1
0
shared_ptr<Component> ScheduledActionsFactory::createObject(std::map<std::string, std::string> parameters,
        ComponentRegistry *reg) {
    REQUIRE_ATTRIBUTES(parameters, "delay", "repeats", "duration");

    shared_ptr<Variable> delay = reg->getVariable(parameters["delay"]);
    shared_ptr<Variable> duration = reg->getVariable(parameters["duration"]);
    shared_ptr<Variable> repeats = reg->getVariable(parameters["repeats"]);
    shared_ptr<Variable> cancel = reg->getVariable(parameters["cancel"], "0");

    checkAttribute(duration, parameters["reference_id"], "duration", parameters["duration"]);

    checkAttribute(delay, parameters["reference_id"], "delay", parameters["delay"]);

    checkAttribute(repeats, parameters["reference_id"], "repeats", parameters["repeats"]);

    checkAttribute(repeats, parameters["reference_id"], "cancel", parameters["cancel"]);


    // TODO .. needs more work, the actual actions aren't included here

    auto newScheduledActions = boost::make_shared<ScheduledActions>(repeats, delay, duration, cancel);

    if (cancel) {
        auto notification = boost::make_shared<ScheduledActions::CancelNotification>(newScheduledActions);
        cancel->addNotification(notification);
    }

    return newScheduledActions;
}
shared_ptr<mw::Component> mFakeMonkeyEyeMovementChannelFactory::createObject(std::map<std::string, std::string> parameters,
																		  ComponentRegistry *reg) {
	const char *EYE_H_VARIABLE = "eye_h";
	const char *EYE_V_VARIABLE = "eye_v";
	const char *UPDATE_PERIOD = "update_interval";
	const char *DATA_SAMPLING_PERIOD = "data_interval";
	
	REQUIRE_ATTRIBUTES(parameters, EYE_H_VARIABLE, EYE_V_VARIABLE, UPDATE_PERIOD, DATA_SAMPLING_PERIOD);
	
	shared_ptr<Variable> eye_h_variable = reg->getVariable(parameters.find(EYE_H_VARIABLE)->second);	
	checkAttribute(eye_h_variable, parameters.find("reference_id")->second, EYE_H_VARIABLE, parameters.find(EYE_H_VARIABLE)->second);

	shared_ptr<Variable> eye_v_variable = reg->getVariable(parameters.find(EYE_V_VARIABLE)->second);		
	checkAttribute(eye_v_variable, parameters.find("reference_id")->second, EYE_V_VARIABLE, parameters.find(EYE_V_VARIABLE)->second);

	MWorksTime update_period = reg->getNumber(parameters.find(UPDATE_PERIOD)->second);
	MWorksTime data_sampling_period = reg->getNumber(parameters.find(DATA_SAMPLING_PERIOD)->second);
	
	int samples_per_update = update_period/data_sampling_period;
	
	shared_ptr <mw::Component> new_fake_monkey_eye_channel = shared_ptr<mw::Component>(new mFakeMonkeyEyeMovementChannel(eye_h_variable, 
																												   eye_v_variable, 
																												   update_period,
																												   samples_per_update));
	return new_fake_monkey_eye_channel;
}
shared_ptr<mw::Component> CNCDeviceFactory::createObject(std::map<std::string, std::string> parameters,
												 ComponentRegistry *reg) {
												 
	REQUIRE_ATTRIBUTES(parameters, "device_name");
	
    string executable_path = parameters["executable_path"];
    if(executable_path == ""){
        executable_path = "/Applications/cncController.app/Contents/MacOS/cncController";
    }
	
    //NSTask *task = [NSTask launchedTaskWithLaunchPath:[NSString stringWithCString:executable_path.c_str() encoding:NSASCIIStringEncoding] arguments:[[NSArray alloc] init]];
   
    shared_ptr<mw::Clock> clock = mw::Clock::instance();
    //clock->sleepMS(1000);
    
    //if(![task isRunning]){
    //    throw SimpleException("Failed to launch eye tracker application");
    //}
    
    NSLog(@"%s",executable_path.c_str());
    
	string resource_name = parameters["device_name"];
    shared_ptr <mw::Component> newDevice(new CNCDevice(resource_name));

    return newDevice;
    
}
shared_ptr<mw::Component> mFakeMonkeyJuiceChannelFactory::createObject(std::map<std::string, std::string> parameters,
																	mwComponentRegistry *reg) {
	const char *JUICE_VARIABLE = "variable";
	
	REQUIRE_ATTRIBUTES(parameters, JUICE_VARIABLE);
	
	shared_ptr<Variable> juice_variable = reg->getVariable(parameters.find(JUICE_VARIABLE)->second);	
	
	shared_ptr <mw::Component> new_fake_monkey_juice_channel = shared_ptr<mw::Component>(new mFakeMonkeyJuiceChannel(juice_variable));
	return new_fake_monkey_juice_channel;
}
Пример #5
0
shared_ptr<mw::Component> mStopMovieFactory::createObject(std::map<std::string, std::string> parameters,
													   mwComponentRegistry *reg) {
	
	const char *MOVIE = "movie";
	
	REQUIRE_ATTRIBUTES(parameters, MOVIE);
	
	shared_ptr <mMovieStimulus> the_movie = reg->getObject<mMovieStimulus>(parameters.find(MOVIE)->second);
	
	if(the_movie == 0) {
		throw MissingReferenceException(parameters.find("reference_id")->second, MOVIE, parameters.find(MOVIE)->second);		
	}
	
	shared_ptr <mStopMovie> new_stop_movie_action = shared_ptr<mStopMovie>(new mStopMovie(the_movie));
	return new_stop_movie_action;		
}
Пример #6
0
shared_ptr<mw::Component> LinearEyeCalibratorFactory::createObject(std::map<std::string, std::string> parameters,
															 ComponentRegistry *reg) {
	REQUIRE_ATTRIBUTES(parameters, "tag", "eyeh_raw", "eyeh_calibrated", "eyev_raw", "eyev_calibrated");
	
	std::string tagname(parameters.find("tag")->second);
	shared_ptr<Variable> eyeh_raw = reg->getVariable(parameters.find("eyeh_raw")->second);	
	shared_ptr<Variable> eyev_raw = reg->getVariable(parameters.find("eyev_raw")->second);	
	shared_ptr<Variable> eyeh_calibrated = reg->getVariable(parameters.find("eyeh_calibrated")->second);	
	shared_ptr<Variable> eyev_calibrated = reg->getVariable(parameters.find("eyev_calibrated")->second);	
	
	checkAttribute(eyeh_raw, parameters["reference_id"], "eyeh_raw", parameters.find("eyeh_raw")->second);
	checkAttribute(eyev_raw, parameters["reference_id"], "eyev_raw", parameters.find("eyev_raw")->second);
	checkAttribute(eyeh_calibrated, parameters["reference_id"], "eyeh_calibrated", parameters.find("eyeh_calibrated")->second);
	checkAttribute(eyev_calibrated, parameters["reference_id"], "eyev_calibrated", parameters.find("eyev_calibrated")->second);
	
	shared_ptr <mw::Component> newEyeCalibrator = shared_ptr<mw::Component>(new EyeCalibrator(tagname, 
																							  eyeh_raw, 
																							  eyev_raw,
																							  eyeh_calibrated,
																							  eyev_calibrated,
																							  1));
	return newEyeCalibrator;
}