-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwtlgetal.c
More file actions
224 lines (180 loc) · 7.24 KB
/
Copy pathwtlgetal.c
File metadata and controls
224 lines (180 loc) · 7.24 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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* WACHTTIJDLANTAARN MET GETAL */
/* =========================== */
/* (C) Copyright 2003-2023 by A.C.M. van Grinsven. All rights reserved. */
/* CCOL : versie 12.0.0 */
/* FILE : wtlgetal.c */
/* DATUM: 20-02-2023 */
/* include files */
/* ============= */
#include "sysdef.c" /* definitie typen variabelen */
#include "cif.inc" /* declaratie CVN C-interface */
#include "fcvar.h" /* declaratie fasecyclusvariabelen */
#include "tmvar.h" /* declaratie tijdvariabelen */
#include "mevar.h" /* declaratie geheugenvariabelen */
/* macrodefinities */
/* =============== */
#ifndef WTL_MAX_GETAL
#define WTL_MAX_GETAL 120 /* maximum aan te sturen getal */
#endif
#define WTL_TIJD_MAX_GETAL 20 /* dooftijd (TE) bij negatieve waarde (PG[]/OS[]) */
/* definitie wachttijdfuncties */
/* =========================== */
/* de functie wachttijd_getal() verzorgt de aansturing van het getal van de wachttijd-
* lantaarn voor de opgegeven fasecyclus (fc) op basis van de berekende wachttijd
* (T_wacht_ber). de functie wachttijd_getal() geeft het getal dat moet branden
* aan de procesbesturing door m.b.v. een uitgangssignaal (CIF_GUS[uswvt]).
* een wachttijd-lantaarn wordt aangestuurd, indien de opgegeven fasecyclus in
* rood verkeert en een aanvraag heeft. de wachttijd-lantaarn wordt niet aangestuurd
* indien de fasecyclus alleen een mee-aanvraag speciaal heeft (BIT5), omdat deze
* mee-aanvraag kan worden teruggezet.
* de functie gaat uit van een wachttijdlantaarn met een 3 segmentdisplays met een
* maximumwaarde van 199.
* de functie verdeelt de berekende wachttijd evenredig over de nog te tonen getallen.
* het getoonde getal wijzigt indien de actuele waarde van de wijzigtijd (T_timer[twtv])
* groter of gelijk is aan de berekende wachttijd gedeeld door het getoonde getal.
* bij het wijzigen van het getal herstart de wijzigtijd.
* de functie wachttijd_getal()geeft als return-waarde het getal dat moet worden getoond.
*/
mulv wachttijd_getal(count fc, count uswtv, count twtv, mulv T_wacht_ber, mulv T_getal_start)
{
/* fc - fasecyclusnummer */
/* uswtv - uitgangsnummer wachttijdlantaarn */
/* twtv - tijdelementnummer, dooftijd voor getal */
/* T_wacht_ber - waarde van de berekende wachttijd */
/* T_getal_start - bijvoorbeeld 2 tiendenseconden */
mulv aantal_getal; /* aantal - getoonde getal */
RT[twtv]= TRUE; /* set instructievariabele tijdmeting */
/* aantal - huidig getal */
/* --------------------- */
aantal_getal= CIF_GUS[uswtv]; /* actueel getoonde getal */
if (aantal_getal>WTL_MAX_GETAL) {
aantal_getal= WTL_MAX_GETAL;
}
/* aantal - te tonen getal */
/* ----------------------- */
if (R[fc] && (A[fc] & (BIT0+BIT3))) /* rood en detectieaanvraag of starre aanvraag */
{
if (aantal_getal==0) /* start aansturing wachttijd-lantaarn */
{
if (T_wacht_ber>=T_getal_start) /* 20 tienden seconden */
aantal_getal= (T_wacht_ber/10);
}
else if (T_wacht_ber<0) /* negatieve waarde - b.v. PG[ ] staat op */
{
aantal_getal= WTL_MAX_GETAL;
}
}
else /* tijdens aansturing */
{
if (T_wacht_ber>=0)
{
if (T_timer[twtv]>=((T_wacht_ber+T_timer[twtv])/aantal_getal))
{
aantal_getal--;
/* RT[twtv]= TRUE; */
}
else
{
RT[twtv]= FALSE;
}
}
else { /* negatieve waarde - b.v. PG[ ] staat op */
if (T_timer[twtv]>=WTL_TIJD_MAX_GETAL)
{
aantal_getal--;
/* RT[twtv]= TRUE; */
}
else
{
RT[twtv]= FALSE;
}
}
}
}
/* beveiliging bereik */
/* ------------------ */
if (aantal_getal<0) aantal_getal= 0;
if (aantal_getal>WTL_MAX_GETAL) aantal_getal= WTL_MAX_GETAL;
/* beveiliging groensturing */
/* ------------------------ */
if (G[fc]) aantal_getal= 0;
else if (R[fc] && A[fc] && !aantal_getal && CIF_GUS[uswtv]) aantal_getal= 1;
/* uitsturing wachttijdvoorspeller */
/* ------------------------------- */
CIF_GUS[uswtv]= aantal_getal;
return (mulv) aantal_getal;
}
/* De functie wachttijd_leds_mm() werkt in principe hetzelfde als de functie wachttijd_leds(),
* het aantal nog brandende leds wordt nu naar een geheugenelement geschreven i.p.v. naar een uitgangssignaal.
* de functie wachttijd_getal()geeft als return-waarde het getal dat moet worden getoond.
*/
mulv wachttijd_getal_mm(count fc, count mmwtv, count twtv, mulv T_wacht_ber, mulv T_getal_start)
{
/* fc - fasecyclusnummer */
/* mmwtv - uitgangsnummer wachttijdlantaarn */
/* twtv - tijdelementnummer, dooftijd voor getal */
/* T_wacht_ber - waarde van de berekende wachttijd */
/* T_led_start - bijvoorbeeld 2 tiendenseconden */
mulv aantal_getal; /* aantal - getoonde getal */
RT[twtv]= TRUE; /* set instructievariabele tijdmeting */
/* aantal - huidig getal */
/* --------------------- */
aantal_getal= MM[mmwtv]; /* actueel getoonde getal */
if (aantal_getal>WTL_MAX_GETAL) {
aantal_getal= WTL_MAX_GETAL;
}
/* aantal - te tonen getal */
/* ----------------------- */
if (R[fc] && (A[fc] & (BIT0+BIT3))) /* rood en detectieaanvraag of starre aanvraag */
{
if (aantal_getal==0) /* start aansturing wachttijd-lantaarn */
{
if (T_wacht_ber>=T_getal_start) /* 20 tienden seconden */
{
aantal_getal= (T_wacht_ber/10);
}
else if (T_wacht_ber<0) /* negatieve waarde - b.v. PG[ ] staat op */
{
aantal_getal= WTL_MAX_GETAL;
}
}
else /* tijdens aansturing */
{
if (T_wacht_ber>=0)
{
if (T_timer[twtv]>=((T_wacht_ber+T_timer[twtv])/aantal_getal))
{
aantal_getal--;
/* RT[twtv]= TRUE; */
}
else
{
RT[twtv]= FALSE;
}
}
else { /* negatieve waarde - b.v. PG[ ] staat op */
if (T_timer[twtv]>=WTL_TIJD_MAX_GETAL)
{
aantal_getal--;
/* RT[twtv]= TRUE; */
}
else
{
RT[twtv]= FALSE;
}
}
}
}
/* beveiliging bereik */
/* ------------------ */
if (aantal_getal<0) aantal_getal= 0;
if (aantal_getal>WTL_MAX_GETAL) aantal_getal= WTL_MAX_GETAL;
/* beveiliging groensturing */
/* ------------------------ */
if (G[fc]) aantal_getal= 0;
else if (R[fc] && A[fc] && !aantal_getal && MM[mmwtv]) aantal_getal= 1;
/* uitsturing wachttijdvoorspeller */
/* ------------------------------- */
MM[mmwtv]= aantal_getal;
return (mulv) aantal_getal;
}