108
|
1 |
(* Test whether the keyword XXXX may be used as an identifier for:
|
|
2 |
* FUNCTION_BLOCK declaration
|
|
3 |
*
|
|
4 |
* The XXXX names in the following code are merely a placeholder.
|
|
5 |
* They will be replaced by several identifiers before actual testing
|
|
6 |
* of the compiler.
|
|
7 |
*)
|
|
8 |
|
|
9 |
(* The identifiers that will replace the XXXX
|
|
10 |
* must be placed on a line starting with #
|
|
11 |
* All identifiers preceded by # are ignored!
|
|
12 |
* The identifier list must be placed inside an IEC 61131-3 comment.
|
|
13 |
*)
|
|
14 |
(*
|
|
15 |
#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN
|
|
16 |
#IL_operators PT PV R R1 RET RETC RETCN S S1 ST STN XORN
|
|
17 |
NOTE: R and S are identical to IL operators!!
|
|
18 |
#SFC_qualifiers D DS L N P #R #S SD SL
|
|
19 |
#Task_initialisers PRIORITY SINGLE INTERVAL
|
|
20 |
*)
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
(* The FUNCTION BLOCK declaration *)
|
|
27 |
function_block XXXX
|
|
28 |
var_input
|
|
29 |
a_1, b_1: int;
|
|
30 |
end_var
|
|
31 |
var_output
|
|
32 |
c_1, d_1: int;
|
|
33 |
end_var
|
|
34 |
c_1 := 10 + b_1;
|
|
35 |
end_function_block
|
|
36 |
|
|
37 |
|
|
38 |
(* Calling of the function block from within ST code *)
|
|
39 |
|
|
40 |
function_block foo
|
|
41 |
var
|
|
42 |
e_1, f_1 : int;
|
|
43 |
fb : XXXX;
|
|
44 |
end_var
|
|
45 |
fb(10, 20);
|
|
46 |
fb (10, 20, e_1, f_1);
|
|
47 |
fb (a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1);
|
|
48 |
fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1);
|
|
49 |
fb (c_1=>e_1, a_1:=20, d_1=>f_1);
|
|
50 |
f_1 := fb.c_1;
|
|
51 |
fb.a_1 := e_1;
|
|
52 |
end_function_block
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
(* Calling of the function block from within IL code *)
|
|
57 |
function_block bar
|
|
58 |
var
|
|
59 |
e_1, f_1 : int;
|
|
60 |
fb : XXXX;
|
|
61 |
end_var
|
|
62 |
CAL fb
|
|
63 |
LD fb.a_1
|
|
64 |
ST fb.b_1
|
|
65 |
CAL fb (10)
|
|
66 |
CAL fb(30, 20, e_1, f_1)
|
|
67 |
CAL fb (
|
|
68 |
a_1 := 10,
|
|
69 |
c_1 => f_1
|
|
70 |
)
|
|
71 |
CAL fb(
|
|
72 |
a_1 := 10,
|
|
73 |
c_1 => f_1
|
|
74 |
)
|
|
75 |
end_function_block
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
(* Checking whether the use of XXXX will confuse any other
|
|
80 |
* normal and correct IL or ST code.
|
|
81 |
*)
|
|
82 |
{#include "basic_code.test" }
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
(*
|
|
93 |
|
|
94 |
CONFIGURATION
|
|
95 |
......
|
|
96 |
using these XXXX identifiers within a configuration
|
|
97 |
|
|
98 |
especially a task initialisation, as Priority, single and interval may clash here.
|
|
99 |
(they shouldn't, but if the parser has an error, they will....)
|
|
100 |
|
|
101 |
END_CONFIGURATION
|
|
102 |
|
|
103 |
*)
|