controller.pr 6.46 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* CIF PROCESS (250, 150), (150, 75) */
process Controller;
    state Green;
    substructure
        in (short);
        out (Go_Orange);
            /* CIF START (604, 136), (70, 35) */
            START short ;
                /* CIF NEXTSTATE (583, 191), (110, 35) */
                NEXTSTATE Second_Delay;
            /* CIF START (343, 131), (70, 35) */
            START;
                /* CIF NEXTSTATE (331, 186), (93, 35) */
                NEXTSTATE First_Delay;
            /* CIF state (583, 191), (110, 35) */
            state Second_Delay;
                /* CIF input (604, 246), (70, 35) */
                input Clock;
                    /* CIF return (621, 301), (35, 35) */
                    return Go_Orange;
            endstate;
            /* CIF state (331, 186), (93, 35) */
            state First_Delay;
                /* CIF input (206, 241), (70, 35) */
                input Clock;
                    /* CIF PROCEDURECALL (155, 296), (171, 35) */
                    call Set_Timer (5000, Clock);
                    /* CIF NEXTSTATE (185, 351), (111, 35) */
                    NEXTSTATE Second_Delay;
                /* CIF input (361, 241), (123, 35) */
                input Button (cmd);
                    /* CIF PROCEDURECALL (336, 296), (171, 35) */
                    call Set_Timer (5000, Clock);
                    /* CIF NEXTSTATE (364, 346), (117, 35) */
                    NEXTSTATE Second_Delay;
            endstate;
    endsubstructure;
    state Red;
    substructure
        out (Go_Green);
            /* CIF START (59, 69), (59, 35) */
            START;
                /* CIF NEXTSTATE (15, 119), (147, 35) */
                NEXTSTATE Everybody_Stopped;
            /* CIF state (237, 112), (73, 35) */
            state Walking;
                /* CIF input (238, 167), (70, 35) */
                input Clock;
                    /* CIF output (211, 222), (124, 35) */
                    output Info_User (Wait);
                    /* CIF PROCEDURECALL (234, 277), (79, 35) */
                    call Blue_Off;
                    /* CIF PROCEDURECALL (184, 327), (178, 35) */
                    call Set_Timer (2000, Clock);
                    /* CIF NEXTSTATE (210, 382), (127, 35) */
                    NEXTSTATE Walking_Is_Over;
            endstate;
            /* CIF state (430, 116), (127, 35) */
            state Walking_Is_Over;
                /* CIF input (373, 171), (70, 35) */
                input Clock;
                    /* CIF return (391, 226), (35, 35) */
                    return Go_Green;
                /* CIF input (477, 171), (123, 35) */
                input Button (cmd);
                    /* CIF task (453, 226), (172, 35) */
                    task Walk_Requested := True;
                    /* CIF NEXTSTATE (504, 281), (70, 35) */
                    NEXTSTATE -;
            endstate;
            /* CIF state (15, 119), (147, 35) */
            state Everybody_Stopped;
                /* CIF input (53, 174), (70, 35) */
                input Clock;
                    /* CIF output (32, 229), (112, 35) */
                    output Info_User (Go);
                    /* CIF PROCEDURECALL (50, 284), (75, 35) */
                    call Blue_On;
                    /* CIF PROCEDURECALL (3, 334), (171, 35) */
                    call Set_Timer (5000, Clock);
                    /* CIF task (0, 389), (177, 35) */
                    task Walk_Requested := False;
                    /* CIF NEXTSTATE (52, 439), (73, 35) */
                    NEXTSTATE Walking;
            endstate;
    endsubstructure;
    /* CIF TEXT (939, 61), (282, 152) */
    timer clock;
    
    dcl dummy t_Boolean;
    
    dcl Walk_Requested T_Boolean := False;
    
    dcl Cmd Command;
    
    dcl blue_led t_boolean := true;
    /* CIF ENDTEXT */
    /* CIF START (155, 40), (70, 33) */
    START;
        /* CIF NEXTSTATE (152, 93), (75, 35) */
        NEXTSTATE Off;
    /* CIF state (152, 93), (75, 35) */
    state Off;
        /* CIF input (117, 148), (134, 35) */
        input Initialize (dummy);
            /* CIF PROCEDURECALL (142, 203), (85, 35) */
            call Kick_WD;
            /* CIF PROCEDURECALL (96, 253), (178, 35) */
            call Set_Timer (1000, Clock);
            /* CIF output (138, 308), (92, 35) */
            output Color (Red);
            /* CIF PROCEDURECALL (149, 363), (71, 35) */
            call Red_On;
            /* CIF PROCEDURECALL (145, 418), (79, 35) */
            call Blue_Off;
            /* CIF output (122, 468), (124, 35) */
            output Info_User (Wait);
            /* CIF NEXTSTATE (154, 518), (61, 35) */
            NEXTSTATE Red;
    endstate;
    /* CIF state (548, 49), (70, 35) */
    state Red;
        /* CIF connect (583, 104), (0, 35) */
        connect Go_Green;
            /* CIF PROCEDURECALL (494, 159), (178, 35) */
            call Set_Timer (5000, Clock);
            /* CIF output (529, 214), (106, 35) */
            output Color (Green);
            /* CIF PROCEDURECALL (540, 269), (85, 35) */
            call Green_On;
            /* CIF decision (520, 319), (124, 50) */
            decision Walk_requested;
                /* CIF ANSWER (469, 389), (70, 24) */
                (True):
                    /* CIF NEXTSTATE (444, 433), (119, 35) */
                    NEXTSTATE Green via Short;
                /* CIF ANSWER (638, 389), (68, 24) */
                (False):
                    /* CIF NEXTSTATE (635, 433), (74, 35) */
                    NEXTSTATE Green;
            enddecision;
    endstate;
    /* CIF state (773, 61), (70, 35) */
    state Orange;
        /* CIF input (773, 116), (70, 35) */
        input Clock;
            /* CIF PROCEDURECALL (719, 171), (178, 35) */
            call Set_Timer (1000, Clock);
            /* CIF output (761, 226), (92, 35) */
            output Color (Red);
            /* CIF PROCEDURECALL (772, 281), (71, 35) */
            call Red_On;
            /* CIF NEXTSTATE (773, 331), (70, 35) */
            NEXTSTATE Red;
    endstate;
    /* CIF state (973, 314), (70, 35) */
    state Green;
        /* CIF connect (1008, 369), (0, 35) */
        connect Go_Orange;
            /* CIF PROCEDURECALL (907, 419), (201, 35) */
            call Set_Timer (2000, Clock);
            /* CIF output (950, 474), (114, 35) */
            output Color (Orange);
            /* CIF PROCEDURECALL (961, 529), (93, 35) */
            call Orange_On;
            /* CIF NEXTSTATE (973, 579), (70, 35) */
            NEXTSTATE Orange;
    endstate;
endprocess Controller;