-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIRunsim.mod
executable file
·9257 lines (9113 loc) · 392 KB
/
IRunsim.mod
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
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{++++++++++++++++++++++++++++++++++++++RAPTOR++++++++++++++++++++++++++++++++++++++}
{+ +}
{+ Implementation Module : IRunsim +}
{+ Author : Chuck Carter / Tony Malerich +}
{+ Last Modified : June 2007 CMC +}
{+ +}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
IMPLEMENTATION MODULE Runsim;
FROM MathMod IMPORT LOG10,POWER,FLOOR,SQRT;
FROM SimMod IMPORT SimTime,StartSimulation,StopSimulation,Timescale,ResetSimTime,ActivityGroup,ActivityOwner,TriggerObj,
SimControlObj,ActivityName,Interrupt;
FROM StatMod IMPORT ITimedStatObj,RStatObj,IStatObj;
FROM IOMod IMPORT StreamObj, FileUseType(Input, Output, Update, Append);
FROM GrpMod IMPORT QueueObj;
FROM Display IMPORT window,nameOfFile,simMenuBar,sound,soundIsOn,startId,endId,simulated,root,totalBlocks,totalNodes,
totalLinks,totalPools,PoolArray,sysStreams,phaseTimes,activePhases,AoGraph,IntAoGraph,MultiRunGraph,
currentGraph,dialogs,AoGraphWindow,faceBoxOpen,menubar,soundsPath,costAnalysis,weakAnalysis,
capacityAnalysis,systemRedCost,flowGenerated,statusBarOn,dZeroFail,simToolBar,hitXinSim,sysLostCost,
phaseObjArray,diagnostics,diagnosticsStream,{installPath,}diagFile,termType,DomainTree,CoreFile,
blockGroup,eventGroup,hierGroup,linkGroup,totalEvents,password,C130File;
FROM Intract IMPORT SendAlert,returnToRBD;
FROM Label IMPORT LabelObj;
FROM Objects IMPORT RBDBlockObj,RBDNodeObj,RBDHierObj,LinkObj,ALL BlockStatusType,ALL NodeStatusType,ALL ActiveStatusType,
ALL LinkStatusType,DetermineMaxCapacity,FlowingAtMaxCap,ALL SparingType,totalSpares,totalCold,
totalRes,poolGroup,SparePoolObj,ALL directionType,AnalyzeSystem,CheckColds,SystemStateChange,
RapTriggerObj,triggerGroup,PhaseObj,WriteEvents,critFactor,RBDEventObj,ALL EventStatusType,
RBDBasicObj, deferTrig;
FROM GTypes IMPORT ALL ColorType,TextBufferType,ALL SysCursorType;
FROM GTable IMPORT TableObj;
FROM Menu IMPORT MenuItemObj;
FROM GProcs IMPORT HandleEvents;
FROM OSMod IMPORT FileExists;
FROM FileFx IMPORT SaveAsFile;
FROM Text IMPORT TextObj;
FROM Analyze IMPORT BlockAlphaSort,NodeAlphaSort,totalCapNodes,FetchRaptorSeed,CreateDomainTree,
EventAlphaSort,HierAlphaSort,randNumCount;
FROM UtilMod IMPORT DateTime;
FROM GPalet IMPORT PaletteButtonObj;
FROM Menubar IMPORT inStepMode,inJumpMode,inEndState,goToNext,FEVStream;
VAR
runNumber,NumRuns,missionsCompleted,missionsAttempted,missionsBegan,
currentPhase,startTag : INTEGER;
SimCompleted,SpareMonsCreated,result,BlockCostMonsSet,PoolCostMonsSet,
EndSpMonCreated,capacityMonsSet,weakAnalysisMonsSet,Aborted,
KeepSimStats,KeepRunStats,NodeFile,keyParamFile,SysFailTimeFile,
SparesFile, EORFile, ResultsFile,TieBreaking, EndSimTimeFile,
AvailPlotFile,EndSimCalled,ZeroInitCost,MTBDEsusp,MTBMsusp,MTBMsupdated,
MTBMuupdated,MTBDEupdated,MDTupdated,MTBMupdated,MMTsupdated,MMTupdated,
MMTuupdated,MTBMssusp,MTBMususp,preFEVcost, preFEVnode,preFEVgraphics,
missionSuccess,earlyAbort,jumpStop,didPM : BOOLEAN;
SysTimeToFail,GreenTime,YellowTime,RedTime,Availability,MTBDE,MDT,
MTBMu,MTBM,MTBMs,MMTs,MMT,MMTu,Term1Condition,GreenPercent,YellowPercent,
RedPercent,GTotal,SystemEndRedCost,SystemEndLostCost,UnitsProduced,
MissionGrnTime,MissionYelTime,MissionRedTime,Dependability,MissionGrnPer,
MissionYelPer,MissionRedPer,Reliability,RCond,Term2Cond,Term3Cond : LMONITORED REAL BY RStatObj;
LastColorChange,AoPlotInterval,CostPlotInterval,TotalTime,
LastMissionChange,MissionTotalTime,TotalRedCost,cyclesCount,relMesh,kpfTimeMesh : REAL; {cmc 3/6/07}
SparesTrackingGroup,BlockPhaseChangeGroup,NodePhaseChangeGroup,
BlockPhaseImproveGroup,NodePhaseImproveGroup,BlockPhaseDegradeGroup,
NodePhaseDegradeGroup,BlockPhaseStressGroup : QueueObj;
AveNumSpares,NodeEndGreen,NodeEndYellow,NodeEndRed,NodeEndBrown,
NodeEndBlue,NodeEndAo,NodeEndDo,NodeEndR,BlockEndOpCost,
BlockEndRepCost,BlockEndSpCost,BlockEndIdleCost,BlockEndHoldCost,
BlockEndSBCost,BlockEndDoneCost,BlockEndDispCost,PoolEndAddCost,
PoolEndESCost,MultiRunData,BlockEndESCost,NodeEndOrange,
NodeUsage,NodeAveFlow,NodeAveCap,NodeCapability,
BlockEndPMCost,BlockEndpmHoldCost,BlockEndRun,BlockEndStandby,
BlockEndRep,BlockEndRepHold,BlockEndIdle,BlockEndPM,BlockEndPMHold,
BlockEndDone,BlockEndAo,BlockEndDo,BlockEndR,hMTBDE,hMDT,
EventEndOpCost,EventEndRepCost,EventEndRun,EventEndStandby,
EventEndRep,EventEndAo,EventEndDo,EventEndR,
CumAoByTime,CumMTBDEbyTime,CumMDTbyTime,CumMTBMbyTime,CumMMTbyTime {cmc 3/6/07} : ARRAY INTEGER OF LMONITORED REAL BY RStatObj;
MinNumSpares,MaxNumSpares,NumOfWaits,EndingSpares,EndSparesUsed,
InitNumSpares,NewSpares,NodeMinFlow,NodeMaxFlow,NodeMinCap,NodeMaxCap: ARRAY INTEGER OF LMONITORED INTEGER BY IStatObj;
MinNumSparesMon,MaxNumSparesMon, NumOfWaitsMon, EndingSparesMon,
InitNumSparesMon,NodeMinFlowMon,NodeMaxFlowMon,NodeMinCapMon,
NodeMaxCapMon,EndSparesUsedMon,NewSparesMon : IStatObj;
SysFailMon,SysRepMon,CompFailMon,CompRepairMon,CompPMMon,GreenMon,RedMon,
YellowMon,NodeGreenMon,NodeYellowMon,NodeRedMon,NodeBlueMon,NodeBrownMon,
SystemCostMon,SystemLostCostMon,OpCostMon,RepCostMon,BlockSpCostMon,
BlockESCostMon,BlockIdleCostMon,BlockHoldCostMon,BlockSBCostMon,
BlockDoneCostMon,PoolAddCostMon,PoolESCostMon,MultiRunDataMon,AvailMon,
MTBDEMon,MDTMon,MTBMuMon,MTBMsMon,MTBMMon,MMTsMon,MMTMon,MMTuMon,
Term1Mon,GreenPercentMon,YellowPercentMon,RedPercentMon,GTotalMon,
BlockDispCostMon,NodeAveFlowMon,NodeUsageMon,NodeAveCapMon,
NodeCapabilityMon,AveNumSparesMon,UnitsProducedMon,MissionGrnMon,
MissionYelMon,MissionRedMon,DependMon,NodeOrangeMon,MissionGrnPerMon,
MissionYelPerMon,MissionRedPerMon,BlockPMCostMon,BlockpmHoldCostMon,
RMon,RCondMon,RunMon,StandbyMon,RepMon,BlockRepHoldMon,BlockIdleMon,
BlockPMMon,BlockPMHoldMon,BlockDoneMon,Term2Mon,Term3Mon,hMTBDEMon,
hMDTMon,AoMon,DoMon,CompRMon,
CumAoByTimeMon,CumMTBDEbyTimeMon,CumMDTbyTimeMon,CumMTBMbyTimeMon,CumMMTbyTimeMon : RStatObj; {cmc 3/6/07}
CustSpareMon,PoolMon,NodeFlowMon,NodeCapMon : ARRAY INTEGER OF ITimedStatObj;
EventController : RBDSimControlObj;
keyStream,SpareStream,EndOfRunStream,EndSimTimeStream,NodeStream,
CostStream,AoPlotStream,ResultsStream,RamStream,relStream,kpfTimeStream : StreamObj; {cmc 3/6/07}
message : TextBufferType;
Date : STRING;
reliabilityFileData : ARRAY INTEGER OF INTEGER;
PROCEDURE StartEngine(IN useGraphics,sysFailFile,sysRepFile,endSimFile,paramFile,
AoPlotFile,capFile,resultsFile,eorFile,eventsFile,costFile,
availGraph : BOOLEAN;
IN costPlotInterval,aoPlotInterval,simLength,startStat,TimeSlice,rMesh : REAL;
IN numTrials,RamInterval : INTEGER);
VAR
nextString,printString,header : STRING;
block : RBDBlockObj;
event : RBDEventObj;
node : RBDNodeObj;
hier : RBDHierObj;
i,j,rejectedFlow, totalIntervals : INTEGER;
flowLabel : TextObj;
button : PaletteButtonObj;
item : MenuItemObj;
trig : RapTriggerObj;
phase : PhaseObj;
link : LinkObj;
clickedOn : ANYOBJ;
thing : RBDBasicObj;
BEGIN
DateTime(Date);
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="StartSimulation " + Date;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
GraphicsOutput:=useGraphics;
SysFailTimeFile:=sysFailFile;
SysRepTimeFile:=sysRepFile;
EndSimTimeFile:=endSimFile;
keyParamFile:=paramFile;
AvailPlotFile:=AoPlotFile;
CapFile:=capFile;
ResultsFile:=resultsFile;
EORFile:=eorFile;
EventsFile:=eventsFile;
CostFile:=costFile;
AvailGraph:=availGraph;
CostPlotInterval:=costPlotInterval;
AoPlotInterval:=aoPlotInterval;
tab:=9C;{ASCII character for a tab}
StopCriteria:=simLength;
StartStats:=startStat;
NumRuns:=numTrials;
{ IF (rMesh>0.0) {cmc 3/6/07}
relMesh:=rMesh;
kpfTimeMesh:=0.0;
ELSIF (rMesh<0.0)
relMesh:=0.0;
kpfTimeMesh:=-rMesh;
ELSE
relMesh:=0.0;
kpfTimeMesh:=0.0;
END IF; }
IF (rMesh>0.0) {cmc 3/6/07}
relMesh:=rMesh;
kpfTimeMesh:=rMesh;
ELSE
relMesh:=0.0;
kpfTimeMesh:=0.0;
END IF;
exploded:=FALSE;
Aborted:=FALSE;
SimCompleted:=FALSE;
KeepRunStats:=TRUE;
KeepSimStats:=TRUE;
StatsReset:=FALSE;
SpareMonsCreated:=FALSE;
EndSpMonCreated:=FALSE;
OutOfSpares:=FALSE;
MTBDEsusp:=FALSE;
MTBMsusp:=FALSE;
MTBMususp:=FALSE;
MTBMssusp:=FALSE;
didPM:=FALSE; {tony 12-04: to get N/As in MTBMs only when appropriate}
CountFailure:=TRUE;
ZeroInitCost:=FALSE;
jumpStop:=FALSE;
IF password
randNumCount:=0;
END IF;
NEW(EventController);
NEW(System);
NEW(BlockDepGroup);
NEW(NodeDepGroup);
NEW(ColdChangeGroup);
NEW(SparesTrackingGroup);
IF activePhases>0
NEW(BlockPhaseChangeGroup);
NEW(BlockPhaseImproveGroup);
NEW(BlockPhaseDegradeGroup);
NEW(BlockPhaseStressGroup);
NEW(NodePhaseChangeGroup);
NEW(NodePhaseImproveGroup);
NEW(NodePhaseDegradeGroup);
NEW(pmDeferGroup);
NEW(pmSyncTrigger);
IF weakAnalysis
NEW(NodeFailureGroup);
END IF;
END IF;
NEW(SysStream,1..11);
FOR i:=1 TO 11
NEW(SysStream[i]);
ASK SysStream[i] TO SetSeed(FetchRaptorSeed(ABS(sysStreams[i])));
IF sysStreams[i]<0
ASK SysStream[i] TO SetAntithetic(TRUE);
END IF;
END FOR;
IF totalBlocks>0
NEW(FailStream,1..totalBlocks);
NEW(RepairStream,1..totalBlocks);
NEW(BlockTrigger,1..totalBlocks);
END IF;
IF totalEvents>0
NEW(EventFailStream,1..totalEvents);
END IF;
OpenOutFiles(RamInterval);
FOREACH block IN blockGroup
NEW(BlockTrigger[block.seqNum]);
ASK block TO Initialize;
IF ((block.usesPhasing) AND (activePhases>0))
ASK BlockPhaseChangeGroup TO Add(block);
END IF;
IF (block.sparingType = Custom)
ASK SparesTrackingGroup TO Add(block);
END IF;
IF (block.failStream<70)
NEW(FailStream[block.seqNum]);
ASK FailStream[block.seqNum] TO SetSeed(FetchRaptorSeed(ABS(block.failStream)));
IF block.failStream<0
ASK FailStream[block.seqNum] TO SetAntithetic(TRUE);
END IF;
NEW(RepairStream[block.seqNum]);
ASK RepairStream[block.seqNum] TO SetSeed(FetchRaptorSeed(ABS(block.repairStream)));
IF block.repairStream<0
ASK RepairStream[block.seqNum] TO SetAntithetic(TRUE);
END IF;
END IF;
ASK block TO CheckForDeps;
END FOREACH;
FOREACH event IN eventGroup
ASK event TO Initialize;
IF ((event.usesPhasing) AND (activePhases>0))
ASK BlockPhaseChangeGroup TO Add(event);
END IF;
IF (event.failStream<70)
NEW(EventFailStream[event.seqNum]);
ASK EventFailStream[event.seqNum] TO SetSeed(FetchRaptorSeed(ABS(event.failStream)));
IF event.failStream<0
ASK EventFailStream[event.seqNum] TO SetAntithetic(TRUE);
END IF;
END IF;
END FOREACH;
FOREACH node IN nodeGroup
IF node.Id=startId
startTag:=node.seqNum;
END IF;
ASK node TO Initialize();
IF ((node.usesPhasing) AND (activePhases>0))
ASK NodePhaseChangeGroup TO Add(node);
END IF;
IF node.coldStandby
ASK node TO IdAndSortColds; {csb speed change removed line }
END IF;
IF capacityAnalysis AND (node.CapConnectTo<>NILARRAY)
ASK node TO SortCapacityArrays;
END IF;
ASK node TO CheckForDeps;
END FOREACH;
NEW(nodeHasDepsGroup);
FOREACH node IN nodeGroup
IF node.hasDepObjects
ASK nodeHasDepsGroup TO Add(node);
END IF;
END FOREACH;
NEW(blockHasDepsGroup);
FOREACH block IN blockGroup
IF block.hasDepObjects
ASK blockHasDepsGroup TO Add(block);
END IF;
END FOREACH;
NEW(eventHasDepsGroup);
FOREACH event IN eventGroup
IF event.hasDepObjects
ASK eventHasDepsGroup TO Add(event);
END IF;
END FOREACH;
IF totalBlocks>0
NEW(SparesUsed,1..totalBlocks);
NEW(EndSparesUsed,1..totalBlocks);
END IF;
IF ((SparesTrackingGroup.numberIn>0) OR (totalPools>0))
NEW(InitNumSpares,1..(totalBlocks+totalPools));
NEW(AveNumSpares,1..(totalBlocks+totalPools));
NEW(MinNumSpares,1..(totalBlocks+totalPools));
NEW(MaxNumSpares,1..(totalBlocks+totalPools));
NEW(NumOfWaits,1..(totalBlocks+totalPools));
NEW(EndingSpares,1..(totalBlocks+totalPools));
NEW(NewSpares,1..(totalBlocks+totalPools));
NEW(currNumWaits,1..(totalBlocks+totalPools));
NEW(currNumArrivals,1..(totalBlocks+totalPools));
NEW(currInitNumber,1..(totalBlocks+totalPools));
END IF;
IF (SparesTrackingGroup.numberIn>0)
NEW(CustomSpares,1..totalBlocks);
NEW(SparesAvailable,1..totalBlocks);
NEW(CustSpareMon,1..totalBlocks);
FOREACH block IN SparesTrackingGroup
j:=block.seqNum;
NEW(CustomSpares[j]);
CustSpareMon[j]:=GETMONITOR(SparesAvailable[j],ITimedStatObj);
ASK CustSpareMon[j] TO Reset;
END FOREACH;
END IF;
IF (totalPools>0)
NEW(PooledSpares,1..totalPools);
NEW(PoolResAvailable,1..totalPools);
NEW(PoolMon,1..totalPools);
FOR i:= 1 TO totalPools
NEW(PooledSpares[i]);
PoolMon[i]:=GETMONITOR(PoolResAvailable[i],ITimedStatObj);
ASK PoolMon[i] TO Reset;
END FOR;
END IF;
IF weakAnalysis
NEW(NodeGreenTime,1..totalNodes);
NEW(NodeYellowTime,1..totalNodes);
NEW(NodeRedTime,1..totalNodes);
NEW(NodeBlueTime,1..totalNodes);
NEW(NodeBrownTime,1..totalNodes);
NEW(NodeOrangeTime,1..totalNodes);
NEW(NodeEndGreen,1..totalNodes);
NEW(NodeEndYellow,1..totalNodes);
NEW(NodeEndRed,1..totalNodes);
NEW(NodeEndBlue,1..totalNodes);
NEW(NodeEndBrown,1..totalNodes);
NEW(NodeEndOrange,1..totalNodes);
NEW(NodeEndAo,1..totalNodes);
NEW(NodeEndDo,1..totalNodes);
NEW(NodeEndR,1..totalNodes);
IF totalBlocks>0
NEW(BlockRunTime,1..totalBlocks);
NEW(BlockStandbyTime,1..totalBlocks);
NEW(BlockRepairTime,1..totalBlocks);
NEW(BlockRepHoldTime,1..totalBlocks);
NEW(BlockIdleTime,1..totalBlocks);
NEW(BlockPMTime,1..totalBlocks);
NEW(BlockPMHoldTime,1..totalBlocks);
NEW(BlockDoneTime,1..totalBlocks);
NEW(BlockEndRun,1..totalBlocks);
NEW(BlockEndStandby,1..totalBlocks);
NEW(BlockEndRep,1..totalBlocks);
NEW(BlockEndRepHold,1..totalBlocks);
NEW(BlockEndIdle,1..totalBlocks);
NEW(BlockEndPM,1..totalBlocks);
NEW(BlockEndPMHold,1..totalBlocks);
NEW(BlockEndDone,1..totalBlocks);
NEW(BlockEndAo,1..totalBlocks);
NEW(BlockEndDo,1..totalBlocks);
NEW(BlockEndR,1..totalBlocks);
NEW(blockMissionBool,1..totalBlocks);
NEW(blockMCompleted,1..totalBlocks);
END IF;
NEW(nodeMissionBool,1..totalNodes);
NEW(nodeMCompleted,1..totalNodes);
IF totalEvents>0
NEW(EventRunTime,1..totalEvents);
NEW(EventStandbyTime,1..totalEvents);
NEW(EventRepairTime,1..totalEvents);
NEW(EventEndRun,1..totalEvents);
NEW(EventEndStandby,1..totalEvents);
NEW(EventEndRep,1..totalEvents);
NEW(EventEndAo,1..totalEvents);
NEW(EventEndDo,1..totalEvents);
NEW(EventEndR,1..totalEvents);
NEW(eventMissionBool,1..totalEvents);
NEW(eventMCompleted,1..totalEvents);
END IF;
IF totalHiers>0
NEW(hMTBDE,1..totalHiers);
NEW(hMDT,1..totalHiers);
NEW(hierDE,1..totalHiers);
END IF;
END IF;
IF costAnalysis
IF totalBlocks>0
NEW(BlockRepCost,1..totalBlocks);
NEW(BlockOpCost,1..totalBlocks);
NEW(BlockSpCost,1..totalBlocks);
NEW(BlockESCost,1..totalBlocks);
NEW(BlockIdleCost,1..totalBlocks);
NEW(BlockHoldCost,1..totalBlocks);
NEW(BlockPMCost,1..totalBlocks);
NEW(BlockpmHoldCost,1..totalBlocks);
NEW(BlockSBCost,1..totalBlocks);
NEW(BlockDoneCost,1..totalBlocks);
NEW(BlockDispCost,1..totalBlocks);
NEW(BlockEndOpCost,1..totalBlocks);
NEW(BlockEndRepCost,1..totalBlocks);
NEW(BlockEndSpCost,1..totalBlocks);
NEW(BlockEndIdleCost,1..totalBlocks);
NEW(BlockEndHoldCost,1..totalBlocks);
NEW(BlockEndPMCost,1..totalBlocks);
NEW(BlockEndpmHoldCost,1..totalBlocks);
NEW(BlockEndSBCost,1..totalBlocks);
NEW(BlockEndESCost,1..totalBlocks);
NEW(BlockEndDoneCost,1..totalBlocks);
NEW(BlockEndDispCost,1..totalBlocks);
END IF;
IF totalEvents>0
NEW(EventOpCost,1..totalEvents);
NEW(EventRepCost,1..totalEvents);
NEW(EventEndOpCost,1..totalEvents);
NEW(EventEndRepCost,1..totalEvents);
END IF;
SystemCostMon:=GETMONITOR(SystemEndRedCost,RStatObj);
ASK SystemCostMon TO Reset;
SystemLostCostMon:=GETMONITOR(SystemEndLostCost,RStatObj);
ASK SystemLostCostMon TO Reset;
END IF;
IF capacityAnalysis
NEW(NodeAveFlow,1..totalNodes);
NEW(NodeMinFlow,1..totalNodes);
NEW(NodeMaxFlow,1..totalNodes);
NEW(NodeUsage,1..totalNodes);
NEW(NodeAveCap,1..totalNodes);
NEW(NodeMinCap,1..totalNodes);
NEW(NodeMaxCap,1..totalNodes);
NEW(NodeCapability,1..totalNodes);
FlowingAtMaxCap:=FALSE;
DetermineMaxCapacity(i);
IF flowGenerated=i
FlowingAtMaxCap:=TRUE;
END IF;
END IF;
IF ((totalPools>0) AND costAnalysis)
NEW(PoolAddCost,1..totalPools);
NEW(PoolESCost,1..totalPools);
NEW(PoolEndAddCost,1..totalPools);
NEW(PoolEndESCost,1..totalPools);
END IF;
SysFailMon:=GETMONITOR(SysTimeToFail,RStatObj);
ASK SysFailMon TO Reset;
SysRepMon:=GETMONITOR(SysTimeToRepair,RStatObj);
ASK SysRepMon TO Reset;
CompFailMon:=GETMONITOR(CompTimeToFail,RStatObj);
ASK CompFailMon TO Reset;
CompRepairMon:=GETMONITOR(CompTimeToRepair,RStatObj);
ASK CompRepairMon TO Reset;
CompPMMon:=GETMONITOR(CompTimeToDoPM,RStatObj);
ASK CompPMMon TO Reset;
GreenMon:=GETMONITOR(GreenTime,RStatObj);
ASK GreenMon TO Reset;
YellowMon:=GETMONITOR(YellowTime,RStatObj);
ASK YellowMon TO Reset;
RedMon:=GETMONITOR(RedTime,RStatObj);
ASK RedMon TO Reset;
MissionGrnMon:= GETMONITOR(MissionGrnTime,RStatObj);
ASK MissionGrnMon TO Reset;
MissionYelMon:= GETMONITOR(MissionYelTime,RStatObj);
ASK MissionYelMon TO Reset;
MissionRedMon:= GETMONITOR(MissionRedTime,RStatObj);
ASK MissionRedMon TO Reset;
AvailMon:=GETMONITOR(Availability,RStatObj);
ASK AvailMon TO Reset;
DependMon:=GETMONITOR(Dependability,RStatObj);
ASK DependMon TO Reset;
GTotalMon:=GETMONITOR(GTotal,RStatObj);
ASK GTotalMon TO Reset;
MTBDEMon:=GETMONITOR(MTBDE,RStatObj);
ASK MTBDEMon TO Reset;
MDTMon:=GETMONITOR(MDT,RStatObj);
ASK MDTMon TO Reset;
MTBMuMon:=GETMONITOR(MTBMu,RStatObj);
ASK MTBMuMon TO Reset;
MTBMsMon:=GETMONITOR(MTBMs,RStatObj);
ASK MTBMsMon TO Reset;
MTBMMon:=GETMONITOR(MTBM,RStatObj);
ASK MTBMMon TO Reset;
MMTsMon:=GETMONITOR(MMTs,RStatObj);
ASK MMTsMon TO Reset;
MMTMon:=GETMONITOR(MMT,RStatObj);
ASK MMTMon TO Reset;
MMTuMon:=GETMONITOR(MMTu,RStatObj);
ASK MMTuMon TO Reset;
Term1Mon:=GETMONITOR(Term1Condition,RStatObj);
ASK Term1Mon TO Reset;
Term2Mon:=GETMONITOR(Term2Cond,RStatObj);
ASK Term2Mon TO Reset;
Term3Mon:=GETMONITOR(Term3Cond,RStatObj);
ASK Term3Mon TO Reset;
GreenPercentMon:=GETMONITOR(GreenPercent,RStatObj);
ASK GreenPercentMon TO Reset;
YellowPercentMon:=GETMONITOR(YellowPercent,RStatObj);
ASK YellowPercentMon TO Reset;
RedPercentMon:=GETMONITOR(RedPercent,RStatObj);
ASK RedPercentMon TO Reset;
MissionGrnPerMon:=GETMONITOR(MissionGrnPer,RStatObj);
ASK MissionGrnPerMon TO Reset;
MissionYelPerMon:=GETMONITOR(MissionYelPer,RStatObj);
ASK MissionYelPerMon TO Reset;
MissionRedPerMon:=GETMONITOR(MissionRedPer,RStatObj);
ASK MissionRedPerMon TO Reset;
RMon:=GETMONITOR(Reliability,RStatObj);
ASK RMon TO Reset;
RCondMon:=GETMONITOR(RCond,RStatObj);
ASK RCondMon TO Reset;
header := nameOfFile;
Timescale:=TimeSlice;
IF EventsFile
ASK EventStream TO WriteString("Event_Log "+tab+"for "+tab+header+tab+" "+tab+Date);
ASK EventStream TO WriteLn;
ASK EventStream TO WriteLn;
END IF;
IF EORFile
ASK EndOfRunStream TO WriteString("End_Of_Run Report for "+header+" "+Date);
ASK EndOfRunStream TO WriteLn;
ASK EndOfRunStream TO WriteLn;
END IF;
IF CapFile
ASK CapacityStream TO WriteString("SimulationTime Flow Capacity");
ASK CapacityStream TO WriteLn;
END IF;
IF CostFile
ASK CostStream TO WriteString("Interim Cost Report for "+header+" "+Date);
ASK CostStream TO WriteLn;
ASK CostStream TO WriteLn;
END IF;
IF keyParamFile
ASK keyStream TO WriteString("Trial Ao Do R RCond"+
" MTBDE MDT MTBM MMT");
ASK keyStream TO WriteLn;
END IF;
IF AvailPlotFile
ASK AoPlotStream TO WriteString
("SimulationTime Ao Green Yellow Red Interval");
ASK AoPlotStream TO WriteLn;
END IF;
IF AvailGraph
totalIntervals:=TRUNC(simLength/AoPlotInterval);
NEW(MultiRunData, 1..totalIntervals);
END IF;
IF ResultsFile
ASK ResultsStream TO WriteString("Final_Results_Report for "+header+" "+Date);
ASK ResultsStream TO WriteLn;
ASK ResultsStream TO WriteLn;
ASK ResultsStream TO WriteLn;
END IF;
IF (RamInterval>0)
ASK RamStream TO WriteString("Trials Ao Ao_StDev Ao_SEM Do Do_StDev Do_SEM " +
"R R_StDev R_SEM R_SEP RCond RCond_StDev RCond_SEM " +
"MTBDE MTBDE_StDev MTBDE_SEM MDT MDT_StDev MDT_SEM MDT_Updates "+
"MTBM MTBM_StDev MTBM_SEM MMT MMT_StDev MMT_SEMS MMT_Updates");
ASK RamStream TO WriteLn;
END IF;
IF (relMesh>0.0)
NEW(reliabilityFileData,0..(TRUNC(simLength/relMesh)));
END IF;
IF (kpfTimeMesh>0.0) {cmc 3/6/07}
NEW(CumAoByTime,1..(TRUNC(simLength/kpfTimeMesh)));
NEW(CumMTBDEbyTime,1..(TRUNC(simLength/kpfTimeMesh)));
NEW(CumMDTbyTime,1..(TRUNC(simLength/kpfTimeMesh)));
NEW(CumMTBMbyTime,1..(TRUNC(simLength/kpfTimeMesh)));
NEW(CumMMTbyTime,1..(TRUNC(simLength/kpfTimeMesh)));
END IF;
IF ((DomainTree) OR (CoreFile))
CreateDomainTree;
END IF;
runNumber:=1;
IF EventsFile
ASK EventStream TO WriteLn;
WriteEvents(0.000000,"System","Begin_Run_"+INTTOSTR(runNumber),"--","--");
END IF;
ASK EventController TO SetTieBreaking(FALSE); {cmc}
TieBreaking:=TRUE;
PoolCostMonsSet:=FALSE;
BlockCostMonsSet:=FALSE;
capacityMonsSet:=FALSE;
weakAnalysisMonsSet:=FALSE;
IF NodeArray<>NILARRAY
DISPOSE(NodeArray);
END IF;
IF BlockArray<>NILARRAY
DISPOSE(BlockArray);
END IF;
IF FinalArray<>NILARRAY
DISPOSE(FinalArray);
END IF;
IF HierArray<>NILARRAY
DISPOSE(HierArray);
END IF;
IF SparesArray<>NILARRAY
DISPOSE(SparesArray);
END IF;
IF CapacityArray<>NILARRAY
DISPOSE(CapacityArray);
END IF;
IF BlockCostArray<>NILARRAY
DISPOSE(BlockCostArray);
END IF;
IF EventArray<>NILARRAY
DISPOSE(EventArray);
END IF;
WHILE runNumber <=NumRuns
IF GraphicsOutput AND faceBoxOpen
ASK window TO DisplayFace(1);
END IF;
IF statusBarOn
ASK window TO ShowStatus(1,"Run " + INTTOSTR(runNumber) + " of " + INTTOSTR(NumRuns));
IF termType=1
ASK window TO ShowStatus(2,"0% complete");
ELSIF termType=2
ASK window TO ShowStatus(2,"0 system failure(s)");
ELSE {termType=3}
ASK window TO ShowStatus(2,"0 cycles completed");
END IF;
END IF;
StatsStarted:=FALSE;
PhaseChangeInProgress:=FALSE;
ResetSimTime(0.0);
termCounter:=0;
cyclesCount:=0.0;
LastColorChange:=0.0;
LastMissionChange:=0.0;
LastUpDownChange:=0.0;
TimeOfCompFailure:=0.0;
StatsStartTime:=0.0;
autoStopped:=FALSE;
EndSimCalled:=FALSE;
ASK System TO Initialize;
NumCurrentlyFailed:=0;
ASK EventController TO SetTimeAdvance(TRUE);
phaseNumber:=1;
IF ((statusBarOn) AND (activePhases>0))
phase:=phaseObjArray[1];
ASK window TO ShowStatus(3,phase.phaseName);
IF phase.mission
ASK window TO ShowStatus(4,"MISSION");
IF EventsFile
WriteEvents(SimTime,"System","State_change","Mission","Began_a_mission");
END IF;
ELSE
ASK window TO ShowStatus(4,"Nonmission");
END IF;
END IF;
FOREACH link IN linkGroup
ASK link TO SetToInitValues;
END FOREACH;
SystemStateChange:=FALSE;
IF capacityAnalysis
NEW(NodeFlow,1..totalNodes);
NEW(NodeCapacity,1..totalNodes);
NEW(NodeFlowMon,1..totalNodes);
NEW(NodeCapMon,1..totalNodes);
lastFlow:=-1; {cmc capFix}
END IF;
FOREACH node IN nodeGroup
ASK node TO SetToInitValues();
IF node.coldStandby {csb speed change}
ASK ColdChangeGroup TO Add(node);
IF (NOT(node.priorityReturn) AND (runNumber > 1))
ASK node TO IdAndSortColds;
END IF;
END IF;
IF weakAnalysis
nodeMissionBool[node.seqNum]:=TRUE;
nodeMCompleted[node.seqNum]:=0;
END IF;
IF capacityAnalysis
NodeFlowMon[node.seqNum]:=GETMONITOR(NodeFlow[node.seqNum],ITimedStatObj);
ASK NodeFlowMon[node.seqNum] TO Reset;
NodeCapMon[node.seqNum]:=GETMONITOR(NodeCapacity[node.seqNum],ITimedStatObj);
ASK NodeCapMon[node.seqNum] TO Reset;
END IF;
END FOREACH;
ASK System TO SetToInitValues();
runCompleted:=FALSE;
FOREACH hier IN hierGroup
ASK hier TO SetToInitValues;
END FOREACH;
FOREACH block IN blockGroup
IF weakAnalysis
blockMissionBool[block.seqNum]:=TRUE;
blockMCompleted[block.seqNum]:=0;
END IF;
ASK block TO GetStartCond;
ASK block TO SetToInitValues();
IF (SparesTrackingGroup.numberIn>0)
SparesAvailable[block.seqNum]:=block.initStock;
END IF;
IF (SparesTrackingGroup.Includes(block))
ASK CustomSpares[block.seqNum] TO Create(block.initStock);
ASK CustomSpares[block.seqNum] TO SetPendStats(TRUE);
SparesAvailable[block.seqNum]:=CustomSpares[block.seqNum].Resources;
ASK CustSpareMon[block.seqNum] TO Reset;
IF (block.routineSpareOrdering)
TELL block TO GenerateSpares();
END IF;
currNumWaits[block.seqNum]:=0;
currNumArrivals[block.seqNum]:=0;
currInitNumber[block.seqNum]:=CustomSpares[block.seqNum].Resources;
END IF;
SparesUsed[block.seqNum]:=0;
END FOREACH;
FOREACH event IN eventGroup
IF weakAnalysis
eventMissionBool[event.seqNum]:=TRUE;
eventMCompleted[event.seqNum]:=0;
END IF;
ASK event TO SetToInitValues();
END FOREACH;
IF (totalPools>0)
FOR i:= 1 TO totalPools
ASK PooledSpares[i] TO Create(PoolArray[i].initialSpares);
ASK PooledSpares[i] TO SetPendStats(TRUE);
PoolResAvailable[i]:=PooledSpares[i].Resources;
ASK PoolMon[i] TO Reset;
IF (PoolArray[i].routineSpareOrdering)
TELL PooledSpares[i] TO GenerateSpares(i);
END IF;
ASK PooledSpares[i] TO Initialize;
IF costAnalysis
PoolAddCost[i]:=0.0;
PoolESCost[i]:=0.0;
END IF;
currNumWaits[i+totalBlocks]:=0;
currNumArrivals[i+totalBlocks]:=0;
currInitNumber[i+totalBlocks]:=PooledSpares[i].Resources;
END FOR;
END IF;
IF AvailPlotFile OR AvailGraph
IF AvailGraph
ASK AoGraph TO ClearDataSet(1);
ASK AoGraph TO ClearDataSet(2);
ASK AoGraph TO ClearDataSet(3);
ASK IntAoGraph TO ClearDataSet(1);
ASK MultiRunGraph TO ClearDataSet(1);
ASK MultiRunGraph TO ClearDataSet(2);
ASK MultiRunGraph TO ClearDataSet(3);
ASK AoGraph TO Plot(1, 0.0, 1.0);
ASK AoGraph TO Plot(2, 0.0, 1.0);
ASK AoGraph TO Plot(3, 0.0, 1.0);
END IF;
TELL System TO GenerateAoPlotData();
END IF;
IF (kpfTimeMesh>0.0) {cmc 3/6/07}
TELL System TO UpdateCumulativeValues(kpfTimeMesh);
END IF;
IF termType=1
IF statusBarOn
TELL System TO UpdateSimStatus(StopCriteria);
END IF;
TELL System TO CallEndSimulation(FALSE,TRUE) IN StopCriteria;
IF startStat>0.0000001
TELL System TO ResetAllStatistics IN startStat;
ELSE
StatsStarted:=TRUE;
END IF;
ELSE {termType=2 or 3}
IF TRUNC(startStat)=0;
StatsStarted:=TRUE;
END IF;
END IF;
IF costAnalysis AND CostFile
TELL System TO CalculateInterimCost;
END IF;
ASK window TO SetSysCursor(NormalCursor);
IF activePhases>0
TELL System TO ControlPhaseChanges();
END IF;
simInProgress:=TRUE; {this line needs to be before dep. backflow}
FOREACH node IN nodeGroup
IF node.typeNode=5
IF ((node.usesPhasing) AND (activePhases>0))
IF node.phase[1]=-1
ASK node TO ChangeNodeState(node.Status,Cut);
ELSIF node.phase[1]=0
ASK node TO ChangeNodeState(node.Status,Linked);
END IF;
END IF;
ELSE
IF node.GoodPathsRequired>node.EconnectIntoNum
ASK node TO ReconfigureNode(0,0,0,0,0,0);
END IF;
END IF;
IF node.Status=Down
ASK node TO BackFlowDependencies(Down);
END IF;
END FOREACH;
FOREACH block IN blockGroup
{IF ((block.opStatus=RepHold) OR (block.opStatus=Repairing) OR (block.opStatus=PM)
OR (block.opStatus=PMhold) OR (block.opStatus=Done) OR (block.activeStatus=Cut))
TELL block TO InitTimeZeroDeps IN 0.0; {cmc 12/13/06}
END IF; }
IF block.startCond="Running"
ASK block TO TurnOffStartCond;
TELL block TO Run IN 0.0;
ELSE
TELL block TO Repair IN 0.0;
END IF;
IF ((block.usesPM) AND (block.pmTriggered))
TELL block TO ControlPMtriggers IN 0.0;
END IF;
END FOREACH;
FOREACH block IN blockGroup
IF ((block.opStatus=RepHold) OR (block.opStatus=Repairing) OR (block.opStatus=PM) {cmc 12/13/06}
OR (block.opStatus=PMhold) OR (block.opStatus=Done) OR (block.activeStatus=Cut))
TELL block TO InitTimeZeroDeps IN 0.0;
END IF;
END FOREACH;
FOREACH event IN eventGroup {cmc 12/13/06}
IF ((event.opStatus=Failure) OR (event.activeStatus=Cut))
TELL event TO InitTimeZeroDeps IN 0.0;
END IF;
END FOREACH;
FOREACH node IN nodeGroup {cmc 12/13/06}
IF node.Status=Down
TELL node TO InitTimeZeroDeps IN 0.0;
END IF;
END FOREACH;
CheckColds;
{*****}
FOREACH trig IN triggerGroup
TELL trig TO PullRapTrigger IN 0.0;
END FOREACH;
IF inJumpMode
jumpStop:=TRUE;
{REPEAT
jumpStopped:=TRUE;
FillStatusBar;
goToNext := FALSE;
clickedOn := ASK window TO AcceptInput();
UNTIL goToNext; }
END IF;
StartSimulation;
{*************************************************************************************************************************}
simInProgress:=FALSE;
runCompleted:=TRUE;
earlyAbort:=FALSE;
IF Aborted
IF (runNumber>1)
NumRunsCompleted:=runNumber-1;
KeepRunStats:=FALSE;
ELSE
NumRunsCompleted:=1;
earlyAbort:=TRUE;
IF KeepSimStats
KeepRunStats:=TRUE;
ELSE
KeepRunStats:=FALSE;
END IF;
END IF;
ELSE
NumRunsCompleted:=runNumber;
IF (SimTime=0.0)
AnalyzeSystem;
IF (inStepMode)
FillStatusBar;
REPEAT
goToNext := FALSE;
button:=ASK simToolBar TO AcceptInput();
UNTIL goToNext;
END IF;
END IF;
END IF;
ASK System TO ChangeStatus(DDone, NonMission);
IF EventsFile
IF Aborted
WriteEvents(SimTime,"System","Simulation_Aborted","--","--");
ELSE
WriteEvents(SimTime,"System","Simulation_Terminated","--","--");
END IF;
END IF;
IF KeepRunStats
MTBDEupdated:=TRUE;
MDTupdated:=TRUE;
MTBMupdated:=TRUE;
MTBMuupdated:=TRUE;
MTBMsupdated:=TRUE; {used for End of Run report}
MMTsupdated:=TRUE;
MMTupdated:=TRUE;
MMTuupdated:=TRUE;
{IF (RedMon.Count>0) }
IF ((GreenMon.Sum+YellowMon.Sum+RedMon.Sum) >0.)
Availability:=(GreenMon.Sum+YellowMon.Sum)/(GreenMon.Sum+YellowMon.Sum+RedMon.Sum);
ELSE
Availability:=1.0;
END IF;
IF ((MissionGrnMon.Sum+MissionYelMon.Sum+MissionRedMon.Sum) >0.)
Dependability:=(MissionGrnMon.Sum+MissionYelMon.Sum)/(MissionGrnMon.Sum+MissionYelMon.Sum+MissionRedMon.Sum);
END IF;
IF missionsAttempted>0
Reliability:=FLOAT(missionsCompleted)/FLOAT(missionsAttempted);
END IF;
IF missionsBegan>0
RCond:=FLOAT(missionsCompleted)/FLOAT(missionsBegan);
END IF;
IF ((SysFailMon.Count>0) AND (SimTime>0.0))
MTBDE:=(GreenMon.Sum+YellowMon.Sum)/FLOAT(SysFailMon.Count);
ELSE
IF (GreenMon.Sum+YellowMon.Sum)>0.0
MTBDE:=(GreenMon.Sum+YellowMon.Sum);
MTBDEsusp:=TRUE;
ELSE
MTBDEupdated:=FALSE;
END IF;
END IF;
IF autoStopped {could not reach required number of failures}
IF ((RedMon.Count>1) AND (SimTime>0.0))
MDT:=RedMon.Mean * FLOAT(RedMon.Count)/(FLOAT(RedMon.Count)-1.0);
ELSE
MDTupdated:=FALSE;
END IF;
ELSE
IF ((RedMon.Count>0) AND (SimTime>0.0))
MDT:=RedMon.Mean;
ELSE
MDTupdated:=FALSE;
END IF;
END IF;
IF (GreenMon.Sum+YellowMon.Sum > 0.0)
IF ((CompFailMon.Count>0) AND (CompPMMon.Count>0))
MTBMu:=(GreenMon.Sum+YellowMon.Sum)/FLOAT(CompFailMon.Count);
MTBM :=(GreenMon.Sum+YellowMon.Sum)/(FLOAT(CompFailMon.Count)+FLOAT(CompPMMon.Count));
MTBMs:=(GreenMon.Sum+YellowMon.Sum)/FLOAT(CompPMMon.Count);
didPM:=TRUE; {Beta118}
ELSIF (CompPMMon.Count>0)
MTBM:= (GreenMon.Sum+YellowMon.Sum)/(FLOAT(CompPMMon.Count));
MTBMs:=(GreenMon.Sum+YellowMon.Sum)/FLOAT(CompPMMon.Count);
MTBMu :=(GreenMon.Sum+YellowMon.Sum);
MTBMususp:=TRUE;
didPM:=TRUE; {Beta118}
ELSIF (CompFailMon.Count>0)
MTBMu:= (GreenMon.Sum+YellowMon.Sum)/(FLOAT(CompFailMon.Count));
MTBM :=(GreenMon.Sum+YellowMon.Sum)/FLOAT(CompFailMon.Count);
MTBMs :=(GreenMon.Sum+YellowMon.Sum);
MTBMsupdated:=FALSE;
MTBMssusp:=TRUE;
ELSE
MTBM :=(GreenMon.Sum+YellowMon.Sum);
MTBMu:=(GreenMon.Sum+YellowMon.Sum);
MTBMsusp:=TRUE;
MTBMususp:=TRUE;
MTBMs :=(GreenMon.Sum+YellowMon.Sum);
MTBMsupdated:=FALSE;
MTBMssusp:=TRUE;
END IF;
ELSE
MTBMupdated:=FALSE;
MTBMuupdated:=FALSE;
MTBMsupdated:=FALSE;
END IF;
IF autoStopped
IF ((CompRepairMon.Count>1) AND (CompPMMon.Count>1))
MMTs:=CompPMMon.Mean * FLOAT(CompPMMon.Count)/(FLOAT(CompPMMon.Count)-1.0);
MMTu:=CompRepairMon.Mean * FLOAT(CompRepairMon.Count)/(FLOAT(CompRepairMon.Count)-1.0);
MMT:= ( MMTu* FLOAT(CompRepairMon.Count-1) + MMTs* FLOAT(CompPMMon.Count-1) )/
FLOAT( (CompRepairMon.Count-1)+(CompPMMon.Count-1) );
ELSIF (CompRepairMon.Count>1)
MMTu:=CompRepairMon.Mean * FLOAT(CompRepairMon.Count)/(FLOAT(CompRepairMon.Count)-1.0);
MMT:= MMTu;
MMTsupdated:=FALSE;
ELSIF (CompPMMon.Count>1)
MMTs:=CompPMMon.Mean * FLOAT(CompPMMon.Count)/(FLOAT(CompPMMon.Count)-1.0);
MMT:= MMTs;
MMTuupdated:=FALSE;
ELSE
MMTupdated:=FALSE;
MMTsupdated:=FALSE;
MMTuupdated:=FALSE;
END IF;
ELSE
IF ((CompRepairMon.Count>0) AND (CompPMMon.Count>0))
MMTs:=CompPMMon.Mean;
MMTu:=CompRepairMon.Mean;
MMT:= (MMTu*FLOAT(CompRepairMon.Count)+MMTs*FLOAT(CompPMMon.Count))/
FLOAT(CompRepairMon.Count+CompPMMon.Count);
ELSIF (CompRepairMon.Count>0)
MMTu:=CompRepairMon.Mean;
MMT:= CompRepairMon.Mean;
MMTsupdated:=FALSE;
ELSIF (CompPMMon.Count>0)
MMTs:=CompPMMon.Mean;
MMT:= CompPMMon.Mean;