29 #include "../Kernel/OVR_Log.h"
30 #include "../Kernel/OVR_Timer.h"
32 namespace OVR {
namespace Util {
86 Device->SetConfiguration(configuration,
true);
99 UInt32 val = rand() % range;
111 OVR_DEBUG_LOG((
"State_WaitingForButton -> State_WaitingForSettlePreCalibrationColorBlack."));
148 OVR_DEBUG_LOG((
"State_WaitingForSettlePreCalibrationColorBlack -> State_WaitingForSettlePostCalibrationColorBlack."));
158 OVR_DEBUG_LOG((
"State_WaitingForSettlePostCalibrationColorBlack -> State_WaitingForSettlePreCalibrationColorWhite."));
168 OVR_DEBUG_LOG((
"State_WaitingForSettlePreCalibrationColorWhite -> State_WaitingForSettlePostCalibrationColorWhite."));
178 OVR_DEBUG_LOG((
"State_WaitingForSettlePostCalibrationColorWhite -> State_WaitingForSettlePostMeasurement."));
192 OVR_DEBUG_LOG((
"State_WaitingForSettlePostMeasurement -> State_WaitingToTakeMeasurement."));
201 OVR_DEBUG_LOG((
"State_WaitingForTestStarted -> State_WaitingForSettlePostMeasurement."));
212 OVR_DEBUG_LOG((
"** Timed out waiting for 'ColorDetected'."));
213 OVR_DEBUG_LOG((
"State_WaitingForColorDetected -> State_WaitingForSettlePostMeasurement."));
247 OVR_DEBUG_LOG((
"State_WaitingToTakeMeasurement -> State_WaitingForTestStarted."));
269 OVR_DEBUG_LOG((
"State_WaitingForTestStarted -> State_WaitingForColorDetected."));
281 OVR_DEBUG_LOG((
"Time to 'ColorDetected' = %d", elapsedTime));
295 OVR_DEBUG_LOG((
"State_WaitingForColorDetected -> State_WaitingForSettlePostMeasurement."));
353 pLatencyTestUtil->handleMessage(msg);
388 UInt32 initialMeasurements = 0;
390 UInt32 measurements1to2 = 0;
391 UInt32 measurements2to1 = 0;
400 initialMeasurements++;
419 pCurr =
Results.GetNext(pCurr);
434 UInt32 minTime1To2 = UINT_MAX;
436 float averageTime1To2 = 0.0f;
437 UInt32 minTime2To1 = UINT_MAX;
439 float averageTime2To1 = 0.0f;
443 float averageUSBTripMilliS = 0.0f;
444 UInt32 countUSBTripTime = 0;
446 UInt32 measurementsCount = 0;
447 UInt32 measurements1to2 = 0;
448 UInt32 measurements2to1 = 0;
471 minTime1To2 =
Alg::Min(elapsed, minTime1To2);
472 maxTime1To2 =
Alg::Max(elapsed, maxTime1To2);
474 averageTime1To2 += (float) elapsed;
485 minTime2To1 =
Alg::Min(elapsed, minTime2To1);
486 maxTime2To1 =
Alg::Max(elapsed, maxTime2To1);
488 averageTime2To1 += (float) elapsed;
493 minUSBTripMilliS =
Alg::Min(usbRountripElapsedMilliS, minUSBTripMilliS);
494 maxUSBTripMilliS =
Alg::Max(usbRountripElapsedMilliS, maxUSBTripMilliS);
495 averageUSBTripMilliS += usbRountripElapsedMilliS;
510 pCurr =
Results.GetNext(pCurr);
516 averageUSBTripMilliS /= countUSBTripTime;
518 float finalResult = 0.5f * (averageTime1To2 + averageTime2To1);
519 finalResult += averageUSBTripMilliS;
522 ResultsString.
AppendFormat(
"RESULT=%.1f (add half Tracker period) [b->w %d|%.1f|%d] [w->b %d|%.1f|%d] [usb rndtrp %.1f|%.1f|%.1f] [cnt %d] [tmouts %d]",
524 minTime1To2, averageTime1To2, maxTime1To2,
525 minTime2To1, averageTime2To1, maxTime2To1,
526 minUSBTripMilliS, averageUSBTripMilliS, maxUSBTripMilliS,
545 if (newTime < OldTime)
547 elapsedMilliS = OldTime - newTime;
548 elapsedMilliS = UINT_MAX - elapsedMilliS;
LatencyTestHandler Handler
static const float BIG_FLOAT
static const Color SENSOR_DETECT_THRESHOLD(128, 255, 255)
bool TimedOutWaitingForColorDetected
static const UInt32 TIMEOUT_WAITING_FOR_TEST_STARTED
MeasurementResult * getActiveResult()
const char * GetResultsString()
OVR_FORCE_INLINE const T Max(const T a, const T b)
static const UInt32 DEFAULT_NUMBER_OF_SAMPLES
void setTimer(UInt32 timeMilliS)
bool DisplayScreenColor(Color &colorToDisplay)
bool TimedOutWaitingForTestStarted
void handleMessage(const Message &msg, LatencyTestMessageType latencyTestMessage=LatencyTest_None)
static const Color CALIBRATE_BLACK(0, 0, 0)
void clearMeasurementResults()
StringBuffer ResultsString
const char * ToCStr() const
static const Color COLOR1(0, 0, 0)
String ReturnedResultString
static const UInt32 TIMEOUT_WAITING_FOR_COLOR_DETECTED
UInt32 DeviceMeasuredElapsedMilliS
static const UInt32 INITIAL_SAMPLES_TO_IGNORE
static UInt32 OVR_STDCALL GetTicksMs()
static const UInt32 TIME_TO_WAIT_FOR_SETTLE_PRE_CALIBRATION
const char * ToCStr() const
static const Color CALIBRATE_WHITE(255, 255, 255)
bool areResultsComplete()
static const UInt32 TIME_TO_WAIT_FOR_SETTLE_POST_MEASUREMENT_RANDOMNESS
List< MeasurementResult > Results
static const float SMALL_FLOAT
double TestStartedSeconds
LatencyTest(LatencyTestDevice *device=NULL)
static const UInt32 TIME_TO_WAIT_FOR_SETTLE_POST_MEASUREMENT
bool SetDevice(LatencyTestDevice *device)
void AppendFormat(const char *format,...)
static const UInt32 TIME_TO_WAIT_FOR_SETTLE_POST_CALIBRATION
OVR_FORCE_INLINE const T Min(const T a, const T b)
static double OVR_STDCALL GetSeconds()
void RemoveHandlerFromDevices()
virtual void OnMessage(const Message &msg)
#define OVR_DEBUG_LOG(args)
static const Color COLOR2(255, 255, 255)
UInt32 getRandomComponent(UInt32 range)