// overridable base class method // assumes data have already been checked for proper dictionary, name. CalibratorRequestedAction Calibrator::getRequestedAction(Datum dictionaryData) { // check what action is requested (e.g. update parameters) if (!(dictionaryData.hasKey(R_CALIBRATOR_ACTION))) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s that did not contain an action field was ignored.", uniqueCalibratorName.c_str()); return(CALIBRATOR_NO_ACTION); } Datum actionData = dictionaryData.getElement(R_CALIBRATOR_ACTION); if (!(actionData.getDataType() == M_STRING)) { // check if name field is a string mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s that did not contain a string in the action field was ignored.", uniqueCalibratorName.c_str()); return(CALIBRATOR_NO_ACTION); } if (actionData.getString() == R_CALIBRATOR_ACTION_SET_PARAMETERS) { // check is name field matches the name of this calibrator if (VERBOSE_EYE_CALIBRATORS>1) mprintf( "Calibrator %s successfully received request for to update its parameters to contained values.", uniqueCalibratorName.c_str()); return CALIBRATOR_ACTION_SET_PARAMS_TO_CONTAINED; } else if (actionData.getString() == R_CALIBRATOR_ACTION_SET_PARAMETERS_TO_DEFAULTS) { if (VERBOSE_EYE_CALIBRATORS>1) mprintf("Calibrator %s successfully received request for to update its parameters to defaults.", uniqueCalibratorName.c_str()); return CALIBRATOR_ACTION_SET_PARAMS_TO_DEFAULTS; } else { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Calibrator %s received a request, but action was unknown. Request ignored", uniqueCalibratorName.c_str()); return CALIBRATOR_NO_ACTION; } return (CALIBRATOR_NO_ACTION); }
// compute the function value(s) with the current parameters //bool LinearFitableFunction::applyTheFunction(Datum *pInputData, Datum *outputData){ // DDC fix bool LinearFitableFunction::applyTheFunction(const Datum& pInputData, Datum *outputData){ lock(); if (Parameters == NULL) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "WARNING: Prompted for calibrated value but parameters not yet set."); unlock(); return false; } //if (pInputData->getNElements() != numInputs) { // DDC fix if (pInputData.getNElements() != numInputs) { // //int xxx0 = pInputData->getNElements(); // DDC fix // int xxx0 = pInputData.getNElements(); // //double xxx1 = (double)(pInputData->getElement(0)); // DDC fix // //double xxx2 = (double)(pInputData->getElement(1)); // double xxx1 = (double)(pInputData.getElement(0)); // DDC fix // double xxx2 = (double)(pInputData.getElement(1)); mwarning(M_SYSTEM_MESSAGE_DOMAIN, "WARNING: Prompted for calibrated value but not all input data exists."); unlock(); return false; } double *inputDataDouble = new double [numInputs]; for (int i=0;i<numInputs;i++) { //inputDataDouble[i] = (double)(pInputData->getElement(i)); // copy data here // DDC fix inputDataDouble[i] = (double)(pInputData.getElement(i)); // copy data here // DDC fix //xxx = inputDataDouble[i]; //TODO -- remove } double temp = 0; for (int p=0; p< (basisSet->getNElements()); p++) { temp = temp + ((Parameters[p])*((basisSet->getElement(p))->applyBasis(inputDataDouble))); //ppp = Parameters[p]; //TODO -- remove } *outputData = Datum(temp);//DDC edit //*outputData = (Datum)temp; delete [] inputDataDouble; // DDC added unlock(); return true; }
bool Eyelink::startDeviceIO(){ boost::mutex::scoped_lock lock(EyelinkDriverLock); if(eyelink_is_connected() && stopped) { //Eyelink to offline mode set_offline_mode(); // Eyelink to record mode if( start_recording(0,1,1,0) ) { merror(M_IODEVICE_MESSAGE_DOMAIN, "Eyelink does not start!"); } shared_ptr<Scheduler> scheduler = Scheduler::instance(); shared_ptr<Eyelink> this_one = component_shared_from_this<Eyelink>(); schedule_node = scheduler->scheduleUS(std::string(FILELINE ": ") + getTag(), update_period, //defer first start one period update_period, //repeat interval M_REPEAT_INDEFINITELY, boost::bind(update_, this_one), M_DEFAULT_IODEVICE_PRIORITY, M_DEFAULT_IODEVICE_WARN_SLOP_US, M_DEFAULT_IODEVICE_FAIL_SLOP_US, M_MISSED_EXECUTION_DROP); stopped = false; mprintf(M_IODEVICE_MESSAGE_DOMAIN, "Eyelink successfully started."); } else { mwarning(M_IODEVICE_MESSAGE_DOMAIN, "Warning! Could not start EyeLink! (StartIO)"); } return !stopped; }
int RandomWithReplacementSelection::draw() { if(done_so_far >= n_draws){ if(autoreset){ mwarning(M_PARADIGM_MESSAGE_DOMAIN, "Autoresetting selection object"); reset(); } else { SelectionOffEdgeException e; throw e; } } // Make a random selection boost::uniform_int<> our_range(0, getNItems()-1); boost::variate_generator<random_generator&, boost::uniform_int<> > dice(rng, our_range); int returnval = dice(); //int returnval = (int)(getNItems() * (float)rand()/(float)RAND_MAX); // Save the selection on the tentative selections list tentative_selections.push_back(returnval); done_so_far++; return returnval; }
Program createProgram(const std::vector<GLuint> &shaders) { Program program(glCreateProgram()); if (!program) { throw OpenGLException("Program creation failed", glGetError()); } for (GLuint shader : shaders) { glAttachShader(program.get(), shader); GLenum error = glGetError(); if (error != GL_NO_ERROR) { throw OpenGLException("Shader attachment failed", error); } } glLinkProgram(program.get()); GLint infoLogLength; glGetProgramiv(program.get(), GL_INFO_LOG_LENGTH, &infoLogLength); if (infoLogLength > 0) { std::vector<GLchar> infoLog(infoLogLength); glGetProgramInfoLog(program.get(), infoLogLength, nullptr, infoLog.data()); mwarning(M_DISPLAY_MESSAGE_DOMAIN, "OpenGL: Program linking produced the following information log:\n%s", infoLog.data()); } GLint linkStatus; glGetProgramiv(program.get(), GL_LINK_STATUS, &linkStatus); if (linkStatus != GL_TRUE) { throw OpenGLException("Program linking failed"); } return program; }
Shader createShader(GLenum shaderType, const std::string &glslVersion, const std::string &shaderSource) { Shader shader(glCreateShader(shaderType)); if (!shader) { throw OpenGLException("Shader creation failed", glGetError()); } const std::array<const GLchar *, 5> strings = { "#version ", glslVersion.data(), "\n", "precision highp float;\n", shaderSource.data() }; glShaderSource(shader.get(), strings.size(), strings.data(), nullptr); glCompileShader(shader.get()); GLint infoLogLength; glGetShaderiv(shader.get(), GL_INFO_LOG_LENGTH, &infoLogLength); if (infoLogLength > 0) { std::vector<GLchar> infoLog(infoLogLength); glGetShaderInfoLog(shader.get(), infoLogLength, nullptr, infoLog.data()); mwarning(M_DISPLAY_MESSAGE_DOMAIN, "OpenGL: Shader compilation produced the following information log:\n%s", infoLog.data()); } GLint compileStatus; glGetShaderiv(shader.get(), GL_COMPILE_STATUS, &compileStatus); if (compileStatus != GL_TRUE) { throw OpenGLException("Shader compilation failed"); } return shader; }
NIDAQDigitalChannel::NIDAQDigitalChannel(const ParameterValueMap ¶meters) : Component(parameters), portNumber(parameters[PORT_NUMBER]), numLinesInPort(parameters[NUM_LINES_IN_PORT]) { if (portNumber < 0) { throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid port number"); } if (numLinesInPort < 1) { throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid number of lines in port"); } if (numLinesInPort % 4 != 0) { mwarning(M_IODEVICE_MESSAGE_DOMAIN, "Reported number of lines (%d) in port %d of NIDAQ device is not a multiple of 4", numLinesInPort, portNumber); } for (std::size_t lineNumber = 0; lineNumber < maxNumLines; lineNumber++) { const ParameterValue &lineParameter = parameters[getLineParameterName(lineNumber)]; if (!lineParameter.empty()) { if (lineNumber >= numLinesInPort) { throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Requested line number exceeds number of lines in port"); } lineVariables.at(lineNumber) = VariablePtr(lineParameter); } } }
void Client::handleEvent(shared_ptr<Event> evt) { int code = evt->getEventCode(); switch (code) { case RESERVED_CODEC_CODE: registry->updateFromCodecDatum(evt->getData()); // Request updated values for all variables putEvent(SystemEventFactory::requestVariablesUpdateControl()); break; case RESERVED_SYSTEM_EVENT_CODE: { auto &sysEvent = evt->getData(); if (sysEvent.getElement(M_SYSTEM_PAYLOAD_TYPE).getInteger() == M_SERVER_CONNECTED_CLIENT) { long clientID = sysEvent.getElement(M_SYSTEM_PAYLOAD).getInteger(); std::lock_guard<std::mutex> lock(connectedEventReceivedMutex); if (remoteConnection && clientID == reinterpret_cast<long>(remoteConnection.get())) { // Received connection acknowledgement from server. Notify any thread waiting // in connectToServer. connectedEventReceived = true; connectedEventReceivedCondition.notify_all(); } } break; } case RESERVED_TERMINATION_CODE: mwarning(M_CLIENT_MESSAGE_DOMAIN, "Received termination notification from server; disconnecting"); (void)disconnectClient(); break; default: break; } handleCallbacks(evt); if(code >= N_RESERVED_CODEC_CODES && code < registry->getNVariables() + N_RESERVED_CODEC_CODES) { shared_ptr <Variable> var = registry->getVariable(code); if(var) { var->setSilentValue(evt->getData()); } else { mwarning(M_CLIENT_MESSAGE_DOMAIN, "Invalid variable, client not processing event code: %d", code); } } }
// PUBLIC METHOD void Calibrator::notifyPrivate(const Datum& original_data, MWTime timeUS) { // base class -- not clear what to do. lock(); mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Notification of calibrator base class should have been overriden. Private variable change ignored"); unlock(); }
Transparency ScopedVariableContext::getTransparency(int i){ if(i < 0 || i > (int)transparency.size()){ mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Attempt to access invalid index in variable context"); return M_TRANSPARENT; } return transparency[i]; }
Eyelink::~Eyelink(){ boost::mutex::scoped_lock lock(EyelinkDriverLock); if (Eyelink_Initialized) { if (!stopped) { mwarning(M_IODEVICE_MESSAGE_DOMAIN,"Eyelink is still running !"); //eyelink stop recording if(eyelink_is_connected()) { stop_recording(); } } if (schedule_node) { schedule_node->cancel(); schedule_node.reset(); } if(eyelink_is_connected()) { // Places EyeLink tracker in off-line (idle) mode set_offline_mode(); // close any open data files if ( close_data_file() == 0 ) { mprintf(M_IODEVICE_MESSAGE_DOMAIN,"Eyelink closed data file %s.",data_file_name); } if (eyelink_close(1)) // disconnect from tracker { merror(M_IODEVICE_MESSAGE_DOMAIN, "Could not close Eyelink connection"); } //close_eyelink_system(); mprintf(M_IODEVICE_MESSAGE_DOMAIN, "Eyelink %d System Version %s disconnected.",tracker_version,version_info); } else { mwarning(M_IODEVICE_MESSAGE_DOMAIN,"Error, Eyelink Shutdown failed"); } Eyelink_Initialized = false; } }
void Timer::startUS(MWTime howlongus) { scoped_lock lock(mutex); if (howlongus <= 0) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Scheduling a timer to fire at a time in the past"); } expirationTimeUS = clock->getCurrentTimeUS() + howlongus; }
bool mFakeMonkeyFixate::execute(){ if(monkey == 0){ mwarning(M_IODEVICE_MESSAGE_DOMAIN, "Attempt to direct a NULL monkey"); } monkey->fixate(duration->getValue().getInteger()); return true; }
bool PairedEyeData::getAvailable(double *pEyeH, double *pEyeV, MWTime *pEyeTimeUS) { if ( (eyeH_buffer_reader->getNItemsUnserviced()==0) || (eyeV_buffer_reader->getNItemsUnserviced()==0) ) { return false; // no data in one or more buffers } bool diffWarned = false; // keep trying to find paired data long diff; MWTime eyeVtimeUS, eyeHtimeUS; while ( (eyeH_buffer_reader->getNItemsUnserviced()>0) && (eyeV_buffer_reader->getNItemsUnserviced()>0) ) { *pEyeV = (double)(eyeV_buffer_reader->getData()); eyeVtimeUS = eyeV_buffer_reader->getTime(); *pEyeH = (double)(eyeH_buffer_reader->getData()); eyeHtimeUS = eyeH_buffer_reader->getTime(); diff = (long)(eyeHtimeUS-eyeVtimeUS); if (std::abs(diff) <= M_MAXIMAL_ALLOWED_EYE_PAIR_SEPARATION_US) { // data alignment acceptable to use *pEyeTimeUS = eyeHtimeUS; eyeH_buffer_reader->advance(); eyeV_buffer_reader->advance(); return true; // data should be used by object } if (!diffWarned) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "mPairedEyeData: Eye H and V data are not paired in time within required limit of %d us. They are separated by %ld us (+ means old V data has no paired H). Correcting by discarding unpaired data.", M_MAXIMAL_ALLOWED_EYE_PAIR_SEPARATION_US, diff); diffWarned = true; } // try to align data by discarding old data that has no possibility of being paired // (note: this assumes that the data arrive to the object in chronological order !) if (eyeHtimeUS>eyeVtimeUS) { // eyeV is too old -- kill it //mprintf("Ignoring one element of eye V data"); eyeV_buffer_reader->advance(); } else { //mprintf("Ignoring one element of eye H data"); eyeH_buffer_reader->advance(); } } // if we exit the while loop, one or more buffers is empty return false; }
bool StandardServerCoreBuilder::initializeGlobalParameters() { initializeStandardVariables(global_variable_registry); try { loadSetupVariables(); } catch (std::exception& e){ mwarning(M_PARSER_MESSAGE_DOMAIN, "Unable to load setup variables. Error was: %s", e.what()); } GlobalMessageOrigin = M_SERVER_MESSAGE_ORIGIN; return true; }
// method to announce details about each sample that is acquired for calibration void EyeCalibrator::announceCalibrationSample(int outputIndex, Datum SampledData, Datum DesiredOutputData, Datum CalibratedOutputData, MWTime timeOfSampleUS) { // this method expects the H sample to arrive first and then the V sample if (outputIndex == outputIndexH) { // store data and wait for v (announce as pair) desiredH = DesiredOutputData; calibratedH = CalibratedOutputData; sampledH = (&SampledData)->getElement(inputIndexH); HsampleTime = timeOfSampleUS; return; } if (outputIndex == outputIndexV) { // store data and wait for v (announce as pair) desiredV = DesiredOutputData; calibratedV = CalibratedOutputData; sampledV = (&SampledData)->getElement(inputIndexV); if ( (std::abs(timeOfSampleUS-HsampleTime)) > 10000) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Calibrator sample announce detected large time differential between h and v samples. Values likely inaccurate."); } } Datum announceData(M_DICTIONARY, 5); announceData.addElement(CALIBRATOR_NAME,uniqueCalibratorName); // char announceData.addElement(CALIBRATOR_ACTION,CALIBRATOR_ACTION_SAMPLE); { Datum temp(M_LIST, 2); temp.setElement(0,sampledH); temp.setElement(1,sampledV); announceData.addElement(CALIBRATOR_SAMPLE_SAMPLED_HV,temp); // input values } { Datum temp(M_LIST, 2); temp.setElement(0,desiredH); temp.setElement(1,desiredV); announceData.addElement(CALIBRATOR_SAMPLE_DESIRED_HV,temp); // gold standard values } { Datum temp(M_LIST, 2); temp.setElement(0,calibratedH); temp.setElement(1,calibratedV); announceData.addElement(CALIBRATOR_SAMPLE_CALIBRATED_HV,temp); // values produced from input values using current calibration } //announceData.addElement("JJDtest",desiredH); // values produced from input values using current calibration if (VERBOSE_EYE_CALIBRATORS) mprintf("mCalibrator::announceCalibrationSample Announcing now"); announce(announceData); // announce things here using method from Announcable }
CVReturn StimulusDisplay::displayLinkCallback(CVDisplayLinkRef _displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *_display) { StimulusDisplay *display = static_cast<StimulusDisplay*>(_display); { unique_lock lock(display->display_lock); if (bool(warnOnSkippedRefresh->getValue())) { if (display->lastFrameTime) { int64_t delta = (outputTime->videoTime - display->lastFrameTime) - outputTime->videoRefreshPeriod; if (delta) { mwarning(M_DISPLAY_MESSAGE_DOMAIN, "Skipped %g display refresh cycles", (double)delta / (double)(outputTime->videoRefreshPeriod)); } } } display->lastFrameTime = outputTime->videoTime; // // Here's how the time calculation works: // // outputTime->hostTime is the (estimated) time that the frame we're currently drawing will be displayed. // The value is in units of the "host time base", which appears to mean that it's directly comparable to // the value returned by mach_absolute_time(). However, the relationship to mach_absolute_time() is not // explicitly stated in the docs, so presumably we can't depend on it. // // What the CoreVideo docs *do* say is "the host time base for Core Video and the one for CoreAudio are // identical, and the values returned from either API can be used interchangeably". Hence, we can use the // CoreAudio function AudioConvertHostTimeToNanos() to convert from the host time base to nanoseconds. // // Once we have a system time in nanoseconds, we substract the system base time and convert to // microseconds, which leaves us with a value that can be compared to clock->getCurrentTimeUS(). // display->currentOutputTimeUS = (MWTime(AudioConvertHostTimeToNanos(outputTime->hostTime)) - display->clock->getSystemBaseTimeNS()) / 1000LL; display->refreshDisplay(); display->waitingForRefresh = false; } // Signal waiting threads that refresh is complete display->refreshCond.notify_all(); return kCVReturnSuccess; }
void EyeStatusMonitor::newDataReceived(int inputIndex, const Datum& data, MWTime timeUS) { // DDC: be careful //lock(); double eyeDataIn = (double)data; double eyeDataOut; MWTime postFilterTimeUS; //mprintf(" **** EyeStatusMonitor::newDataReceived. inputIndex = %d, data = %f, time = %d us", // inputIndex, (double)data, (long)timeUS); // every piece of data gets boxcar filtered // the filters are smart enough to manage their own memory if (inputIndex==eyeHindex) { filterH->input(eyeDataIn, timeUS); filterH->output(&eyeDataOut, &postFilterTimeUS); pairedEyeData->putDataH(eyeDataOut, postFilterTimeUS); } else if (inputIndex==eyeVindex) { filterV->input(eyeDataIn, timeUS); filterV->output(&eyeDataOut, &postFilterTimeUS); pairedEyeData->putDataV(eyeDataOut, postFilterTimeUS); // DDC: experimental: stop hammer this thing so hard? //unlock(); return; } else { mwarning(M_SYSTEM_MESSAGE_DOMAIN, " **** EyeStatusMonitor::newDataReceived Unknown input index"); } // update the eye status based on current information // we also update the time of the change and these times are all based // on the times sent through the notification objects. // Thus, the time posted (below) represents our best estiamte of the real time // that the eye status actually changed (even if it takes additonal time delay // to get through the filters and/or propogate all the way back to a variable change. // if a pair is ready, pull it out and process it MWTime eyeTimeUS; double eyeH, eyeV; while (pairedEyeData->getAvailable(&eyeH, &eyeV, &eyeTimeUS)) { processAndPostEyeData(eyeH,eyeV,eyeTimeUS); } //unlock(); }
void *scheduled_action_runner(const shared_ptr<ScheduledActions> &sa) { shared_ptr <Clock> clock = Clock::instance(); MWTime delta = clock->getCurrentTimeUS() - ((sa->getTimeScheduled() + sa->getDelay()) + sa->getNRepeated()*sa->getInterval()); if(delta > 2000) { merror(M_SCHEDULER_MESSAGE_DOMAIN, "Scheduled action is starting %lldus behind intended schedule", delta); } else if (delta > 500) { mwarning(M_SCHEDULER_MESSAGE_DOMAIN, "Scheduled action is starting %lldus behind intended schedule", delta); } sa->executeActions(); return 0; }
void AsynchronousTrigger::addVariable(shared_ptr<Variable> var){ if(var == NULL){ mwarning(M_PARADIGM_MESSAGE_DOMAIN, "Attempt to add a notification to a null variable"); return; } shared_ptr<AsynchronousTriggerNotification> notif( new AsynchronousTriggerNotification(this)); var->addNotification(notif); notifications->addReference(notif); }
bool mFakeMonkeySaccadeAndFixate::execute(){ if(monkey == NULL){ mwarning(M_IODEVICE_MESSAGE_DOMAIN, "Attempt to direct a NULL monkey"); } monkey->saccadeTo(h_loc->getValue().getFloat(), v_loc->getValue().getFloat(), duration->getValue().getInteger()); return true; }
// Use a registered factory to create a new object and register the // result in the instances map // Returns true on success, false on failure shared_ptr<mw::Component> ComponentRegistry::registerNewObject(std::string tag_name, std::string type_name, std::map<std::string, std::string> parameters) { shared_ptr<mw::Component> obj = this->createNewObject(type_name, parameters); if(obj != NULL){ // put it into the instances map registerObject(tag_name, obj); } else { mwarning(M_PARSER_MESSAGE_DOMAIN, "Null object created"); } return obj; }
void StimulusDisplay::setMainDisplayRefreshRate() { CVTime refreshPeriod = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLinks.at(0)); double refreshRate = 60.0; if (refreshPeriod.flags & kCVTimeIsIndefinite) { mwarning(M_DISPLAY_MESSAGE_DOMAIN, "Could not determine main display refresh rate. Assuming %g Hz.", refreshRate); } else { refreshRate = double(refreshPeriod.timeScale) / double(refreshPeriod.timeValue); } mainDisplayRefreshRate = refreshRate; }
// this routine checks that the request is a dictionary and that it contains a name that matches the calibrator bool Calibrator::checkRequest(Datum dictionaryData) { Datum data; // to hold field data for checking // check if this is a dictionary if (!(dictionaryData.getDataType() == M_DICTIONARY)) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s that was not expected dictionary type was ignored.", uniqueCalibratorName.c_str()); return(false); } // check if there is a name field and if this calibrator should respond (i.e. if it has the correct name) if (!(dictionaryData.hasKey(R_CALIBRATOR_NAME))) { mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s that did not contain name field was ignored.", uniqueCalibratorName.c_str()); return(false); } Datum nameData = dictionaryData.getElement(R_CALIBRATOR_NAME); if (!(nameData.getDataType() == M_STRING)) { // check if name field is a string mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s that did not contain a string in the name field was ignored.", uniqueCalibratorName.c_str()); return(false); } if (uniqueCalibratorName == nameData.getString()) { // check is name field matches the name of this calibrator if (VERBOSE_EYE_CALIBRATORS) mprintf("Calibrator %s successfully received a properly named request.", uniqueCalibratorName.c_str()); } else { if (VERBOSE_EYE_CALIBRATORS) mprintf("Calibrator %s received a request, but name did not match.", uniqueCalibratorName.c_str()); return(false); // request not meant for this calibrator (can be normal behavior -- no warnings) } return true; }
void Experiment::setCurrentProtocol(std::string protName) { mprintf("Setting protocol to %s", protName.c_str()); if(protName.size() == 0) { return; } for(unsigned int i = 0; i < getList().size(); i++) { std::string comp = (getList()[i])->getName(); if(comp == protName){ setCurrentProtocol(i); return; } } // if the name was never found print a warning mwarning(M_PARADIGM_MESSAGE_DOMAIN, "Attempt to set Experiment to missing protocol -(%s)-", protName.c_str()); }
void ScheduledActions::executeOnce() { MWTime delta = clock->getCurrentTimeUS() - ((timeScheduled + scheduledDelay) + nRepeated * scheduledInterval); if (delta > 2000) { merror(M_SCHEDULER_MESSAGE_DOMAIN, "Scheduled action is starting %lldus behind intended schedule", delta); } else if (delta > 500) { mwarning(M_SCHEDULER_MESSAGE_DOMAIN, "Scheduled action is starting %lldus behind intended schedule", delta); } for (auto &action : action_list) { action->announceEntry(); action->execute(); } nRepeated++; }
int DataFileManager::openFile(const Datum &oeDatum) { std::string dFile(oeDatum.getElement(DATA_FILE_FILENAME).getString()); DatumFileOptions opt = (DatumFileOptions)oeDatum.getElement(DATA_FILE_OPTIONS).getInteger(); if(dFile.size() == 0) { merror(M_FILE_MESSAGE_DOMAIN, "Attempt to open an empty data file"); return -1; } if(GlobalDataFileManager->isFileOpen()) { mwarning(M_FILE_MESSAGE_DOMAIN, "Data file already open at %s", (GlobalDataFileManager->getFilename()).c_str()); return -1; } return openFile(dFile, opt); }
bool Eyelink::stopDeviceIO() { boost::mutex::scoped_lock lock(EyelinkDriverLock); if(!stopped) { if (schedule_node) { schedule_node->cancel(); schedule_node.reset(); } if(eyelink_is_connected()) { //eyelink stop recording stop_recording(); //go to eyelink offline mode set_offline_mode(); } else mwarning(M_IODEVICE_MESSAGE_DOMAIN, "Warning! Could not stop EyeLink! Connection Lost!! (StopIO)"); if (e_time != NULL) e_time -> setValue( (float)MISSING_DATA ); if (e_rx != NULL) e_rx -> setValue( (float)MISSING_DATA ); if (e_ry != NULL) e_ry -> setValue( (float)MISSING_DATA ); if (e_lx != NULL) e_lx -> setValue( (float)MISSING_DATA ); if (e_ly != NULL) e_ly -> setValue( (float)MISSING_DATA ); if (e_x != NULL) e_x -> setValue( (float)MISSING_DATA ); if (e_y != NULL) e_y -> setValue( (float)MISSING_DATA ); if (e_z != NULL) e_z -> setValue( (float)MISSING_DATA ); if (h_rx != NULL) h_rx -> setValue( (float)MISSING_DATA ); if (h_ry != NULL) h_ry -> setValue( (float)MISSING_DATA ); if (h_lx != NULL) h_lx -> setValue( (float)MISSING_DATA ); if (h_ly != NULL) h_ly -> setValue( (float)MISSING_DATA ); if (p_rx != NULL) p_rx -> setValue( (float)MISSING_DATA ); if (p_ry != NULL) p_ry -> setValue( (float)MISSING_DATA ); if (p_lx != NULL) p_lx -> setValue( (float)MISSING_DATA ); if (p_ly != NULL) p_ly -> setValue( (float)MISSING_DATA ); if (p_r != NULL) p_r -> setValue( (float)MISSING_DATA ); if (p_l != NULL) p_l -> setValue( (float)MISSING_DATA ); stopped = true; mprintf(M_IODEVICE_MESSAGE_DOMAIN, "Eyelink successfully stopped."); } return stopped; }
BEGIN_NAMESPACE_MW // all of these units should be assumed to be arbitrary, even though they many are tagged // by the term "deg" TODO -- drop all the "deg" refs // === EyeStatusMonitor is a very specific type of var transform adaptor ====== // the input data is expected to be calibrated eye data EyeStatusMonitor::EyeStatusMonitor(shared_ptr<Variable> _eyeHCalibratedVar, shared_ptr<Variable> _eyeVCalibratedVar, shared_ptr<Variable> _eyeStatusVar, int _filterWidthSamples) { // _filterWidthSamples is used for both the eye signale filters and the // velocity filters in the eyeStatusComputer // pointers to the input vars -- will setup notifications eyeHindex = registerInput(_eyeHCalibratedVar); // input 0 eyeVindex = registerInput(_eyeVCalibratedVar); // input 1 // pointers to the output vars eyeStatusIndex = registerOutput(_eyeStatusVar); // TODO -- should we post an update to this variable immediately? eyeStatus = M_EYE_STATUS_UNKNOWN; shared_ptr <Clock> clock = Clock::instance(); eyeStatusTimeUS = clock->getCurrentTimeUS(); // get current time // setup boxcar filters -- could use another filter down the road int filterWidthSamples = _filterWidthSamples; if (_filterWidthSamples<1) { filterWidthSamples = 1; mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Tried to create eye status monitor boxcar filters with width <1, setting to 1 (no filtering)"); } filterH = new BoxcarFilter1D(filterWidthSamples); filterV = new BoxcarFilter1D(filterWidthSamples); int buffer_size = M_ASSUMED_EYE_SAMPLES_PER_MS * M_MAX_EYE_BUFFER_SIZE_MS; pairedEyeData = new PairedEyeData(buffer_size); // object to pair eye data }
// PUBLIC METHOD // triggered by any change to the calibrator request variable void EyeCalibrator::notifyRequest(const Datum& dictionaryData, MWTime timeUS) { lock(); // DDC added // check if this calibrator should respond bool validRequest = checkRequest(dictionaryData); // base class method (minimal checking) if (!validRequest){ unlock(); // DDC added return; // not meant for this calibrator or improperly formatted } // determine the requested action CalibratorRequestedAction requestedAction = getRequestedAction(dictionaryData); // overridable base class method switch (requestedAction) { case CALIBRATOR_NO_ACTION: mwarning(M_SYSTEM_MESSAGE_DOMAIN, "Request sent to calibrator %s resulted in no action.", uniqueCalibratorName.c_str()); unlock(); // DDC added return; break; case CALIBRATOR_ACTION_SET_PARAMS_TO_DEFAULTS: //mwarning(M_SYSTEM_MESSAGE_DOMAIN, // "Request to update params sent to calibrator %s, BUT METHOD NOT YET WRITTEN. Request ignored.", uniqueCalibratorName); if (VERBOSE_EYE_CALIBRATORS) mprintf("An eye calibrator is processing a request to set its parameters to defaults."); setParametersToDefaults(); break; break; case CALIBRATOR_ACTION_SET_PARAMS_TO_CONTAINED: if (VERBOSE_EYE_CALIBRATORS) mprintf("An eye calibrator is processing a request to set its parameters to specific values."); tryToUseDataToSetParameters(dictionaryData); break; } unlock(); // DDC added }