aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tc250_symbols/symbols.awl
blob: 73043fae2c1707e1afa3c64b6e3fa908263f3e29 (plain)
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
80
81
FUNCTION_BLOCK "Function Block"
	VAR_INPUT
		INVAR : S5TIME;
	END_VAR
	VAR
		MULTI : "Function Block 2";
	END_VAR
BEGIN
	CALL #MULTI (
		INP	:= 42,
	)
END_FUNCTION_BLOCK


FUNCTION_BLOCK "Function Block 2"
	VAR_INPUT
		INP : INT;
	END_VAR
BEGIN
	L		#INP
	__ASSERT==	__ACCU 1,	42
END_FUNCTION_BLOCK


DATA_BLOCK "Data_1"
STRUCT
	VAR0		: INT;
END_STRUCT;
BEGIN
	VAR0		:= 123;
END_DATA_BLOCK


DATA_BLOCK "Instance DB"
	"Function Block"
BEGIN
END_DATA_BLOCK


ORGANIZATION_BLOCK OB 1
BEGIN
	// Test symbolic M access
	__STWRST
	U		"sym_M_0.0"
	__ASSERT==	__STW VKE,	0
	SET
	=		M 0.0
	__STWRST
	U		"sym_M_0.0"
	__ASSERT==	__STW VKE,	1
	CLR
	=		"sym_M_0.0"
	__STWRST
	U		M 0.0
	__ASSERT==	__STW VKE,	0


	// Test symbolic fully qualified access
	L		"Data_1".VAR0
	__ASSERT==	__ACCU 1,	123


	// Test symbolic FB call
	CALL	"Function Block", "Instance DB" (
		INVAR := 100,
	)


	// Test symbolic timer/counter access
	CLR
	SI		"symbolic timer"
	U		"symbolic timer"
	=		M 0.0
	CLR
	ZR		"symbolic counter"
	U		"symbolic counter"
	=		M 0.0


	CALL SFC 46 // STOP CPU
END_ORGANIZATION_BLOCK
bues.ch cgit interface