-
Notifications
You must be signed in to change notification settings - Fork 0
/
InOutUtils.pas
executable file
·79 lines (66 loc) · 1.46 KB
/
InOutUtils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
unit InOutUtils;
{$MODE Delphi}
interface
uses
math, SysUtils, LCLIntf, LCLType, LMessages, Messages, Forms, strutils;
procedure Delay(msecs: Longint);
procedure NanoSleep(dur: Integer);
function BinToInt(Value: string): Integer;
function GetUgDif(ug1: Integer; ug2: Integer): Integer;
var
busInUse: Boolean;
implementation
function BinToInt(Value: string): Integer;
var
i, iValueSize: Integer;
begin
Result := 0;
iValueSize := Length(Value);
for i := iValueSize downto 1 do
if Value[i] = '1' then Result := Result + (1 shl (iValueSize - i));
end;
procedure NanoSleep(dur: Integer);
var
i: Integer;
begin
if dur>0 then
Delay(dur)
else
if dur = 0 then
for i:=1 to 1000 do
begin
application.ProcessMessages;
end;
end;
procedure Delay(msecs: Longint);
var
targettime: Longint;
Msg: TMsg;
begin
targettime := GetTickCount + msecs;
while targettime > GetTickCount do
application.ProcessMessages;
end;
function GetUgDif(ug1: Integer; ug2: Integer): Integer;
var
tmpUg, smn: Integer;
begin
smn := -1;
if ug1 < ug2 then
begin
tmpUg := ug1;
ug1 := ug2;
ug2 := tmpUg;
smn := 1;
end;
if (abs(ug1 - ug2) > 180) then
begin
tmpUg := abs((360 - ug1) + ug2)*-1;
end
else
begin
tmpUg := abs(ug1 - ug2);
end;
result := tmpUg * smn;
end;//function GetUgDif(ug1: Integer; ug2: Integer): integer;
end.