-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathccolfunc.c
More file actions
898 lines (834 loc) · 31.6 KB
/
ccolfunc.c
File metadata and controls
898 lines (834 loc) · 31.6 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
/* ccolfunc.c - gegenereerd met TLCGen 12.4.0.19 */
#include <stdarg.h>
#include "ccolfunc.h"
#if (!defined AUTOMAAT && !defined AUTOMAAT_TEST)
#include <conio.h>
#endif
#ifdef NALOPEN
#include "nalopen.c"
#include "gkvar.c" /* groengroenkonflikten */
#include "nlvar.c" /* nalopen */
#endif
#ifdef SYNC
#include "syncfunc.c"
#endif
#include "uitstuur.c"
#define TAVRMAX 32000 /* Maximaal aantal tijdelijke aanvragen op een fasecyclus */
mulv TAVR[FCMAX]; /* Tijdelijke aanvraag (kan tijdens geel/rood worden gereset) */
mulv TMAVR[FCMAX][FCMAX]; /* Tijdelijke meeaanvraag van fcxx naar fcyy */
/**************************************************************************
* Functie : aanvraag_detectie_reset_prm_va_arg
*
* Functionele omschrijving :
* Deze functie is afgeleid van aanvraag_detectie_prm_va_arg() in
* STDFUNC maar reset de aanvraag als de detectielus een instelbare tijd
* onbezet is.
**************************************************************************/
void aanvraag_detectie_reset_prm_va_arg(count fc, ...)
{
va_list argpt; /* variabele argumentenlijst */
count dpnr, /* arraynummer detectie-element */
tav = 0; /* arraynummer tijdelement */
mulv prm = 0; /* aanvraag parameter */
va_start(argpt, fc);
do {
dpnr = (count) va_arg(argpt, va_count); /* lees array-nummer detecctie */
if (dpnr >= 0)
{
tav = (count) va_arg(argpt, va_count); /* lees array-nummer tijdelement */
if (tav >= 0)
{
prm = (mulv) va_arg(argpt, va_mulv); /* lees waarde parameter */
if (prm > END)
{
if (prm <= 0)
{
RT[tav] = FALSE;
}
if (prm == 1)
{
RT[tav] = R[fc] && !TRG[fc] && DB[dpnr] ? TRUE : T[tav] && !G[fc] && D[dpnr];
}
if (prm == 2)
{
RT[tav] = R[fc] && DB[dpnr] ? TRUE : T[tav] && !G[fc] && D[dpnr];
}
if (prm >= 3)
{
RT[tav] = (R[fc] || GL[fc]) && DB[dpnr] ? TRUE : T[tav] && !G[fc] && D[dpnr];
}
AT[tav] = G[fc];
if (RT[tav] && !T[tav] && (TAVR[fc] < TAVRMAX)) TAVR[fc]++; /* optellen tijdelijke aanvragen bij start timer */
if (ET[tav] && !AT[tav] && (TAVR[fc] > 0)) TAVR[fc]--; /* aftellen tijdelijke aanvragen bij einde timer */
if (EG[fc]) TAVR[fc] = 0; /* altijd reset bij eindgroen (net als A) */
}
}
}
} while ((dpnr >= 0) && (tav >= 0) && (prm > END));
if (TAVR[fc])
{
/* set tijdelijke aanvraag */
A[fc] |= BIT8;
}
if (!TAVR[fc] && (A[fc] & BIT8))
{
/* reset tijdelijke aanvraag */
A[fc] &= ~BIT8;
if (!A[fc])
{
TFB_timer[fc] = 0;
RR[fc] |= RA[fc] ? BIT8 : 0;
}
}
va_end(argpt); /* maak var. arg-lijst leeg */
}
/**************************************************************************
* Functie : aanvraag_richtinggevoeligV1
*
* Functionele omschrijving :
* Deze functie is afgeleid van aanvraag_richtinggevoelig() in STDFUNC
* maar houdt aanvullend rekening met detectie storing. Daarnaast is
* 'zekere' variant verwijderd
**************************************************************************/
void aanvraag_richtinggevoeligV1(count fc, count d1, count d2, count trga,
mulv schrga)
{
if ((trga >= 0) && (schrga > 0)) {
if (CIF_IS[d1] >= CIF_DET_STORING && CIF_IS[d2] < CIF_DET_STORING && DB[d2]) {
A[fc] |= BIT1;
return;
}
if (CIF_IS[d1] < CIF_DET_STORING && CIF_IS[d2] >= CIF_DET_STORING && DB[d1]) {
A[fc] |= BIT1;
return;
}
RT[trga] = SD[d2];
if (R[fc] && !TRG[fc] && SD[d1] && T[trga]) { /* snelle variant */
A[fc] |= BIT1;
}
}
else {
if (R[fc] && !TRG[fc] && SD[d1] && D[d2]) { /* zekere variant */
A[fc] |= BIT1;
}
}
}
/**************************************************************************
* Functie : aanvraag_richtinggevoelig_reset
*
* Functionele omschrijving :
* Deze functie is afgeleid van aanvraag_richtinggevoelig() in STDFUNC
* maar reset de aanvraag als het richtinggevoelige lussenpaar een
* instelbare tijd onbezet is.
**************************************************************************/
void aanvraag_richtinggevoelig_reset(count fc, count d1, count d2, count trga, count tav, mulv schrga)
{
if ((trga >= 0) && (schrga > 0))
{
RT[trga] = SD[d2];
if (tav >= 0)
{
RT[tav] = R[fc] && !TRG[fc] && SD[d1] && T[trga] ? TRUE : T[tav] && !G[fc] && (D[d1] || D[d2]);
AT[tav] = G[fc];
}
/* snelle variant */
if (R[fc] && !TRG[fc] && SD[d1] && T[trga])
{
if (tav < 0)
{
A[fc] |= BIT1;
}
}
}
else
{
if (tav >= 0)
{
RT[tav] = R[fc] && !TRG[fc] && SD[d1] && D[d2] ? TRUE : T[tav] && !G[fc] && (D[d1] || D[d2]);
AT[tav] = G[fc];
}
/* zekere variant */
if (R[fc] && !TRG[fc] && SD[d1] && D[d2])
{
if (tav < 0)
{
A[fc] |= BIT1;
}
}
}
if (tav >= 0)
{
if (RT[tav] && !T[tav] && (TAVR[fc] < TAVRMAX)) TAVR[fc]++; /* optellen tijdelijke aanvragen bij start timer */
if (ET[tav] && !AT[tav] && (TAVR[fc] > 0)) TAVR[fc]--; /* aftellen tijdelijke aanvragen bij einde timer */
if (EG[fc]) TAVR[fc] = 0; /* altijd reset bij eindgroen (net als A) */
if (TAVR[fc])
{
/* set tijdelijke aanvraag */
A[fc] |= BIT9;
}
if (!TAVR[fc] && (A[fc] & BIT9))
{
/* reset tijdelijke aanvraag */
A[fc] &= ~BIT9;
if (!A[fc]) {
TFB_timer[fc] = 0;
RR[fc] |= RA[fc] ? BIT9 : 0;
}
}
}
}
#ifndef INSTRUCTION_BITS8
/**************************************************************************
* Functie : mee_aanvraag_reset
*
* Functionele omschrijving :
* zet een meeaanvraag door van fcv naar fcn
* en reset deze als deze wordt veroorzaakt door tijdelijke aanvragen
* die allen ingetrokken worden.
**************************************************************************/
void mee_aanvraag_reset(count fcn, count fcv, boolv expressie)
{
register count fc;
boolv reset_A = TRUE;
/* 'normale' meeaanvraag */
if (expressie && (A[fcv] & ~(BIT7 | BIT8)))
{
A[fcn] |= BIT4;
}
/* tijdelijke meeaanvraag */
if (expressie && (A[fcv] & BIT7))
{
A[fcn] |= BIT8;
}
TMAVR[fcv][fcn] = TAVR[fcv]; /* onthoud of de aanvragende fc nog een TA heeft */
for (fc = 0; fc < FCMAX; ++fc)
{
if (TMAVR[fc][fcn]) /* er is nog een aanvragende fc met een TA */
{
reset_A = FALSE;
break;
}
}
if ((reset_A) && (A[fcn] & BIT8)) /* alle TA's van aanvragende fc's zijn ingetrokken */
{
/* -> reset tijdelijke meeaanvraag */
A[fcn] &= ~BIT8;
if (!A[fcn])
{
TFB_timer[fcn] = 0;
RR[fcn] |= RA[fcn] ? BIT7 : 0;
}
}
}
#endif
#if (defined MLMAX) || (defined MLAMAX)
/**************************************************************************
* Functie : WStandRi
*
* Functionele omschrijving :
* Bepaalt WS[] van een wachtstand-rood richting
* Wordt gebruikt door de functie WachtStand
**************************************************************************/
boolv WStandRi(count fci, boolv *prml[], count ml, count ml_max)
{
register count hml, hfci;
if (WG[fci])
{
for (hfci = 0; hfci < FC_MAX; ++hfci)
{
if (hfci != fci)
{
for (hml = 0; hml < ml_max; ++hml)
{
if (hml != ml)
{
if ((prml[hml][hfci] & PRIMAIR) && /* Aanvraag of realisatie in ander module */
(R[hfci] && A[hfci] || AR[hfci] && G[hfci] || PG[hfci] & VERSNELD_PRIMAIR))
return (!ka(fci) && WG[fci]);
}
}
if ((prml[ml][hfci] & PRIMAIR) && PG[hfci] &&
R[hfci] && A[hfci]) /* Aanvraag uit zelfde module, maar al */
{
/* eerder primair gerealiseerd */
return (!ka(fci) && WG[fci]);
}
}
}
}
return FALSE;
}
/**************************************************************************
* Functie : WachtStand
*
* Functionele omschrijving :
* Bepaalt WS[] van alle richtingen (wachtstand-rood)
**************************************************************************/
void WachtStand(boolv *prml[], count ml, count ml_max)
{
register count fci;
for (fci = 0;fci < FC_MAX; ++fci)
{
WS[fci]&=~BIT0;
WS[fci] |= WStandRi(fci, prml, ml, ml_max)? BIT0 : 0;
}
}
#endif
/* MAXIMUM REALISATIETIJD VOOR EEN ALTERNATIEVE REALISATIE */
/* ======================================================= */
/* max_tar_to() kan worden gebruikt bij de specificatie van de instructie-
* variabele PAR[] (periode alternatieve realisatie) van de fasecyclus.
* max_tar_to() geeft de maximum tijd in tienden van seconden, die beschikbaar
* is voor het groen van een alternatieve realisatie van de fasecyclus.
* het aanroepen van de functie max_tar_to() dient in de applicatiefunctie
* application() te worden gespecificeerd.
* de beschikbare tijd voor het groen van een alternatieve realisatie van
* de fasecyclus wordt als volgt bepaald:
* . indien er geen (fictief) conficterende fasecycli met een aanvraag
* ( !fka(k) ) aanwezig zijn, wordt een maximale tijd voor alternatieve
* realisatie van de fasecyclus (300 seconden) ingesteld.
* . indien er een (fictief) conflicterende primaire fasecyclus met een
* aanvraag in een volgende module aanwezig is die primair mag worden
* gerealiseerd (AAPR[k] is waar), dan wordt de beschikbare tijd voor
* het groen van een alternatieve realisatie van de fasecyclus bepaald,
* afhankelijk van de resterende (verleng)groentijden in de schaduw van de actieve
* primaire fasecycli t.o.v. de beschouwde (fictief) conflicterende
* fasecyclus vermindert met de tijd van eventueel aanwezige conflictfasen. Tevens
* wordt rekening gehouden met het verschil in geeltijd tussen de primaire en
* alternatieve richting en met het verschil in ontruiming van de primaire en
* alternatieve richting naar de richting met de AAPR.
* . indien er geen (fictief) conflicterende primaire fasecyclus in een
* volgende module met een aanvraag aanwezig is die versneld mag worden
* gerealiseerd (AAPR[k]'s zijn niet waar) dan wordt de beschikbare tijd
* voor alternatieve realisatie van de fasecyclus bepaald door de
* grootste resterende (verleng)groentijd van een actieve primaire
* fasecyclus vermindert met de tijd van eventueel aanwezige conflictfasen.
*
* voorbeeld gebruik:
* PAR[fc01]= (max_tar_to(fc01)>=PRM[prmaltmax01]) && SCH[schar01];
*
*/
#if !defined (CCOLFUNC) || defined (LWFUNC12)
#include "lwvar.h"
#include "fcvar.h"
#include "kfvar.h"
#if !(CCOL_V >= 95) || defined NO_TIGMAX
mulv max_tar_to(count i)
{
register count n, k, nn, kk;
#ifndef NO_CHNG20021126
mulv totxb_min = 0, totxb_min_tmp = 3000, totxb_tmp;
#else
mulv totxb_min = 0, totxb_tmp;
#endif
mulv to_max = 0, to_tmp;
mulv t_aa_max = 0;
mulv aapr_tmp = 0;
if (!kcv(i)) /* let op! i.v.m. snelheid */
{
t_aa_max = 0; /* alleen tijdens !kcv behandeld */
totxb_min = 0;
totxb_tmp = 0;
to_max = to_tmp = 0;
if (!fka(i)) /* geen (fictieve) conflictaanvragen */
{
t_aa_max = 3000; /* maximale realisatietijd */
return((mulv)t_aa_max);
}
for (n = 0; n < FKFC_MAX[i]; n++)
{
#if (CCOL_V >= 95)
k = KF_pointer[i][n];
#else
k = TO_pointer[i][n];
#endif
if (TO[k][i]) /* zoek grootste ontruimingstijd */
{
to_tmp = TGL_max[k] + TO_max[k][i] - TGL_timer[k] - TO_timer[k];
if (to_tmp > to_max)
to_max = to_tmp;
}
if (AAPR[k] && !PAR[k]) /* zoek maximale realisatietijd */
{
aapr_tmp = TRUE; /* t.o.v. te realiseren conflicten */
#ifndef NO_CHNG20021126
totxb_min = totxb_tmp = 0;
#else
totxb_tmp = 0;
#endif
for (nn = 0; nn < GKFC_MAX[k]; nn++)
{
#if (CCOL_V >= 95)
kk = KF_pointer[k][nn];
#else
kk = TO_pointer[k][nn];
#endif
if ((kk != i) && PR[kk])/* test alleen de primaire richtingen */
{
if (G[kk] && !MG[kk] && !FM[kk] && !Z[kk])
{
totxb_tmp = TFG_max[kk] + TVG_max[kk] + TGL_max[kk] + TO_max[kk][k] - TFG_timer[kk] - TVG_timer[kk] - TGL_max[i] - TO_max[i][k];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
else if (RA[kk] && !RR[kk] && !BL[kk])
{
totxb_tmp = TFG_max[kk] + TVG_max[kk] + TGL_max[kk] + TO_max[kk][k] - TGL_max[i] - TO_max[i][k];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
}
}
#ifndef NO_CHNG20021126
if (totxb_min < totxb_min_tmp) totxb_min_tmp = totxb_min;
#endif
}
}
if (t_aa_max >= 0) /* bereken de realisatietijd */
{
if (aapr_tmp) /* primaire conflict aanvraag */
#ifndef NO_CHNG20021126
t_aa_max = totxb_min_tmp - to_max;
#else
t_aa_max = totxb_min - to_max;
#endif
else /* geen primaire conflict aanvraag */
{
totxb_tmp = 0;
for (n = 0; n < FC_MAX; n++) /* zoek langste primaire groentijd */
{
if ((n != i) && (PR[n])) /* test alleen de primaire richtingen */
{
if (G[n] && !MG[n] && !FM[n] && !Z[n])
{
totxb_tmp = TFG_max[n] + TVG_max[n] + TGL_max[n]
- TFG_timer[n] - TVG_timer[n] - TGL_max[i];
if (totxb_tmp > totxb_min)
totxb_min = totxb_tmp;
}
else if (RA[n] && !RR[n] && !BL[n])
{
totxb_tmp = TFG_max[n] + TVG_max[n] + TGL_max[n] - TGL_max[i];
if (totxb_tmp > totxb_min)
totxb_min = totxb_tmp;
}
}
}
t_aa_max = totxb_min - to_max;
}
}
}
else t_aa_max = NG;
#ifdef TEST_TAR
if (i == fc06)
{
gotoxy(1, 1);
printf("TAR_MAX01= %d ", t_aa_max);
gotoxy(1, 2);
printf("totxb_min= %d ", totxb_min);
gotoxy(1, 3);
printf("to_max= %d ", to_max);
}
#endif
return t_aa_max;
}
#else
mulv max_tar_tig(count i)
{
register count n, k, nn, kk;
#ifndef NO_CHNG20021126
mulv totxb_min = 0, totxb_min_tmp = 3000, totxb_tmp;
#else
mulv totxb_min = 0, totxb_tmp;
#endif
mulv to_max = 0, to_tmp;
mulv t_aa_max = 0;
mulv aapr_tmp = 0;
if (!kcv(i)) /* let op! i.v.m. snelheid */
{
t_aa_max = 0; /* alleen tijdens !kcv behandeld */
totxb_min = 0;
totxb_tmp = 0;
to_max = to_tmp = 0;
if (!fka(i)) /* geen (fictieve) conflictaanvragen */
{
t_aa_max = 3000; /* maximale realisatietijd */
return((mulv)t_aa_max);
}
for (n = 0; n < FKFC_MAX[i]; n++)
{
k = KF_pointer[i][n];
if (TIG[k][i]) /* zoek grootste ontruimingstijd */
{
to_tmp = TIG_max[k][i] - TIG_timer[k];
if (to_tmp > to_max)
to_max = to_tmp;
}
if (AAPR[k]) /* zoek maximale realisatietijd */
{
aapr_tmp = TRUE; /* t.o.v. te realiseren conflicten */
#ifndef NO_CHNG20021126
totxb_min = totxb_tmp = 0;
#else
totxb_tmp = 0;
#endif
for (nn = 0; nn < GKFC_MAX[k]; nn++)
{
kk = KF_pointer[k][nn];
if ((kk != i) && PR[kk])/* test alleen de primaire richtingen */
{
if (G[kk] && !MG[kk] && !FM[kk] && !Z[kk])
{
totxb_tmp = TFG_max[kk] + TVG_max[kk] + TIG_max[kk][k] - TFG_timer[kk] - TVG_timer[kk] - TIG_max[i][k];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
else if (RA[kk] && !RR[kk] && !BL[kk])
{
totxb_tmp = TFG_max[kk] + TVG_max[kk] + TIG_max[kk][k] - TIG_max[i][k];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
}
}
#ifndef NO_CHNG20021126
if (totxb_min < totxb_min_tmp) totxb_min_tmp = totxb_min;
#endif
}
}
if (t_aa_max >= 0) /* bereken de realisatietijd */
{
if (aapr_tmp) /* primaire conflict aanvraag */
#ifndef NO_CHNG20021126
t_aa_max = totxb_min_tmp - to_max;
#else
t_aa_max = totxb_min - to_max;
#endif
else /* geen primaire conflict aanvraag */
{
totxb_tmp = 0;
for (n = 0; n < FC_MAX; n++) /* zoek langste primaire groentijd */
{
if ((n != i) && (PR[n])) /* test alleen de primaire richtingen */
{
if (G[n] && !MG[n] && !FM[n] && !Z[n])
{
totxb_tmp = TFG_max[n] + TVG_max[n] + TGL_max[n]
- TFG_timer[n] - TVG_timer[n] - TGL_max[i];
if (totxb_tmp > totxb_min)
totxb_min = totxb_tmp;
}
else if (RA[n] && !RR[n] && !BL[n])
{
totxb_tmp = TFG_max[n] + TVG_max[n] + TGL_max[n] - TGL_max[i];
if (totxb_tmp > totxb_min)
totxb_min = totxb_tmp;
}
}
}
t_aa_max = totxb_min - to_max;
}
}
}
else t_aa_max = NG;
#ifdef TEST_TAR
if (i == fc06)
{
gotoxy(1, 1);
printf("TAR_MAX01= %d ", t_aa_max);
gotoxy(1, 2);
printf("totxb_min= %d ", totxb_min);
gotoxy(1, 3);
printf("to_max= %d ", to_max);
}
#endif
return t_aa_max;
}
#endif /* NO_TIGMAX */
#endif
/* MAXIMUM REALISATIETIJD VOOR EEN ALTERNATIEVE REALISATIE ONDER OV-INGREEP */
/* ======================================================================== */
/* max_tar_ov() kan worden gebruikt bij de specificatie van de instructie-
* variabele PAR[] (periode alternatieve realisatie) van de fasecyclus.
* max_tar_to() geeft de maximum tijd in tienden van seconden, die beschikbaar
* is voor het groen van een alternatieve realisatie van de fasecyclus.
* het aanroepen van de functie max_tar_to() dient in de applicatiefunctie
* application() te worden gespecificeerd.
* de beschikbare tijd voor het groen van een alternatieve realisatie van
* de fasecyclus wordt als volgt bepaald:
* . indien er geen (fictief) conficterende fasecycli met een aanvraag
* ( !fka(k) ) aanwezig zijn, wordt een maximale tijd voor alternatieve
* realisatie van de fasecyclus (300 seconden) ingesteld.
* . indien er een (fictief) conflicterende primaire fasecyclus met een
* aanvraag in een volgende module aanwezig is die primair mag worden
* gerealiseerd (AAPR[k] is waar), dan wordt de beschikbare tijd voor
* het groen van een alternatieve realisatie van de fasecyclus bepaald,
* afhankelijk van de resterende (verleng)groentijden in de schaduw van de actieve
* OV-fasecycli t.o.v. de beschouwde (fictief) conflicterende
* fasecyclus vermindert met de tijd van eventueel aanwezige conflictfasen. Tevens
* wordt rekening gehouden met het verschil in geeltijd tussen de OV- en
* alternatieve richting en met het verschil in ontruiming van de OV- en
* alternatieve richting naar de richting met de AAPR.
* . indien er geen (fictief) conflicterende primaire fasecyclus in een
* volgende module met een aanvraag aanwezig is die versneld mag worden
* gerealiseerd (AAPR[k]'s zijn niet waar) dan wordt de beschikbare tijd
* voor alternatieve realisatie van de fasecyclus bepaald door de
* grootste resterende (verleng)groentijd van een actieve OV-
* fasecyclus vermindert met de tijd van eventueel aanwezige conflictfasen.
*
* voorbeeld gebruik:
* PAR[fc01]= (max_tar_ov(fc01)>=PRM[prmaltmax01]) && SCH[schar01];
*
*/
mulv max_tar_ov(count i, ...) /* i=alt.ri. */
{
/* variabele argumentenlijst */
va_list argpt;
/* ov=ov-richting vb=vecombewakingstijd h=ov-hulpelement */
register count k, n = 0, ov, vb = 0, h = 0;
mulv totxb_min = 0, totxb_tmp;
mulv to_max = 0, to_tmp;
mulv t_aa_max = 0;
mulv t_aa_max_max = 0;
mulv aapr_tmp = 0;
va_start(argpt, i); /* start var. argumentenlijst */
do
{
ov = va_arg(argpt, va_count); /* lees array-nummer ov-fc */
if (ov >= 0)
{
vb = va_arg(argpt, va_count); /* lees waarde vb */
if (vb >= 0)
{
h = va_arg(argpt, va_count); /* lees waarde h */
#if (CCOL_V >= 95) && !defined NO_TIGMAX
if (h >= 0 && IH[h] && (TIG_max[ov][i] == NG) && T[vb])
#else
if (h >= 0 && IH[h] && (TO_max[ov][i] == NG) && T[vb])
#endif
{
if (!kcv(i) || TRUE) /* let op! i.v.m. snelheid alleen tijdens !kcv behandeld */ //@@ TRUE is constant; warning C4127: conditional expression is constant
{
t_aa_max = 0;
totxb_min = 0;
totxb_tmp = 0;
to_max = to_tmp = 0;
if (!fka(i)) /* geen (fictieve) conflictaanvragen */
{
t_aa_max = 3000; /* maximale realisatietijd */
return((mulv)t_aa_max);
}
for (n = 0; n < FKFC_MAX[i]; ++n)
{
#if (CCOL_V >= 95)
k = KF_pointer[i][n];
#else
k = TO_pointer[i][n];
#endif
#if (CCOL_V >= 95) && !defined NO_TIGMAX
if (TIG[k][i]) /* zoek grootste ontruimingstijd */
{
to_tmp = TIG_max[k][i] - TIG_timer[k];
#else
if (TO[k][i]) /* zoek grootste ontruimingstijd */
{
to_tmp = TGL_max[k] + TO_max[k][i] - TGL_timer[k] - TO_timer[k];
#endif
if (to_tmp > to_max)
to_max = to_tmp;
}
if (AAPR[k]) /* zoek maximale realisatietijd */
{
aapr_tmp = TRUE; /* t.o.v. te realiseren conflicten */
totxb_tmp = 0;
if (G[ov])
{
#if (CCOL_V >= 95) && !defined NO_TIGMAX
totxb_tmp = T_max[vb] + TIG_max[ov][k] - T_timer[vb] - TIG_max[i][k];
#else
totxb_tmp = T_max[vb] + TGL_max[ov] + TO_max[ov][k] - T_timer[vb] - TGL_max[i] - TO_max[i][k];
#endif
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
else if (RA[ov] && !RR[ov] && !BL[ov])
{
#if (CCOL_V >= 95) && !defined NO_TIGMAX
totxb_tmp = T_max[vb] + TIG_max[ov][k] - TIG_max[i][k];
#else
totxb_tmp = T_max[vb] + TGL_max[ov] + TO_max[ov][k] - TGL_max[i] - TO_max[i][k];
#endif
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
}
}
if (t_aa_max >= 0) /* bereken de realisatietijd */
{
if (aapr_tmp) /* primaire conflict aanvraag */
t_aa_max = totxb_min - to_max;
else /* geen primaire conflict aanvraag */
{
totxb_tmp = 0;
if (G[ov])
{
totxb_tmp = T_max[vb] + TGL_max[ov] - T_timer[vb] - TGL_max[i];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
else if (RA[ov] && !RR[ov] && !BL[ov])
{
totxb_tmp = T_max[vb] + TGL_max[ov] - TGL_max[i];
if (totxb_tmp > totxb_min)
{
totxb_min = totxb_tmp;
}
}
t_aa_max = totxb_min - to_max;
}
}
else
{
t_aa_max = NG;
}
if (t_aa_max > t_aa_max_max)
{
t_aa_max_max = t_aa_max;
}
}
}
}
}
} while ((ov >= 0) && (vb >= 0) && (h >= 0));
va_end(argpt); /* maak var. arg-lijst leeg */
return t_aa_max_max;
}
#ifdef __BORLANDC__
#pragma argsused
#endif
/**************************************************************************
* Functie : AlternatieveRuimte
*
* Functionele omschrijving :
* Deze functie bepaalt of een alternatieve richting in ieder geval
* zijn minimale alternatieve groentijd kan maken tijdens het
* resterende (verleng)groen van de primaire richting. De boolv
* AlternatieveRuimte moet als voorwaarde worden opgenomen
* in de functies set_ARML() en YML[].
*
* Parameters:
* - fcprim primaire richting in wiens schaduw fcalt mag komen
* - paltg minimaal gewenste alternatieve groentijd
**************************************************************************/
boolv AlternatieveRuimte(count fcprim, count paltg)
{
return (TVG_max[fcprim] - TVG_timer[fcprim] >= PRM[paltg]);
}
boolv no_conflict(count fc1par, count fc2ov)
{
count l, c;
if (fc1par == fc2ov) return (FALSE);
else
{
for (l = 0; l < GKFC_MAX[fc1par]; ++l)
{
#if (CCOL_V >= 95)
c = KF_pointer[fc2ov][l];
#else
c = TO_pointer[fc2ov][l];
#endif
if (c == fc1par) return(FALSE);
}
}
return(TRUE);
}
#if !defined (CCOLFUNC) || defined (LWMLFUNC7)
boolv testpri_gk_calw(count i)
{
register count n, j;
for (n = 0; n < GKFC_MAX[i]; ++n)
{
#if (CCOL_V >= 95)
j = KF_pointer[i][n];
#else
j = TO_pointer[i][n];
#endif
if ((R[j] || GL[j]) && !RR[j] && !BL[j] && (/* AA[j] && !AR[j]
|| */ (CALW[j]>CALW[i])))
return FALSE;
/* test of !AR[j] i.v.m. het mogelijk tegenhouden (RR[]) */
/* alternatieve realisaties mbv rr_ar_fkpr() */
} /* de vraag is of hier wel op RR[] moet worden getest */
/* indien slechts een tijdelijke volgorde van afwikkeling */
return TRUE; /* m.b.v. RR[] moet worden beheerst */
}
/* SET prioriteitsrealisatie */
/* ========================= */
/* set_PRIRLW() is een variant op set_PRILW() in LWMLFUNC.C
* in plaats van de functies testpri_fk_calw() en fkaa() worden de functies testpri_gk_calw(i) en kcv(i) aangeroepen
* dit is gedaan om te voorkomen dat een prioriteitsrealisatie ten onrechte wordt tegengehouden, als een fictief conflict in RA staat
*
* set_PRIRLW() sets AA[] and PR[] als een primaire prioriteitsrealisatie met BIT6
* set_PRIRLW() returns TRUE, als het AAPR_bit wordt geset, anders FALSE.
* set_PRIRLW() roept testpri_gk_calw() aan en kcv().
* set_PRIRLW() wordt aangeroepen in de procedure OVBijzonderRealiseren() in ov.c
*/
boolv set_PRIRLW(count i, boolv period)
{
if (AAPR[i] && !AA[i]) AAPR[i] = FALSE;
if (!AA[i] && period && (CALW[i] >= PRI_CALW) && A[i] && RV[i]
&& !TRG[i] && !RR[i] && !BL[i] && testpri_gk_calw(i))
{
AAPR[i] = FALSE;
if (kcv(i)) AAPR[i] |= BIT6; /* prioriteit! */
if (!AAPR[i])
{
AAPR[i] = TRUE;
AAPR[i] |= BIT6;
AA[i] = TRUE; /* set actuation */
PR[i] = BIT6;
}
return (TRUE);
}
return (FALSE);
}
#endif
/* SET ALTERNATIVE REALIZATION BIT6 BIJ OV-MEEREALISATIE */
/* ===================================================== */
/* set_ARLW_bit6() sets an alternative realization BIT6 verder idem lwfunc.c
*/
#if !defined (CCOLFUNC) || defined (LWFUNC4)
boolv set_ARLW_bit6 (count i)
{
if (PAR[i] && A[i] && RV[i] && !TRG[i] && !AA[i] && !RR[i]
&& !BL[i] && !kcv(i) && !fkaa(i) && testar_fk_calw(i))
{
AA[i] = TRUE; /* set actuation */
AR[i] = BIT6;
return TRUE;
}
return FALSE;
}
void langstwachtende_alternatief_bit6(void)
{
register count i;
for (i=0; i<FC_MAX; i++)
{
set_ARLW_bit6(i);
}
}
#endif