[an error occurred while processing this directive] [an error occurred while processing this directive]
А вот так...
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено John 16 мая 2002 г. 13:08
В ответ на: Вот я и говорю - реально по вопросу ничего у вас нет. отправлено L.A. 16 мая 2002 г. 12:30

var
PriorityClass, Priority: Integer;
DelayCount : dword;

{---------------------------------}
{ Калибровка скорости работы компьютера }
procedure CalibrDelay;
var
PriorityClass, Priority : integer;
i, L, RN, RK : dword;
begin
PriorityClass := GetPriorityClass ( GetCurrentProcess );
Priority := GetThreadPriority ( GetCurrentThread );
{ Определение количества циклов задержки на мкс }
SetPriorityClass ( GetCurrentProcess, REALTIME_PRIORITY_CLASS );
SetThreadPriority ( GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL );
L := 1000;
Repeat
L := L * 10;
RN := GetTickCount;
For i := 1 to L do;
RK := GetTickCount;
until ( RK - RN ) > 100;
DelayCount := Round ( L / 1000 / ( RK - RN ) );
If DelayCount = 0
then DelayCount := 1;
SetThreadPriority ( GetCurrentThread, Priority );
SetPriorityClass ( GetCurrentProcess, PriorityClass );
end; { CalibrDelay }

{---------------------------------}
{ Задержка на мкс }
procedure DelayUS ( US : dword );
var
i, L : dword;
begin
L := US * DelayCount;
For i := 1 to L do;
end; { TMainForm.DelayUS }

{---------------------------------}
// Сделать приложение "единственным"
procedure SetRealTimePriority;
begin
PriorityClass := GetPriorityClass ( GetCurrentProcess );
Priority := GetThreadPriority ( GetCurrentThread );
SetPriorityClass ( GetCurrentProcess, REALTIME_PRIORITY_CLASS );
SetThreadPriority ( GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL );
end; // SetRealTimePriority

{---------------------------------}
// Восстановить нормальный приоритет
procedure ClrRealTimePriority;
begin
SetThreadPriority ( GetCurrentThread, Priority );
SetPriorityClass ( GetCurrentProcess, PriorityClass );
end; // ClrRealTimePriority


Процедурки задержек должны быть взяты с скобки
SetRealTimePriority;
ClrRealTimePriority;
Большой точности не обещается, но подстройка под конкретную машину наличествует.

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru