-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiec104_test.pas
69 lines (55 loc) · 1.56 KB
/
iec104_test.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
{$I eDefines.inc}
program iec104_test;
uses
SysUtils, iec104, iec104defs;
var IEC104Server: TIEC104Server;
I, J: Integer;
Cmd: TIECCommand;
begin
IEC104Server:= TIEC104Server.Create('0.0.0.0', '2404');
//
IEC104Server.UseORGAddress:= True;
IEC104Server.ASDUAddressSize:= 2;
IEC104Server.ASDUAddress:= 1;
IEC104Server.IOASize:= 3;
// add information objects
For I:= 1 to 200 do begin
IEC104Server.AddIOValue(M_SP_NA_1, M_SP_TB_1, I);
IEC104Server.SetIOValue(I, LongWord(I mod 2));
end;
For I:= 300 to 400 do begin
IEC104Server.AddIOValue(M_ME_NC_1, M_ME_TF_1, I, 1);
IEC104Server.SetIOValue(I, Random()*1000);
end;
For I:= 401 to 600 do begin
IEC104Server.AddIOValue(M_IT_NA_1, M_IT_TB_1, I, 0);
IEC104Server.SetIOValue(I, I);
end;
// command
IEC104Server.AddIOValue(C_SC_NA_1, 0, 700);
//
IEC104Server.Start();
// test sporadic
I:= 0;
While true do begin
// IEC104Server.SetIOValue(5, Random()*1000);
// IEC104Server.SetIOValue(6, Random()*1000);
// IEC104Server.SetIOValue(7, 0);
If I mod 2 = 0 then IEC104Server.SetIOBadQuality(300) else IEC104Server.SetIOValue(300, Random()*1000);
Inc(I);
For J:= 1 to 50 do begin
Sleep(100);
Cmd:= IEC104Server.GetCommand();
If Cmd <> Nil then begin
try
WriteLn('COMMAND --------------------->', CMD.Value);
finally
FreeAndNil(Cmd);
end;
end;
end;
end;
Readln;
//
FreeAndNil(IEC104Server);
end.