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

Commit

Permalink
Merge branch 'master' of git://github.com/monkeyworks-project/mw_core
Browse files Browse the repository at this point in the history
  • Loading branch information
cstawarz committed Jan 14, 2010
2 parents c99487f + e9975de commit 46e570a
Show file tree
Hide file tree
Showing 36 changed files with 91 additions and 77 deletions.
Expand Up @@ -13,7 +13,7 @@
#include "DummyEventTransport.h"
#include "IPCEventTransport.h"

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CodecAwareConduitTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CodecAwareConduitTestFixture, "Unit Test" );

using namespace mw;

Expand Down
Expand Up @@ -17,7 +17,7 @@

using namespace mw;

////<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( EventStreamConduitTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( EventStreamConduitTestFixture, "Unit Test" );


void EventStreamConduitTestFixture::setUp(){
Expand Down
2 changes: 1 addition & 1 deletion Core/Communications/Conduits/tests/SimpleConduitTest.cpp
Expand Up @@ -14,7 +14,7 @@

using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SimpleConduitTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SimpleConduitTestFixture, "Unit Test" );

void SimpleEventCollector::handleEvent(shared_ptr<Event> event){
boost::mutex::scoped_lock lock(last_event_lock);
Expand Down
2 changes: 1 addition & 1 deletion Core/Communications/PythonConduitServerTest.cpp
Expand Up @@ -28,7 +28,7 @@

using namespace mw;

////<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PythonConduitServerTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PythonConduitServerTestFixture, "Unit Test" );


void PythonConduitServerTestFixture::setUp(){
Expand Down
Expand Up @@ -15,7 +15,7 @@
#include <boost/archive/text_oarchive.hpp>
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SerializationTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SerializationTestFixture, "Unit Test" );


void SerializationTestFixture::setUp(){
Expand Down
Expand Up @@ -11,7 +11,7 @@
#include "IPCEventTransport.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IPCEventTransportTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IPCEventTransportTestFixture, "Unit Test" );


void IPCEventTransportTestFixture::testOneThread(){
Expand Down
2 changes: 1 addition & 1 deletion Core/DataFiles/tests/DataFileTest.cpp
Expand Up @@ -24,7 +24,7 @@ using namespace mw;
#define BUFFER_HIGH_WATER_MARK 1
#define MAX_EVENTS_TO_BUFFER 10000

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DatumFileTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DatumFileTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( DatumFileTestFixture );

#define dft_CPPUNIT_ASSERT_TS(x) dft_cppunit_lock->lock(); \
Expand Down
2 changes: 1 addition & 1 deletion Core/Events/tests/BufferManagerTest.cpp
Expand Up @@ -43,7 +43,7 @@ void bmt_assert(const std::string &message,
const bool assertCondition);
//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BufferManagerTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BufferManagerTestFixture, "Unit Test" );
void BufferManagerTestFixture::setUp() {
shared_ptr <Clock> shared_clock = Clock::instance(false);
Expand Down
2 changes: 1 addition & 1 deletion Core/Events/tests/ScarabEventTest.cpp
Expand Up @@ -11,7 +11,7 @@
#include "EventBuffer.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabEventTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabEventTestFixture, "Unit Test" );

void ScarabEventTestFixture::setUp(){

Expand Down
2 changes: 1 addition & 1 deletion Core/GenericStructures/tests/ExpandableListTest.cpp
Expand Up @@ -11,7 +11,7 @@
using namespace mw;


//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ExpandableListTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ExpandableListTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( ExpandableListTestFixture );

void ExpandableListTestFixture::setUp(){}
Expand Down
2 changes: 1 addition & 1 deletion Core/GenericStructures/tests/LinkedListTest.cpp
Expand Up @@ -10,7 +10,7 @@
#include "LinkedListTest.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LinkedListTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LinkedListTestFixture, "Unit Test" );

void LinkedListTestFixture::setUp(){
a = shared_ptr<StimulusNode>(new StimulusNode());
Expand Down
2 changes: 1 addition & 1 deletion Core/Interpreters/tests/PerlInterpreterTest.cpp
Expand Up @@ -10,5 +10,5 @@
#include "PerlInterpreterTest.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PerlInterpreterTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PerlInterpreterTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( PerlInterpreterTestFixture );
2 changes: 1 addition & 1 deletion Core/ParadigmComponents/tests/ActionTest.cpp
Expand Up @@ -15,7 +15,7 @@
#include "CancelScheduledActionsAction.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ActionTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ActionTestFixture, "Unit Test" );

void ActionTestFixture::testSimpleAssignment1() {
shared_ptr<ConstantVariable>c1 = shared_ptr<ConstantVariable>(new ConstantVariable(Datum(M_FLOAT, 7.62)));
Expand Down
Expand Up @@ -13,7 +13,7 @@
using namespace mw;


//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PlatformDependentServicesTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PlatformDependentServicesTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( PlatformDependentServicesTestFixture );


Expand Down
2 changes: 1 addition & 1 deletion Core/RealtimeServices/tests/ClockTest.cpp
Expand Up @@ -11,7 +11,7 @@
#include "Clock.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClockTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClockTestFixture, "Unit Test" );

void ClockTestFixture::setUp() {
shared_ptr <Clock> shared_clock = Clock::instance(false);
Expand Down
16 changes: 14 additions & 2 deletions Core/RealtimeServices/tests/SchedulerTest.cpp
Expand Up @@ -12,7 +12,7 @@
using namespace mw;


//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SchedulerTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SchedulerTestFixture, "Unit Test" );

void SchedulerTestFixture::setUp() {
shared_ptr <Scheduler> shared_scheduler = Scheduler::instance(false);
Expand Down Expand Up @@ -352,7 +352,19 @@ void SchedulerTestFixture::reportLatencies(std::vector<MWTime> times_array,
}
n++;
}


#define DO_CUMULATIVE 1
if(DO_CUMULATIVE){
less_than_10us += less_than_5us;
less_than_50us += less_than_10us;
less_than_100us += less_than_50us;
less_than_500us += less_than_100us;
less_than_1000us += less_than_500us;
less_than_5000us += less_than_1000us;
less_than_10000us += less_than_5000us;
less_than_15000us += less_than_10000us;
}

fprintf(stderr, "Latency Statistics...\n"
"\t< 5us: %.4g\n"
"\t< 10us: %.4g\n"
Expand Down
12 changes: 6 additions & 6 deletions Core/RealtimeServices/tests/SchedulerTest.h
Expand Up @@ -16,7 +16,7 @@
namespace mw {
#define N_SCHEDULED_EXECUTIONS 100
#define SLACK_MARGIN 5
#define ACCEPTABLE_ERROR_US 10000 // 10 ms
#define ACCEPTABLE_ERROR_US 1000 // 100 us

void *chaff_1(const MWTime interval);

Expand All @@ -37,12 +37,12 @@ class SchedulerTestFixture : public FullCoreEnvironmentTestFixture {

CPPUNIT_TEST_SUITE( SchedulerTestFixture );

// CPPUNIT_TEST( testPeriod10HzNoPayload );
// CPPUNIT_TEST( testPeriod100HzNoPayload );
// CPPUNIT_TEST( testPeriod10HzNoPayloadChaffX4 );
CPPUNIT_TEST( testPeriod10HzNoPayload );
CPPUNIT_TEST( testPeriod100HzNoPayload );
CPPUNIT_TEST( testPeriod10HzNoPayloadChaffX4 );
//CPPUNIT_TEST( testPeriod10HzNoPayloadChaffX20 );
// CPPUNIT_TEST( testPeriod10HzSmallPayload );
// CPPUNIT_TEST( testOneOffFiringSmallPayload );
CPPUNIT_TEST( testPeriod10HzSmallPayload );
CPPUNIT_TEST( testOneOffFiringSmallPayload );

CPPUNIT_TEST (testSchedulerLeaks);

Expand Down
2 changes: 1 addition & 1 deletion Core/RealtimeServices/tests/TimerTest.cpp
Expand Up @@ -11,7 +11,7 @@
#include "MonkeyWorksCore/TrialBuildingBlocks.h"
#include "MonkeyWorksCore/GlobalVariable.h"

////<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TimerTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TimerTestFixture, "Unit Test" );


#include <mach/mach_types.h>
Expand Down
2 changes: 1 addition & 1 deletion Core/Scarab/tests/ScarabDataTest.cpp
Expand Up @@ -10,5 +10,5 @@
#include "ScarabDataTest.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabDataTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabDataTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( ScarabDataTestFixture );
2 changes: 1 addition & 1 deletion Core/Scarab/tests/ScarabFileTest.cpp
Expand Up @@ -10,5 +10,5 @@
#include "ScarabFileTest.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabFileTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabFileTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( ScarabFileTestFixture );
2 changes: 1 addition & 1 deletion Core/Scarab/tests/ScarabNetworkTest.cpp
Expand Up @@ -10,5 +10,5 @@
#include "ScarabNetworkTest.h"
using namespace mw;

//<disabled>CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabNetworkTestFixture, "Unit Test" );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ScarabNetworkTestFixture, "Unit Test" );
//CPPUNIT_TEST_SUITE_REGISTRATION( ScarabNetworkTestFixture );
65 changes: 32 additions & 33 deletions Core/Stimuli/StandardStimuli.cpp
Expand Up @@ -534,6 +534,20 @@ shared_ptr<mw::Component> BlankScreenFactory::createObject(std::map<std::string,
bool OpenGLImageLoader::initialized = false;
Lockable *OpenGLImageLoader::lock = NULL;

void OpenGLImageLoader::initialize(){
mprintf("initializing image loader facility");
OpenGLImageLoader::lock = new Lockable();
lock = OpenGLImageLoader::lock;

//lock->lock();
ilInit();
ilutInit();
ilutRenderer(ILUT_OPENGL);
ilutEnable(ILUT_OPENGL_CONV);
//lock->unlock();
OpenGLImageLoader::initialized = true;
}

GLuint OpenGLImageLoader::load(std::string filename, StimulusDisplay *display,
int *width, int *height) {

Expand Down Expand Up @@ -785,17 +799,7 @@ GLuint OpenGLImageLoader::load(std::string filename, StimulusDisplay *display,
fclose(test);

if(1 || !OpenGLImageLoader::initialized) {
mprintf("initializing image loader facility");
OpenGLImageLoader::lock = new Lockable();
lock = OpenGLImageLoader::lock;

//lock->lock();
ilInit();
ilutInit();
ilutRenderer(ILUT_OPENGL);
ilutEnable(ILUT_OPENGL_CONV);
//lock->unlock();
OpenGLImageLoader::initialized = true;
OpenGLImageLoader::initialize();
}


Expand Down Expand Up @@ -885,25 +889,18 @@ ImageStimulus::ImageStimulus(std::string _tag, std::string _filename,
shared_ptr<Variable> _alpha)
: BasicTransformStimulus(_tag, _xoffset, _yoffset,
_xscale ,_yscale, _rot, _alpha) {
// fprintf(stderr,"Creating image stimulus (filename = %s)\n",_filename.c_str());
// fflush(stderr);


filename = _filename;

texture_maps = new ExpandableList<GLuint>();
//image_loaded = false;
//il_image_name = 0;
width = 0;
height = 0;

// filename = _filename;
//image_loader = new OpenGLImageLoader();
}

// for cloning
ImageStimulus::ImageStimulus( std::string _tag,
std::string _filename,
ExpandableList<GLuint> *_texture_maps,
const vector<GLuint>& _texture_maps,
int _width, int _height,
shared_ptr<Variable> _xoffset,
shared_ptr<Variable> _yoffset, shared_ptr<Variable> _xscale,
Expand All @@ -917,8 +914,12 @@ ImageStimulus::ImageStimulus( std::string _tag,
// actually copy the string...
filename = _filename;

texture_maps = _texture_maps;
//image_loaded = false;
vector<GLuint>::const_iterator i;
for(i = _texture_maps.begin(); i != _texture_maps.end(); ++i){
texture_maps.push_back(*i);
}

//image_loaded = false;
//il_image_name = 0;
width = _width;
height = _height;
Expand Down Expand Up @@ -947,7 +948,6 @@ ImageStimulus::~ImageStimulus() {

}

delete texture_maps;
}


Expand All @@ -963,15 +963,15 @@ Stimulus * ImageStimulus::frozenClone(){
ImageStimulus *clone =
new ImageStimulus(tag,
filename,
new ExpandableList<GLuint>(*texture_maps),
texture_maps,
width,
height,
x_clone,
y_clone,
xs_clone,
ys_clone,
r_clone,
a_clone);
r_clone,
a_clone);


clone->setIsFrozen(true);
Expand All @@ -994,10 +994,13 @@ void ImageStimulus::load(StimulusDisplay *display) {
// TODO: this needs clean up. We are counting on all of the contexts
// in the stimulus display to have the exact same history. Ideally, this
// should be true, but we should eventually be robust in case it isn't
for(int i = 0; i < display->getNContexts(); i++){
texture_maps.clear();

for(int i = 0; i < display->getNContexts(); i++){
display->setCurrent(i);
GLuint texture_map = OpenGLImageLoader::load(filename, display, &width, &height);
texture_maps->addElement(i, texture_map);

texture_maps.push_back(texture_map);
// fprintf(stderr, "Loaded texture map %u into context %d\n", (unsigned int)texture_map, i);fflush(stderr);
if(texture_map){
mprintf("Image loaded into texture_map %d", texture_map);
Expand Down Expand Up @@ -1026,11 +1029,7 @@ void ImageStimulus::drawInUnitSquare(StimulusDisplay *display) {

//glActiveTexture(GL_TEXTURE0);

// fprintf(stderr, "Binding texture %lu on context index %u (context %u)",
// *(texture_maps->getElement(display->getCurrentContextIndex())),
// display->getCurrentContextIndex(),
// (unsigned int)display->getCurrentContext());fflush(stderr);
glBindTexture(GL_TEXTURE_2D, *(texture_maps->getElement(display->getCurrentContextIndex())));
glBindTexture(GL_TEXTURE_2D, texture_maps[display->getCurrentContextIndex()]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glEnable (GL_BLEND);
Expand Down
9 changes: 5 additions & 4 deletions Core/Stimuli/StandardStimuli.h
Expand Up @@ -110,15 +110,16 @@ class OpenGLImageLoader {
static bool initialized;
static Lockable *lock;

static GLuint load(std::string filename, StimulusDisplay *display,
static void initialize();
static GLuint load(std::string filename, StimulusDisplay *display,
int *width, int *height);
};

// Image file based stimulus
class ImageStimulus : public BasicTransformStimulus {
protected:
std::string filename;
ExpandableList<GLuint> *texture_maps;
vector<GLuint> texture_maps;
int width, height;

// for debugging
Expand All @@ -134,14 +135,14 @@ class ImageStimulus : public BasicTransformStimulus {
shared_ptr<Variable> _alpha);
// constructor for cloning an existing image stimulus
ImageStimulus(std::string _tag, std::string _filename,
ExpandableList<GLuint> *_texture_maps,
const vector<GLuint>& _texture_maps,
int _width,
int _height,
shared_ptr<Variable> _xoffset,
shared_ptr<Variable> _yoffset,
shared_ptr<Variable> _xscale,
shared_ptr<Variable> _yscale,
shared_ptr<Variable> _rot,
shared_ptr<Variable> _rot,
shared_ptr<Variable> _alpha);

ImageStimulus(ImageStimulus& copy);
Expand Down

0 comments on commit 46e570a

Please sign in to comment.