summaryrefslogtreecommitdiffstats
path: root/tests/150-startup/ob_startup_info.awl
blob: 3e9e279f92fcf0830f2dbb22cb5ccbdd53fb1d5f (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
ORGANIZATION_BLOCK OB 100
BEGIN

	// Check if OB-temp writing is enabled
	__FEATURE	1
	L		0
	<>D
	SPB isen

	// Enable OB-temp presets
	__FEATURE	1,	1
	// Reboot
	CALL		SFC -2 (
		REBOOT_TYPE := 1
	)

isen:	NOP		0

END_ORGANIZATION_BLOCK


ORGANIZATION_BLOCK OB 1
VAR_TEMP
	OB1_EV_CLASS		: BYTE;
	OB1_SCAN_1		: BYTE;
	OB1_PRIORITY		: BYTE;
	OB1_OB_NUMBR		: BYTE;
	OB1_RESERVED_1		: BYTE;
	OB1_RESERVED_2		: BYTE;
	OB1_PREV_CYCLE		: INT;
	OB1_MIN_CYCLE		: INT;
	OB1_MAX_CYCLE		: INT;
	OB1_DATE_TIME		: DATE_AND_TIME;
END_VAR
BEGIN

	L		#OB1_EV_CLASS
	__ASSERT==	__ACCU 1,	B#16#11

	L		#OB1_SCAN_1
	__ASSERT==	__ACCU 1,	B#16#03

	L		#OB1_PRIORITY
	__ASSERT==	__ACCU 1,	B#16#01

	L		#OB1_OB_NUMBR
	__ASSERT==	__ACCU 1,	B#16#01

	L		#OB1_RESERVED_1
	__ASSERT==	__ACCU 1,	B#16#00

	L		#OB1_RESERVED_2
	__ASSERT==	__ACCU 1,	B#16#00

	L		#OB1_PREV_CYCLE
	__ASSERT<=	__ACCU 1,	W#16#7FFF

	L		#OB1_MIN_CYCLE
	__ASSERT<=	__ACCU 1,	W#16#7FFF

	L		#OB1_MAX_CYCLE
	__ASSERT<=	__ACCU 1,	W#16#7FFF

	LAR1		P##OB1_DATE_TIME
	L		B [AR1, P#0.0]	// year
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT>=	MB 0,		B#16#13
	L		B [AR1, P#1.0]	// month
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT<=	MB 0,		B#16#12
	L		B [AR1, P#2.0]	// day
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT<=	MB 0,		B#16#31
	L		B [AR1, P#3.0]	// hour
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT<=	MB 0,		B#16#24
	L		B [AR1, P#4.0]	// minute
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT<=	MB 0,		B#16#60
	L		B [AR1, P#5.0]	// second
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	__ASSERT<=	MB 0,		B#16#60
	L		B [AR1, P#6.0]	// millisecond upper
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	L		B [AR1, P#7.0]	// millisecond lower / weekday
	T		MB 0
	CALL		FC 1 (BCD_BYTE := MB 0)
	L		MB 0
	UD		DW#16#0000000F
	__ASSERT>=	__ACCU 1,	1
	__ASSERT<=	__ACCU 1,	7

	__ASSERT<=	#OB1_PREV_CYCLE,	#OB1_MAX_CYCLE
	__ASSERT>=	#OB1_PREV_CYCLE,	#OB1_MIN_CYCLE
	__ASSERT>=	#OB1_MAX_CYCLE,		#OB1_MIN_CYCLE


	CALL SFC 46 // STOP CPU
END_ORGANIZATION_BLOCK


FUNCTION FC 1 : VOID
TITLE = Check whether BCD_BYTE is a valid BCD value
VAR_INPUT
	BCD_BYTE	: BYTE;
END_VAR
BEGIN
	L		#BCD_BYTE
	UD		DW#16#0000000F
	__ASSERT<=	__ACCU 1,	9
	L		#BCD_BYTE
	SRD		4
	UD		DW#16#0000000F
	__ASSERT<=	__ACCU 1,	9
END_FUNCTION
bues.ch cgit interface