Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
Action now supports StandardComponentFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
cstawarz committed Mar 31, 2011
1 parent 9ab08dc commit a10c0f3
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 130 deletions.
43 changes: 39 additions & 4 deletions Core/ParadigmComponents/TrialBuildingBlocks.cpp
Expand Up @@ -19,14 +19,30 @@

#include <iostream>
#include <sstream>
using namespace mw;


BEGIN_NAMESPACE_MW


#define VERBOSE_ACTION_METHODS 0


/****************************************************************
* Action Methods
****************************************************************/
void Action::describeComponent(ComponentInfo &info) {
State::describeComponent(info);
}

Action::Action(const ParameterValueMap &parameters) :
State(), // TODO: pass parameters once State supports them
delay(NULL),
taskRef(0)
{
setOwner(GlobalCurrentExperiment); // a bit of kludge for now
setName("Action");
}

Action::Action() : State() {
setOwner(GlobalCurrentExperiment); // a bit of kludge for now
delay = NULL;
Expand Down Expand Up @@ -2055,13 +2071,32 @@ shared_ptr<mw::Component> ClearAveragerFactory::createObject(std::map<std::strin
}


// action to flush calibration samples up to some time?? (variable controlled?)

// action to load params into calibration?? (where should this happen?)


END_NAMESPACE_MW




















//#endif

// action to flush calibration samples up to some time?? (variable controlled?)

// action to load params into calibration?? (where should this happen?)

89 changes: 61 additions & 28 deletions Core/ParadigmComponents/TrialBuildingBlocks.h
Expand Up @@ -27,38 +27,49 @@
#include "EyeCalibrators.h"
#include "Sound.h"
#include "ComponentRegistry.h"
namespace mw {
#include "ComponentInfo.h"
#include "ParameterValue.h"

using namespace boost;


BEGIN_NAMESPACE_MW


// base class for all actions
class Action : public State, public VariableNotification {
protected:
// State *parent;
Variable *delay;
ScheduleTask *taskRef;
public:
Action();
virtual ~Action();
virtual bool execute();

// TODO: are these needed
virtual void setOwner(weak_ptr<State> _parent);
virtual weak_ptr<State> getOwner();

virtual weak_ptr<Experiment> getExperiment();
void setName(const std::string &_name);

// Fancier features
void setDelay(Variable *_delay){ delay = _delay; }
Variable *getDelay(){ return delay; };

virtual void announceEntry();
virtual void announceExit();

// State methods
virtual void action();
virtual weak_ptr<State> next();

protected:
// State *parent;
Variable *delay;
ScheduleTask *taskRef;

public:
static void describeComponent(ComponentInfo &info);

explicit Action(const ParameterValueMap &parameters);
Action();
virtual ~Action();
virtual bool execute();

// TODO: are these needed
virtual void setOwner(weak_ptr<State> _parent);
virtual weak_ptr<State> getOwner();

virtual weak_ptr<Experiment> getExperiment();
void setName(const std::string &_name);

// Fancier features
void setDelay(Variable *_delay){ delay = _delay; }
Variable *getDelay(){ return delay; };

virtual void announceEntry();
virtual void announceExit();

// State methods
virtual void action();
virtual weak_ptr<State> next();

};

class ActionVariableNotification : public VariableNotification{
Expand Down Expand Up @@ -863,8 +874,30 @@ class ClearAveragerFactory : public ComponentFactory{
virtual shared_ptr<mw::Component> createObject(std::map<std::string, std::string> parameters,
ComponentRegistry *reg);
};
}


END_NAMESPACE_MW


#endif





















1 change: 1 addition & 0 deletions Core/PluginServices/ComponentFactory.cpp
Expand Up @@ -21,6 +21,7 @@ bool ComponentFactory::shouldIgnoreParameter(const std::string &name) {
//
// Parameters added or used by the parser
//
(name == "parent_scope") ||
(name == "reference_id") ||
(name == "type") ||
(name == "variable_assignment") ||
Expand Down
12 changes: 12 additions & 0 deletions Core/PluginServices/ParameterValue.cpp
Expand Up @@ -31,6 +31,18 @@ RGBColor ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg)
}


template<>
StimulusNodePtr ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg) {
StimulusNodePtr stimNode(reg->getStimulus(s));

if (!stimNode) {
throw SimpleException("Unknown stimulus", s);
}

return stimNode;
}


template<>
StimulusGroupPtr ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg) {
StimulusGroupPtr stimGroup(reg->getObject<StimulusGroup>(s));
Expand Down
4 changes: 4 additions & 0 deletions Core/PluginServices/ParameterValue.h
Expand Up @@ -94,6 +94,10 @@ template<>
RGBColor ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg);


template<>
StimulusNodePtr ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg);


template<>
StimulusGroupPtr ParameterValue::convert(const std::string &s, ComponentRegistryPtr reg);

Expand Down
2 changes: 1 addition & 1 deletion Core/Stimuli/Stimulus.cpp
Expand Up @@ -29,7 +29,7 @@ BEGIN_NAMESPACE_MW
void StimulusGroup::describeComponent(ComponentInfo &info) {
Component::describeComponent(info);
info.setSignature("stimulus_group");
info.addParameter(Component::TAG); // Make tag required
info.addParameter(TAG); // Make tag required
}


Expand Down
14 changes: 4 additions & 10 deletions Core/Stimuli/StimulusDisplay.cpp
Expand Up @@ -21,16 +21,7 @@
#include "boost/bind.hpp"


#ifdef __APPLE__
#include <AGL/agl.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#elif linux
// TODO: where are these in linux?
#endif


using namespace mw;
BEGIN_NAMESPACE_MW



Expand Down Expand Up @@ -497,6 +488,9 @@ shared_ptr<StimulusDisplay> StimulusDisplay::getCurrentStimulusDisplay() {
}


END_NAMESPACE_MW





31 changes: 30 additions & 1 deletion Core/Stimuli/StimulusNode.cpp
Expand Up @@ -8,7 +8,10 @@
*/

#include "StimulusNode.h"
using namespace mw;


BEGIN_NAMESPACE_MW


/**********************************************************************
* StimulusNode Methods
Expand Down Expand Up @@ -466,3 +469,29 @@ Datum StimulusGroupReferenceNode::getCurrentAnnounceDrawData(){
// }
//}
//


END_NAMESPACE_MW























0 comments on commit a10c0f3

Please sign in to comment.