-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSF_TwoHandControlTypeII.st
More file actions
139 lines (134 loc) · 3.15 KB
/
SF_TwoHandControlTypeII.st
File metadata and controls
139 lines (134 loc) · 3.15 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
FUNCTION_BLOCK SF_TwoHandControlTypeII
VAR_INPUT
Activate: BOOL;
S_Button1: SAFEBOOL;
S_Button2: SAFEBOOL;
END_VAR
VAR_OUTPUT
Ready: BOOL;
S_TwoHandOut: SAFEBOOL;
SafetyDemand: BOOL;
Error: BOOL;
DiagCode: WORD;
END_VAR
IF NOT Activate THEN
DiagCode := 16#0000;
END_IF;
CASE DiagCode OF
16#0000:
IF Activate THEN
DiagCode := 16#8001;
END_IF;
16#8001:
IF S_Button1 AND S_Button2 THEN
DiagCode := 16#C030;
ELSIF S_Button1 THEN
DiagCode := 16#C010;
ELSIF S_Button2 THEN
DiagCode := 16#C020;
ELSE
DiagCode := 16#8802;
END_IF;
16#8802:
IF S_Button1 AND S_Button2 THEN
DiagCode := 16#8000;
ELSIF S_Button1 THEN
DiagCode := 16#8804;
ELSIF S_Button2 THEN
DiagCode := 16#8806;
END_IF;
16#8804:
IF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
ELSIF NOT S_Button1 AND S_Button2 THEN
DiagCode := 16#880E;
ELSIF S_Button1 AND S_Button2 THEN
DiagCode := 16#8000;
END_IF;
16#8806:
IF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
ELSIF S_Button1 AND NOT S_Button2 THEN
DiagCode := 16#880E;
ELSIF S_Button1 AND S_Button2 THEN
DiagCode := 16#8000;
END_IF;
16#8808:
IF S_Button1 AND S_Button2 THEN
DiagCode := 16#880C;
ELSIF NOT S_Button1 AND S_Button2 THEN
DiagCode := 16#880A;
ELSIF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
16#880A:
IF S_Button1 AND S_Button2 THEN
DiagCode := 16#880C;
ELSIF S_Button1 AND NOT S_Button2 THEN
DiagCode := 16#8808;
ELSIF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
16#880C:
IF NOT S_Button1 AND S_Button2 THEN
DiagCode := 16#880A;
ELSIF S_Button1 AND NOT S_Button2 THEN
DiagCode := 16#8808;
ELSIF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
16#880E:
IF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
16#8000:
IF S_Button1 AND NOT S_Button2 THEN
DiagCode := 16#8808;
ELSIF NOT S_Button1 AND S_Button2 THEN
DiagCode := 16#880A;
ELSIF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
16#C010,
16#C020,
16#C030:
IF NOT (S_Button1 OR S_Button2) THEN
DiagCode := 16#8802;
END_IF;
END_CASE;
CASE DiagCode OF
16#0000:
Ready := FALSE;
SafetyDemand := FALSE;
Error := FALSE;
S_TwoHandOut := FALSE;
16#8000:
Ready := TRUE;
SafetyDemand := FALSE;
Error := FALSE;
S_TwoHandOut := TRUE;
16#8001:
Ready := TRUE;
SafetyDemand := FALSE;
Error := FALSE;
S_TwoHandOut := FALSE;
16#8802,
16#8804,
16#8806,
16#8808,
16#880A,
16#880C,
16#880E:
Ready := TRUE;
SafetyDemand := TRUE;
Error := FALSE;
S_TwoHandOut := FALSE;
16#C010,
16#C020,
16#C030:
Ready := TRUE;
SafetyDemand := FALSE;
Error := TRUE;
S_TwoHandOut := FALSE;
END_CASE;
END_FUNCTION_BLOCK