Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef OVR_Util_LatencyTest_h
00018 #define OVR_Util_LatencyTest_h
00019
00020 #include "../OVR_Device.h"
00021
00022 #include "../Kernel/OVR_String.h"
00023 #include "../Kernel/OVR_List.h"
00024
00025 namespace OVR { namespace Util {
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class LatencyTest : public NewOverrideBase
00055 {
00056 public:
00057 LatencyTest(LatencyTestDevice* device = NULL);
00058 ~LatencyTest();
00059
00060
00061
00062 bool SetDevice(LatencyTestDevice* device);
00063
00064
00065 bool HasDevice() const
00066 { return Handler.IsHandlerInstalled(); }
00067
00068 void ProcessInputs();
00069 bool DisplayScreenColor(Color& colorToDisplay);
00070 const char* GetResultsString();
00071
00072
00073 void BeginTest();
00074
00075 private:
00076 LatencyTest* getThis() { return this; }
00077
00078 enum LatencyTestMessageType
00079 {
00080 LatencyTest_None,
00081 LatencyTest_Timer,
00082 LatencyTest_ProcessInputs,
00083 };
00084
00085 UInt32 getRandomComponent(UInt32 range);
00086 void handleMessage(const Message& msg, LatencyTestMessageType latencyTestMessage = LatencyTest_None);
00087 void reset();
00088 void setTimer(UInt32 timeMilliS);
00089 void clearTimer();
00090
00091 class LatencyTestHandler : public MessageHandler
00092 {
00093 LatencyTest* pLatencyTestUtil;
00094 public:
00095 LatencyTestHandler(LatencyTest* latencyTester) : pLatencyTestUtil(latencyTester) { }
00096 ~LatencyTestHandler();
00097
00098 virtual void OnMessage(const Message& msg);
00099 };
00100
00101 bool areResultsComplete();
00102 void processResults();
00103 void updateForTimeouts();
00104
00105 Ptr<LatencyTestDevice> Device;
00106 LatencyTestHandler Handler;
00107
00108 enum TesterState
00109 {
00110 State_WaitingForButton,
00111 State_WaitingForSettlePreCalibrationColorBlack,
00112 State_WaitingForSettlePostCalibrationColorBlack,
00113 State_WaitingForSettlePreCalibrationColorWhite,
00114 State_WaitingForSettlePostCalibrationColorWhite,
00115 State_WaitingToTakeMeasurement,
00116 State_WaitingForTestStarted,
00117 State_WaitingForColorDetected,
00118 State_WaitingForSettlePostMeasurement
00119 };
00120 TesterState State;
00121
00122 bool HaveOldTime;
00123 UInt32 OldTime;
00124 UInt32 ActiveTimerMilliS;
00125
00126 Color RenderColor;
00127
00128 struct MeasurementResult : public ListNode<MeasurementResult>, public NewOverrideBase
00129 {
00130 MeasurementResult()
00131 : DeviceMeasuredElapsedMilliS(0),
00132 TimedOutWaitingForTestStarted(false),
00133 TimedOutWaitingForColorDetected(false),
00134 StartTestTicksMicroS(0),
00135 TestStartedTicksMicroS(0)
00136 {}
00137
00138 Color TargetColor;
00139
00140 UInt32 DeviceMeasuredElapsedMilliS;
00141
00142 bool TimedOutWaitingForTestStarted;
00143 bool TimedOutWaitingForColorDetected;
00144
00145 UInt64 StartTestTicksMicroS;
00146 UInt64 TestStartedTicksMicroS;
00147 };
00148
00149 List<MeasurementResult> Results;
00150 void clearMeasurementResults();
00151
00152 MeasurementResult* getActiveResult();
00153
00154 StringBuffer ResultsString;
00155 String ReturnedResultString;
00156 };
00157
00158 }}
00159
00160 #endif // OVR_Util_LatencyTest_h