|
Fast Research Interface Library
Manual and Documentation
|
00001 // ---------------------- Doxygen info ---------------------- 00047 // ---------------------------------------------------------- 00048 // For a convenient reading of this file's source code, 00049 // please use a tab width of four characters. 00050 // ---------------------------------------------------------- 00051 00052 #include <OSAbstraction.h> 00053 00054 00055 00056 #include <stdio.h> 00057 #include <conio.h> 00058 #include <time.h> 00059 #include <Windows.h> 00060 #include <stdlib.h> 00061 00062 00063 ULONGLONG StoredSystemTimeInTicks; 00064 00065 00066 static bool GetSystemTimeInSecondsCalledFirstTime = true; 00067 00068 00069 00070 // **************************************************************** 00071 // WaitForKBCharacter() 00072 // 00073 unsigned char WaitForKBCharacter(bool *Abort) 00074 { 00075 if (Abort == NULL) 00076 { 00077 while ( _kbhit() == 0 ) 00078 { 00079 Sleep(10); 00080 } 00081 } 00082 else 00083 { 00084 while ( ( _kbhit() == 0 ) && (!(*Abort)) ) 00085 { 00086 Sleep(10); 00087 } 00088 if (*Abort) 00089 { 00090 return(0); 00091 } 00092 } 00093 00094 return(_getche()); 00095 } 00096 00097 00098 00099 unsigned char CheckForKBCharacter(void) 00100 { 00101 00102 if ( _kbhit() == 0 ) 00103 { 00104 return(0); 00105 } 00106 else 00107 { 00108 return(_getche()); 00109 } 00110 } 00111 00112 00113 float GetSystemTimeInSeconds(const bool &Reset) 00114 { 00115 ULONGLONG CurrentLocalMachineTime; 00116 00117 if ( (GetSystemTimeInSecondsCalledFirstTime) || (Reset) ) 00118 { 00119 StoredSystemTimeInTicks = GetTickCount64(); 00120 GetSystemTimeInSecondsCalledFirstTime = false; 00121 } 00122 00123 CurrentLocalMachineTime = GetTickCount64(); 00124 00125 return(0.001 * (float)(CurrentLocalMachineTime - StoredSystemTimeInTicks)); 00126 }