Beispiel #1
0
void EyeStatusMonitorVer1::processAndPostEyeData(double _eyeHdeg, double _eyeVdeg, MWTime _eyeTimeUS) {
    
    // call a transform object to do the computation of eye status right away
    //mprintf("  *** calling eyeStatus computer...");
    eyeStatusComputer->input(_eyeHdeg, _eyeVdeg, _eyeTimeUS);
    
    if (eyeStatusComputer->output(eyeStatus, eyeStatusTimeUS, eyeVelocity)) {
        // base class method to post the new eye status to the variable
        //      --> this will trigger any notifications for these vars
        //mprintf("  *** posting results from eyeStatus computer:  eyeStatus = %d", eyeStatus);
        postResults(eyeStatusIndex, (Datum)((long)eyeStatus), eyeStatusTimeUS);
        if (-1 != eyeVelocityHIndex) {
            postResults(eyeVelocityHIndex, eyeVelocity.h, eyeStatusTimeUS);
        }
        if (-1 != eyeVelocityVIndex) {
            postResults(eyeVelocityVIndex, eyeVelocity.v, eyeStatusTimeUS);
        }
    }
    
}
Beispiel #2
0
// PUBLIC METHOD
// this is the common entry method for all "input" variables of any calibrator
// thus, it is invoked every time any one of the input variables is updated
// this happens through a notification object that communicates with this class
//  at the level of the base class "mVarTransformAdaptor".
// the main jobs of this method are to:
//    1) locally "save" the data the is brought in on the input variable.
//    2) apply the current calibration function (operates over "saved" values of potentially ALL input variables) 
void Calibrator::newDataReceived(int inputIndex, const Datum& data, 
                                                MWTime timeUS) {
    
	lock(); // DDC added
    if (!initialized){
		unlock();
		return;
    }
	
	
    // for now, just keep the most recent value (for calibration)
    pUncalibratedData->setElement(inputIndex,data);   // this is used for filtering
    pSampledData->setElement(inputIndex,data);        // this is what is used for calibration samples
    timeOfMostRecentUncalibratedDataUS = timeUS;
        
    
    // if the averager is running, take the sample  
    // (this happens in the background -- the averager is instatiated when this object is instantiated)
        
        
    // compute the calibrated values if possible
    // -- note -- this will compute ALL of the outputs given the inputs
    //Ffor calibrators with more than one output (e.g. eye calibrators), this
    //  means that the calibrated eye values will be posted (e.g.) twice as
    // often as the uncalibrated eye samples.  
    // I think this is the right behavior, and it can easily be overriden if desired.
    
    bool noErr = true;
    Datum calibData;
    for (int outputIndex=0;outputIndex<this->getNumOutputs();outputIndex++) {
        noErr = (fitableFunctions->getElement(outputIndex))->
                        //applyTheFunction(pUncalibratedData, &calibData);  // DDC fix
						applyTheFunction(*pUncalibratedData, &calibData);
        if (noErr) {
            postResults(outputIndex, calibData, timeUS);               
            pCalibratedData->setElement(outputIndex,calibData);   // keep a copy of the last outs
        }
    }
    
    unlock(); // DDC added
}
Beispiel #3
0
// JJD overrode the base class function on Nov 2, 2006, so that the eye calibrator 
// will wait for paired input from BOTH channels before posting
void EyeCalibrator::newDataReceived(int inputIndex, const Datum& data, 
                                                MWTime timeUS) {
    
	lock(); 
    if (!initialized){
		unlock();
		return;
    }
	
	
    //pUncalibratedData->setElement(inputIndex,data);   // this is used for filtering
    pSampledData->setElement(inputIndex,data);        // this is what is used for calibration samples
    timeOfMostRecentUncalibratedDataUS = timeUS;
        
    // if the averager is running, take the sample  
    // (this happens in the background -- the averager is instatiated when this object is instantiated)
    
    
    // check to see if we have a correct pair of values that we should compute calibration on
    // process and post all such pairs now
    
    if (inputIndex==inputIndexH) {
        pairedEyeData->putDataH(data, timeUS);
	}
	else if (inputIndex==inputIndexV) {
        pairedEyeData->putDataV(data, timeUS);
	}
    else {
        mwarning(M_SYSTEM_MESSAGE_DOMAIN,
			" **** EyeStatusMonitor::newDataReceived  Unknown input index");
        unlock();
        return;
    }
	
     

    // if a pair is ready, pull it out and process it
    MWTime eyeTimeUS;
    double eyeH, eyeV;
    bool noErr = true;
    Datum calibData;
    
    while (pairedEyeData->getAvailable(&eyeH, &eyeV, &eyeTimeUS)) {
    
        // put the paired values in the input vector for the calibration function
        pUncalibratedData->setElement(inputIndexH,(Datum)eyeH);
        pUncalibratedData->setElement(inputIndexV,(Datum)eyeV);
        
        
        for (int outputIndex=0;outputIndex<this->getNumOutputs();outputIndex++) {
            noErr = (fitableFunctions->getElement(outputIndex))->
						applyTheFunction(*pUncalibratedData, &calibData);
            if (noErr) {
                postResults(outputIndex, calibData, timeUS);               
                pCalibratedData->setElement(outputIndex,calibData);   // keep a copy of the last outs
            }
        }
    }
    
    unlock(); 
}