-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIObjects.mod
executable file
·9149 lines (8732 loc) · 361 KB
/
IObjects.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 : IObjects +}
{+ Author : Chuck Carter / Steve Brown / Tony Malerich +}
{+ Last Modified : November 2004 +}
{+ +}
{+ Description: This module contains the procedures for blocks, nodes, links, +}
{+ and pools. +}
{+ +}
{+ +}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
IMPLEMENTATION MODULE Objects;
FROM MathMod IMPORT SIN, COS, ATAN2, SQRT, POWER, pi, LN, EXP;
FROM GTypes IMPORT PointArrayType, ALL ColorType, TextBufferType,
FillStyleType(SolidFill, NarrowCrosshatchFill),OptionListType;
FROM Text IMPORT TextObj;
FROM Intract IMPORT SendAlert,GetNumParams,GammaFunction,ComputeStats, fEmpArray, rEmpArray;
FROM Fill IMPORT FillVObj;
FROM GProcs IMPORT Transform;
FROM Display IMPORT window,root,totalLinks,totalNodes,startId,endId,activePhases,fontSize,typeOfCursor,PoolArray,
somethingChanged, totalBlocks,flowGenerated,defaultBlock,statusBarOn,weakLinkAnalType,GYthreshold,
capacityAnalysis,weakAnalysis,costAnalysis,YRthreshold,blockGUIColor,linkWorkColor,totalTriggers,
selectGroup,selectedLinksGroup,termType,writeBlkEvs,writeNdEvs,writeSysEvs,writePhsEvs,
writeOnlyItemEvs,nodesIn,blocksIn,hiersIn,nextLinkId,nextId,blockGroup,eventGroup,nodeGroup,hierGroup,
linkGroup,totalEvents,copied,copiedFromPrevFile,detComp, C130File;
FROM Runsim IMPORT BlockDepGroup,FevDepGroup,NodeDepGroup,BlockRepCost,BlockOpCost,BlockSpCost,BlockIdleCost,
BlockHoldCost,BlockSBCost,BlockDoneCost,BlockESCost,BlockDispCost,NodeGreenTime,NodeYellowTime,
NodeRedTime,NodeBrownTime,NodeBlueTime,NodeOrangeTime,BlockTrigger,System,RepTimeStream, EventStream,
SysStream,FailStream,RepairStream,SystemUp,redString,EventFailStream,SysRepTimeFile,EventsFile,
CapFile,StatsStarted,SysTimeToRepair,LastUpDownChange,OutOfSpares,currNumWaits,currNumArrivals,
StartStats,StopCriteria,runCompleted,phaseNumber, PooledSpares, CustomSpares, CompTimeToFail,
SparesUsed,CompTimeToRepair, CompTimeToDoPM,SparesAvailable, PoolResAvailable,TimeOfCompFailure,
ALL SystemStatusType,PoolAddCost,PoolESCost,ColdChangeGroup,simInProgress,NodeFlow,NodeCapacity,
CapacityStream,hierDE,CountFailure,autoStopped,pmSyncTrigger,REALTOSigFigSTR, PhaseChangeInProgress,
NodeFailureGroup, FEVmode,NumCurrentlyFailed,pmDeferGroup,BlockPMCost,BlockpmHoldCost,BlockRunTime,
BlockStandbyTime,BlockRepairTime,BlockRepHoldTime,BlockIdleTime,BlockPMTime,BlockPMHoldTime,
BlockDoneTime,blockMissionBool,nodeMissionBool,termCounter,EventRunTime,EventStandbyTime,
EventRepairTime,EventOpCost,EventRepCost,eventMissionBool,nodeHasDepsGroup,blockHasDepsGroup,
eventHasDepsGroup, C130Stream, lastFlow {cmc capFix} ;
FROM SimMod IMPORT Interrupt, SimTime;
FROM Button IMPORT ButtonObj;
FROM Value IMPORT ValueBoxObj;
FROM Label IMPORT LabelObj;
FROM TextBox IMPORT ComboBoxObj;
FROM OSMod IMPORT Delay;
FROM Analyze IMPORT LoopCheck,LoopError,PropagatedGroup,DownstreamGroup,analysisType,TestElement,RandomGenObj,
totalCapNodes;
VAR
message : TextBufferType;
result,coldsAffected,checkingSystemCap,skipBackflow, specialBackFlow : BOOLEAN;
startUpFailures :BOOLEAN; {cmc StartUpFailures}
PROCEDURE InitFactorySettings;
BEGIN
NEW(factBools, 1..18);
NEW(factReals, 1..28);
NEW(factInts, 1..17);
NEW(factStrs, 1..6);
NEW(factFparams,1..2);
NEW(factRparams,1..2);
NEW(factPreParams,1..1);
NEW(factPostParams,1..1);
NEW(factPMParams,1..1);
{see Procedure SetBlockData for a description of each item}
factBools[1] := TRUE; factBools[2] := FALSE; factBools[3] := FALSE; factBools[4] := FALSE;
factBools[5] := FALSE; factBools[6] := FALSE; factBools[7] := FALSE; factBools[8] := FALSE;
factBools[9] := FALSE; factBools[10] := FALSE; factBools[11]:= FALSE; factBools[12]:= TRUE;
factBools[13]:= TRUE; factBools[14] := FALSE; factBools[15]:= TRUE; factBools[16]:= FALSE;
factBools[17]:= TRUE; factBools[18] := FALSE;
factReals[1] := 720.; factReals[2] := 24.; factReals[3] := 24.;
factReals[4] := 0.; factReals[5] := 1.; factReals[6] := 1.;
factReals[7] := 1.; factReals[8] := 1.; factReals[9] := 1.;
factReals[10] := 1.; factReals[11] := 1.; factReals[12] := 1.;
factReals[13] := 1.; factReals[14] := 1.; factReals[15] := 1.;
factReals[16] := 1.; factReals[17] := 1.; factReals[18] := 1.;
factReals[19] := 0.; factReals[20] := 0.; factReals[21] := 100.;
factReals[22] := 1.; factReals[23] := 1.; factReals[24] := 0.;
factReals[25] := 100.; factReals[26] := 0.; factReals[27] :=0.;
factReals[28] := 75.;
factInts[1] := 4; factInts[2] := 19; factInts[3] := 7;
factInts[4] := 19; factInts[5] := 100; factInts[6] := 1;
factInts[7] := 0; factInts[8] := 1; factInts[9] := 0;
factInts[10] := 0; factInts[11] := 203; factInts[12] := 203;
factInts[13] := 3; factInts[14] := 1; factInts[15] := 0;
factInts[16] := 19; factInts[17] := 1;
factStrs[1] := "unnamed"; factStrs[2] := "unnamed"; factStrs[3] := "unnamed";
factStrs[4] := "none"; factStrs[5] :="";
factFparams[1] := 100.; factFparams[2] := 0.;
factRparams[1] := 10.; factRparams[2] := 2.;
factSparing := Infinite;
factPreParams[1]:=0.;
factPostParams[1]:=0.;
factPMParams[1]:=1.;
ASK defaultBlock TO SetBlockData(factBools, factInts, factReals,factStrs, factFparams,
factRparams, factPreParams,factPostParams,factPMParams,factSparing);
END PROCEDURE; {InitFactorySettings}
PROCEDURE arrowhead (IN connectInType : STRING;
IN startX, startY, endX, endY : REAL;
OUT p1X, p1Y, p2X, p2Y, p3X, p3Y : REAL);
CONST
oldphi = 15.; {arrowhead angle}
radius = 0.2;
VAR
delta, phi,lineX,lineY,unitX,unitY,theta,
leftRelX,leftRelY,rightRelX,rightRelY, z : REAL;
BEGIN
IF (startX = endX) AND (startY = endY)
p1X := startX;
p1Y := startY;
p2X := startX;
p2Y := startY;
p3X := startX;
p3Y := startY;
ELSE
lineX := endX - startX;
lineY := endY - startY;
unitX := lineX / SQRT(POWER(lineX,2.) + POWER(lineY,2.));
unitY := lineY / SQRT(POWER(lineX,2.) + POWER(lineY,2.));
phi := oldphi * pi / 180.;
theta := ATAN2(lineY, lineX);
IF connectInType = "RBDBlock"
IF (theta >= -0.3925) AND (theta < 0.3925)
delta := 0.25; {distance the tip of the arrowhead is away from the end of the line}
ELSIF (theta >= 0.3925) AND (theta < 1.178)
delta := 0.4;
ELSIF (theta >= 1.178) AND (theta < 1.963)
delta := 0.25;
ELSIF (theta >= 1.963) AND (theta < 2.748)
delta := 0.4;
ELSIF (theta >= -1.178) AND (theta < -0.3925)
delta := 0.4;
ELSIF (theta >= -1.963) AND (theta < -1.178)
delta := 0.22;
ELSIF (theta >= -2.748) AND (theta < -1.963)
delta := 0.4;
ELSE
delta := 0.3;
END IF;
ELSIF connectInType = "RBDHier"
z:=ABS(theta);
IF z>1.5708
z:=3.1415-z;
END IF;
IF (z >= -0.1) AND (z < 0.2618)
delta := 0.65; {0-15 degrees}
ELSIF (z >= 0.2618) AND (z < 0.5236)
delta := 0.55; {15-30 degrees}
ELSIF (z >= 0.5236) AND (z < 0.6)
delta := 0.5; {30-45 degrees}
ELSIF (z >= 0.6) AND (z < 0.7854)
delta := 0.4; {30-45 degrees}
ELSIF (z >= 0.7854) AND (z < 1.0472)
delta := 0.35; {45-60 degrees}
ELSIF (z >= 1.0472) AND (z < 1.3090)
delta := 0.30; {60-75 degrees}
ELSIF (z >= 1.3090) AND (z < 1.58)
delta := 0.25; {75-90 degrees}
ELSE
delta := 2.65; {shouldn't happen}
END IF;
ELSE
IF (theta >= -0.3925) AND (theta < 0.3925)
delta := 0.25;
ELSIF (theta >= 0.3925) AND (theta < 1.178)
delta := 0.24;
ELSIF (theta >= 1.178) AND (theta < 1.963)
delta := 0.24;
ELSIF (theta >= 1.963) AND (theta < 2.748)
delta := 0.23;
ELSIF (theta >= -1.178) AND (theta < -0.3925)
delta := 0.28;
ELSIF (theta >= -1.963) AND (theta < -1.178)
delta := 0.26;
ELSIF (theta >= -2.748) AND (theta < -1.963)
delta := 0.28;
ELSE
delta := 0.22;
END IF;
END IF;
leftRelX := -radius * COS(theta) * COS(phi) - radius * SIN(theta) * SIN(phi);
leftRelY := -radius * SIN(theta) * COS(phi) + radius * COS(theta) * SIN(phi);
rightRelX := -radius * COS(theta) * COS(phi) + radius * SIN(theta) * SIN(phi);
rightRelY := -radius * SIN(theta) * COS(phi) - radius * COS(theta) * SIN(phi);
p1X := endX - delta * unitX;
p1Y := endY - delta * unitY;
p2X := p1X + leftRelX;
p2Y := p1Y + leftRelY;
p3X := p1X + rightRelX;
p3Y := p1Y + rightRelY;
END IF;
END PROCEDURE; {arrowhead}
PROCEDURE CheckColds;
VAR
node : RBDNodeObj;
i,path : INTEGER;
link : LinkObj;
someColdsChanged,completed : BOOLEAN;
BEGIN
completed:=FALSE;
skipBackflow:=FALSE;
WHILE NOT completed
someColdsChanged:=FALSE;
WHILE coldsAffected
someColdsChanged:=TRUE;
coldsAffected:=FALSE;
FOREACH node IN ColdChangeGroup
ASK node TO RunColdLogic;
ASK ColdChangeGroup TO RemoveThis(node); {CSB Speed Change}
END FOREACH;
END WHILE;
completed:=TRUE;
IF someColdsChanged
skipBackflow:=TRUE; {Insure blocks connected to standby node stay idle after ResendBackFlow}
ResendBackFlow;
END IF;
IF coldsAffected
completed:=FALSE;
END IF;
END WHILE;
skipBackflow:=FALSE;
END PROCEDURE; {CheckColds}
PROCEDURE AnalyzeSystem;
VAR
i,j,currentCap,LostFlow : INTEGER;
node,startNode,endNode : RBDNodeObj;
block : RBDBlockObj;
link,tempLink : LinkObj;
currentSysStatus,newSysStatus : SystemStatusType;
oldTimescale : REAL;
outString,statusString,commentString : STRING;
flowLabel : TextObj;
pathFound : BOOLEAN;
hier : RBDHierObj;
BEGIN
currentSysStatus:=System.Status;
IF ((NumCurrentlyFailed=0) AND (SystemUp))
newSysStatus:=GGreen;
ELSIF ((NumCurrentlyFailed>0) AND (SystemUp))
newSysStatus:=YYellow;
ELSE
newSysStatus:=RRed;
END IF;
IF totalHiers>0
FOREACH hier IN hierGroup
node:=ASK root Child("RBDNode", hier.outID);
IF ((hier.numCurrentlyFailed>0) AND (node.Status=AllUp))
ASK node TO ChangeNodeState(Degraded,node.activeStatus);
ELSIF ((hier.numCurrentlyFailed=0) AND (node.Status=Degraded))
ASK node TO ChangeNodeState(AllUp,node.activeStatus);
END IF;
END FOREACH;
END IF;
IF currentSysStatus<>newSysStatus
ASK System TO ChangeStatus(newSysStatus,System.missionStatus);
ELSIF ((currentSysStatus=RRed) AND (newSysStatus=RRed))
CapAnalysisRequired:=FALSE;
IF (SimTime>LastUpDownChange)
IF ((EventsFile) AND (System.Status<>DDone) AND (NOT runCompleted))
commentString:="";
FOREACH block IN blockGroup
IF block.activeStatus=Cut
commentString:=commentString+"_c"+INTTOSTR(block.Id);
ELSE
IF block.opStatus=Repairing
commentString:=commentString+"_r"+INTTOSTR(block.Id);
ELSIF ((block.opStatus=RepHold) OR (block.opStatus=PMhold))
commentString:=commentString+"_h"+INTTOSTR(block.Id);
ELSIF block.opStatus=Done
commentString:=commentString+"_d"+INTTOSTR(block.Id);
ELSIF block.opStatus=PM
commentString:=commentString+"_p"+INTTOSTR(block.Id);
END IF;
END IF;
END FOREACH;
IF commentString<>redString
redString:=commentString;
IF commentString = ""
WriteEvents(SimTime,"System","Red_change","Red","System_status_change");
ELSE
WriteEvents(SimTime,"System","Red_change","Red",commentString);
END IF;
END IF;
END IF; {EventsFile}
END IF; {simTime>LastUpDownChange}
END IF;
IF ((SimTime=0.0) OR FEVmode)
CapAnalysisRequired:=TRUE;
END IF;
IF (capacityAnalysis AND (NOT runCompleted) AND (CapAnalysisRequired))
startNode:=ASK root Child("RBDNode",startId);
endNode := ASK root Child("RBDNode",endId);
FOREACH link IN capLinkGroup
ASK link TO SetActualFlow(0);
ASK link TO SetPathFull(FALSE);
END FOREACH;
FOREACH node IN capNodeGroup
ASK node TO ResetNodeFlow;
IF (GraphicsOutput AND (node.typeNode=2))
ASK node TO ShowFlow;
END IF;
END FOREACH;
IF FEVmode
ASK startNode TO DistributeFlow(flowGenerated, LostFlow);
ELSE
IF (newSysStatus<>RRed)
IF (NOT FlowingAtMaxCap)
checkingSystemCap:=TRUE;
ASK startNode TO DistributeFlow(999999999, LostFlow);
checkingSystemCap:=FALSE;
NodeCapacity[startNode.seqNum]:=999999999-LostFlow;
FOREACH link IN capLinkGroup
ASK link TO SetActualFlow(0);
ASK link TO SetPathFull(FALSE);
END FOREACH;
FOREACH node IN capNodeGroup
ASK node TO ResetNodeFlow;
END FOREACH;
END IF;
ASK startNode TO DistributeFlow(flowGenerated, LostFlow);
IF FlowingAtMaxCap
NodeCapacity[startNode.seqNum]:=flowGenerated-LostFlow;
END IF;
ELSE
NodeCapacity[startNode.seqNum]:=0;
LostFlow:=flowGenerated;
END IF;
END IF;
IF GraphicsOutput
flowLabel:=ASK startNode Child("RBDNodeKofN", 0);
ASK flowLabel TO SetText("Flow="+INTTOSTR(flowGenerated-LostFlow));
ASK flowLabel TO Draw;
END IF;
IF NOT FEVmode
FOREACH node IN capNodeGroup
IF (node.Id<>endId)
NodeFlow[node.seqNum]:=node.nodeFlow;
END IF;
currentCap:=0;
IF ((node.Status=AllUp) OR (node.Status=Degraded))
IF node.fullFlow
currentCap:=999999999;
ELSE
FOR j:=1 TO node.EconnectIntoNum
link := ASK root Child("RBDLink",node.inPathsArray[j]);
IF link.Status=LinkUp
currentCap:=currentCap+link.simMaxFlow;
END IF;
END FOR;
END IF;
ELSE
currentCap:=0;
END IF;
IF node.Id<>startId
NodeCapacity[node.seqNum]:=currentCap;
END IF;
END FOREACH;
NodeFlow[endNode.seqNum]:=NodeFlow[startNode.seqNum]; {set NodeFlow for end node equal to start node's}
END IF;
{ IF GraphicsOutput
FOREACH link IN linkGroup {capLinkGroup}
ASK link TO ShowFlowStatus;
END FOREACH;
END IF; }
IF CapFile
startNode:=ASK root Child("RBDNode",startId);
outString:=SUBSTR(1,20,REALTOSTR(SimTime)+" ")+" ";
outString:=outString+SUBSTR(1,9,INTTOSTR(NodeFlow[startNode.seqNum])+" ")+" ";
outString:=outString+SUBSTR(1,9,INTTOSTR(NodeCapacity[startNode.seqNum])+" ")+" ";
IF (NodeFlow[startNode.seqNum]<>lastFlow) {cmc capFix}
ASK CapacityStream TO WriteString(outString);
ASK CapacityStream TO WriteLn;
lastFlow:= NodeFlow[startNode.seqNum]; {cmc capFix}
END IF;
END IF;
END IF;
CapAnalysisRequired:=FALSE;
END PROCEDURE; {AnalyzeSystem - new version}
PROCEDURE DetermineMaxCapacity(OUT maxCap : INTEGER);
VAR
node : RBDNodeObj;
link : LinkObj;
LostFlow : INTEGER;
BEGIN
FOREACH link IN capLinkGroup
ASK link TO SetActualFlow(0);
ASK link TO SetPathFull(FALSE);
END FOREACH;
FOREACH node IN capNodeGroup
ASK node TO ResetNodeFlow;
END FOREACH;
node:=ASK root Child("RBDNode", startId);
checkingSystemCap:=TRUE;
ASK node TO DistributeFlow(999999999, LostFlow);
checkingSystemCap:=FALSE;
maxCap:=999999999-LostFlow;
FOREACH link IN capLinkGroup
ASK link TO SetActualFlow(0);
ASK link TO SetPathFull(FALSE);
END FOREACH;
FOREACH node IN capNodeGroup
ASK node TO ResetNodeFlow;
END FOREACH;
END PROCEDURE;
PROCEDURE WriteEvents (IN time : REAL;
IN typeString,nameString,
actionString,commentString : STRING);
VAR
timeString,outString,tab : STRING;
print : BOOLEAN;
BEGIN
print:=FALSE;
IF (detComp<>"")
IF (nameString=detComp)
print:=TRUE;
END IF;
END IF;
CASE typeString
WHEN "Block":
IF (writeBlkEvs)
print:=TRUE;
END IF;
WHEN "Node":
IF (writeNdEvs)
print:=TRUE;
END IF;
WHEN "System":
IF ((nameString="Phase_change") AND (writePhsEvs))
print:=TRUE;
ELSIF (writeSysEvs)
print:=TRUE;
END IF;
WHEN "Pool":
IF (writeSysEvs)
print:=TRUE;
END IF;
WHEN "Trigger":
IF (writeSysEvs)
print:=TRUE;
END IF;
WHEN "Hier":
IF (writeSysEvs)
print:=TRUE;
END IF;
OTHERWISE
{do nothing}
END CASE;
IF ((NOT writeBlkEvs) AND (NOT writeNdEvs) AND (NOT writeSysEvs) AND (NOT detComp<>"") AND (NOT writePhsEvs))
print:=TRUE; {tony - very awkward - can improve?}
END IF;
IF print
tab:=9C;
timeString:=REALTOSTR(time)+" ";
timeString:=SUBSTR(1,16,timeString+" ")+" "+tab;
typeString:=SUBSTR(1,7,typeString+" ")+" "+tab;
nameString:= SUBSTR(1,20,nameString+" ")+" "+tab;
actionString:=SUBSTR(1,15,actionString + " ")+" "+tab;
outString:=timeString+typeString+nameString+actionString+commentString;
ASK EventStream TO WriteString(outString);
ASK EventStream TO WriteLn;
END IF;
END PROCEDURE;
PROCEDURE GetStream (IN usesStream : INTEGER;
IN typeString : STRING;
IN idStream : INTEGER;
OUT drawStream : RandomGenObj);
VAR
arrayIndex : INTEGER;
BEGIN
IF usesStream > 200
arrayIndex:=usesStream-200;
drawStream:=SysStream[arrayIndex];
ELSIF (typeString="Event")
drawStream:=EventFailStream[idStream];
ELSIF (typeString="Fail")
drawStream:=FailStream[idStream];
ELSIF (typeString="Repair")
drawStream:=RepairStream[idStream];
END IF;
END PROCEDURE;
PROCEDURE RunBogusRBD;
VAR
bogus : BogusRBD;
BEGIN
NEW(bogus);
TELL bogus TO Run IN 0.0;
StartSimulation;
DISPOSE(bogus);
END PROCEDURE;
PROCEDURE ResendBackFlow;
VAR
tempBlock : RBDBlockObj;
tempNode : RBDNodeObj;
tempEvent : RBDEventObj;
BEGIN
specialBackFlow:=TRUE;
FOREACH tempBlock IN blockHasDepsGroup
IF tempBlock.activeStatus=Cut
ASK tempBlock TO BackFlowDependencies(Down);
ELSIF tempBlock.activeStatus=Active
IF ((tempBlock.opStatus=Repairing) OR (tempBlock.opStatus=PM)
OR (tempBlock.opStatus=RepHold) OR (tempBlock.opStatus=PMhold))
ASK tempBlock TO BackFlowDependencies(Down);
END IF;
END IF;
END FOREACH;
FOREACH tempEvent IN eventHasDepsGroup
IF tempEvent.activeStatus=Cut
ASK tempEvent TO BackFlowDependencies(Down);
ELSIF tempEvent.activeStatus=Active
IF (tempEvent.opStatus=Failure)
ASK tempEvent TO BackFlowDependencies(Down);
END IF;
END IF;
END FOREACH;
FOREACH tempNode IN nodeHasDepsGroup
IF (tempNode.Status=Down)
ASK tempNode TO BackFlowDependencies(Down);
END IF;
END FOREACH;
specialBackFlow:=FALSE;
END PROCEDURE; {ResendBackFlow}
OBJECT BogusRBD;
TELL METHOD Run;
BEGIN
WAIT DURATION 1.0;
END WAIT;
StopSimulation;
END METHOD;
END OBJECT;
OBJECT RBDHierObj;
ASK METHOD SetName (IN newName : STRING);
VAR
label : TextObj;
BEGIN
name := newName;
ToolTip:=name;
label := Child("HierLabel", 0);
ASK label TO SetText(newName);
ASK label TO SetColor(Black);
IF fontSize = 1
ASK label TO SetSysFont("SmallFonts",fontSize,70,0); {add this line}
ASK label TO SetHidden(TRUE);
ELSE
ASK label TO SetSysFont("SmallFonts",fontSize,70,0);
END IF;
ASK label TO Draw;
END METHOD;
ASK METHOD SetConnectToNode(IN isConnected : BOOLEAN);
BEGIN
isConnectedNode := isConnected;
END METHOD; {SetConnectToNode}
ASK METHOD SetZoom (IN newZoom : REAL);
BEGIN
zoom := newZoom;
END METHOD; {SetZoom}
ASK METHOD SetLevel (IN newLevel : INTEGER);
BEGIN
level := newLevel;
END METHOD; {SetZoom}
ASK METHOD SetInID(IN newValue : INTEGER);
BEGIN
inID:=newValue;
END METHOD;
ASK METHOD SetOutID(IN newValue : INTEGER);
BEGIN
outID:=newValue;
END METHOD;
ASK METHOD CreateChildGroup;
BEGIN
NEW(childGroup);
END METHOD;
ASK METHOD AugmentSelectGroup;
VAR
child : ANYOBJ;
tempHier : RBDHierObj;
i : INTEGER;
BEGIN
FOREACH child IN childGroup
IF OBJTYPENAME(child) = "LinkObj";
IF selectedLinksGroup.Includes(child);
ELSE
ASK selectedLinksGroup TO Add(child);
INC(linksIn);
END IF;
ELSIF OBJTYPENAME(child) = "RBDBlockObj"
IF selectGroup.Includes(child);
ELSE
ASK selectGroup TO Add(child);
INC(blocksIn);
END IF;
ELSIF OBJTYPENAME(child) = "RBDEventObj"
IF selectGroup.Includes(child);
ELSE
ASK selectGroup TO Add(child);
INC(eventsIn);
END IF;
ELSIF OBJTYPENAME(child) = "RBDNodeObj"
IF selectGroup.Includes(child);
ELSE
ASK selectGroup TO Add(child);
INC(nodesIn);
END IF;
ELSIF OBJTYPENAME(child) = "RBDHierObj"
IF selectGroup.Includes(child);
ELSE
ASK selectGroup TO Add(child);
INC(hiersIn);
END IF;
END IF;
END FOREACH;
FOREACH tempHier IN hierGroup
IF tempHier.parentID = Id
ASK tempHier TO AugmentSelectGroup;
END IF;
END FOREACH;
END METHOD;
ASK METHOD ChangeStatus(IN newcolor : NodeStatusType);
VAR
hierImage,dsi : ImageObj;
tempHier : RBDHierObj;
oldDSIsignal,oldStatus : NodeStatusType;
gre,yel,sie,blu,red,ora : INTEGER;
BEGIN
oldStatus:=Status;
Status:=newcolor;
IF (GraphicsOutput AND (oldStatus<>newcolor))
hierImage := Descendant("Hier", 603);
CASE newcolor
WHEN AllUp:
ASK hierImage TO SetColor(LimeGreen);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
WHEN Degraded:
ASK hierImage TO SetColor(Yellow);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
WHEN NodeIdle:
ASK hierImage TO SetColor(Sienna);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
WHEN NodeStandby:
ASK hierImage TO SetColor(Blue);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
WHEN Down:
ASK hierImage TO SetColor(Red);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
WHEN NodePM:
ASK hierImage TO SetColor(Orange);
ASK hierImage TO SetTranslation(hierImage.Translation.x, hierImage.Translation.y);
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown hierarchy status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
Draw;
IF NOT runCompleted
IF (parentID > 0)
oldDSIsignal:=DSIsignal;
IF (Status > dsiState) {newColor worse than }
DSIsignal:=Status;
ELSE
DSIsignal:=dsiState;
END IF;
tempHier := ASK root Child("RBDHier", parentID);
IF ( ((oldStatus=AllUp) OR (oldStatus=Degraded) OR (oldStatus=NodeStandby)) AND
((Status=Down) OR (Status=NodeIdle) OR (Status=NodePM)) )
ASK tempHier TO IncNumFailed;
ELSIF ( ((Status=AllUp) OR (Status=Degraded) OR (Status=NodeStandby)) AND
((oldStatus=Down) OR (oldStatus=NodeIdle) OR (oldStatus=NodePM)) )
ASK tempHier TO DecNumFailed;
END IF;
IF DSIsignal<>oldDSIsignal;
CASE oldDSIsignal
WHEN AllUp:
gre:=-1;
WHEN Degraded:
yel:=-1;
WHEN NodeIdle:
sie:=-1;
WHEN NodeStandby:
blu:=-1;
WHEN Down:
red:=-1;
WHEN NodePM:
ora:=-1;
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown hierarchy status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
CASE DSIsignal
WHEN AllUp:
gre:=1;
WHEN Degraded:
yel:=1;
WHEN NodeIdle:
sie:=1;
WHEN NodeStandby:
blu:=1;
WHEN Down:
red:=1;
WHEN NodePM:
ora:=1;
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown hierarchy status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
ASK tempHier TO ChangeDSIStatus(gre,blu,yel,sie,ora,red);
END IF;
END IF; {parentId>0}
END IF; {runCompleted}
END IF; {GraphicsOutput AND (oldStatus<>newcolor)}
IF (GraphicsOutput AND runCompleted)
dsi:= Descendant("HierMid", 0);
ASK dsi TO SetColor(LimeGreen);
ASK dsi TO Draw; {cmc}
END IF;
END METHOD; {HierObj - ChangeStatus}
ASK METHOD ChangeDSIStatus(IN gre,blu,yel,sie,ora,red : INTEGER);
VAR
dsi : ImageObj;
tempHier : RBDHierObj;
newState,oldState, oldDSIsignal : NodeStatusType;
node : RBDNodeObj;
BEGIN
oldState:=dsiState;
dsiBlues:=dsiBlues+blu;
dsiYellows:=dsiYellows+yel;
dsiSiennas:=dsiSiennas+sie;
dsiOranges:=dsiOranges+ora;
dsiReds:=dsiReds+red;
IF dsiReds>0
newState:=Down;
ELSIF dsiOranges>0;
newState:=NodePM;
ELSIF dsiSiennas>0;
newState:=NodeIdle;
ELSIF dsiYellows>0;
newState:=Degraded;
ELSIF dsiBlues>0;
newState:=NodeStandby;
ELSE;
newState:=AllUp;
END IF;
dsi:= Descendant("HierMid", 0);
node:=ASK root Child("RBDNode",outID);
IF (node.activeStatus=Linked)
ASK dsi TO SetColor(White);
ELSIF (node.activeStatus=Cut)
ASK dsi TO SetColor(Black);
ELSE
CASE newState
WHEN AllUp:
ASK dsi TO SetColor(LimeGreen);
WHEN Degraded:
ASK dsi TO SetColor(Yellow);
WHEN NodeIdle:
ASK dsi TO SetColor(Sienna);
WHEN NodeStandby:
ASK dsi TO SetColor(Blue);
WHEN Down:
ASK dsi TO SetColor(Red);
WHEN NodePM:
ASK dsi TO SetColor(Orange);
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown DSI status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
END IF;
Draw;
IF newState<>oldState
dsiState:=newState;
IF (parentID > 0)
oldDSIsignal:=DSIsignal;
IF (Status > dsiState) {own color worse than descendents}
DSIsignal:=Status;
ELSE
DSIsignal:=dsiState;
END IF;
IF DSIsignal<>oldDSIsignal;
gre:=0;
yel:=0;
sie:=0;
blu:=0;
red:=0;
ora:=0;
CASE oldDSIsignal
WHEN AllUp:
gre:=-1;
WHEN Degraded:
yel:=-1;
WHEN NodeIdle:
sie:=-1;
WHEN NodeStandby:
blu:=-1;
WHEN Down:
red:=-1;
WHEN NodePM:
ora:=-1;
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown hierarchy status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
CASE DSIsignal
WHEN AllUp:
gre:=1;
WHEN Degraded:
yel:=1;
WHEN NodeIdle:
sie:=1;
WHEN NodeStandby:
blu:=1;
WHEN Down:
red:=1;
WHEN NodePM:
ora:=1;
OTHERWISE
NEW(message,1..1);
message[1]:="Unknown hierarchy status color! ";
result:=SendAlert(message,FALSE, FALSE, TRUE);
DISPOSE(message);
END CASE;
tempHier := ASK root Child("RBDHier", parentID);
ASK tempHier TO ChangeDSIStatus(gre,blu,yel,sie,ora,red);
END IF;
END IF;
END IF;
END METHOD; {ChangeDSIStatus}
ASK METHOD IncNumFailed;
BEGIN
INC(numCurrentlyFailed);
END METHOD;
ASK METHOD DecNumFailed;
BEGIN
DEC(numCurrentlyFailed);
END METHOD;
ASK METHOD SetToInitValues;
VAR
dsi, hierImage : ImageObj;
BEGIN
Status:=AllUp;
numCurrentlyFailed:=0;
IF GraphicsOutput
dsi:= Descendant("HierMid", 0);
hierImage := Descendant("Hier", 603);
ASK dsi TO SetColor(LimeGreen);
ASK hierImage TO SetColor(LimeGreen);
Draw;
dsiBlues:=0;
dsiYellows:=0;
dsiSiennas:=0;
dsiOranges:=0;
dsiReds:=0;
DSIsignal:=AllUp;
END IF;
END METHOD;
ASK METHOD CleanUp;
VAR
dsi, hierImage : ImageObj;
BEGIN
dsi:= Descendant("HierMid", 0);
hierImage := Descendant("Hier", 603);
ASK dsi TO SetColor(Black);
ASK hierImage TO SetColor(blockGUIColor);
Draw;
numCurrentlyFailed:=0;
dsiBlues:=0;
dsiYellows:=0;
dsiSiennas:=0;
dsiOranges:=0;
dsiReds:=0;
DSIsignal:=AllUp;
Status:=AllUp;
END METHOD;
ASK METHOD SetxCenter (IN newValue : REAL);
BEGIN
xCenter:=newValue;
END METHOD;
ASK METHOD SetyCenter (IN newValue : REAL);
BEGIN
yCenter:=newValue;
END METHOD;
ASK METHOD SetLocation(IN xLoc, yLoc : REAL);
BEGIN
xPosition := xLoc;
yPosition := yLoc;
END METHOD;
ASK METHOD SetOrigin (IN X, Y : REAL);
BEGIN
xOrigin := X;
yOrigin := Y;
END METHOD;
ASK METHOD SetOldID(IN newValue : INTEGER);
BEGIN
oldID:=newValue;
END METHOD;
ASK METHOD SetmyDepth (IN newValue : INTEGER);
BEGIN
myDepth:=newValue;
END METHOD;
ASK METHOD CalculateDepth (OUT depth : INTEGER);
VAR
tempHier : RBDHierObj;
child : ANYOBJ;
currDepth : INTEGER;
BEGIN
depth := level;
currDepth := 0;
FOREACH child IN childGroup
IF OBJTYPENAME(child) = "RBDHierObj"
tempHier := RBDHierObj(child);
ASK tempHier TO CalculateDepth(currDepth);
END IF;
IF currDepth > depth
depth := currDepth;
END IF;
END FOREACH;
END METHOD;
ASK METHOD SetChildLevels;
VAR
child : ANYOBJ;
tempHier, tempHier2 : RBDHierObj;
BEGIN
FOREACH child IN childGroup
IF OBJTYPENAME(child) = "RBDHierObj"
tempHier := RBDHierObj(child);
IF tempHier.level = deepestLevel
deepestLevel := 0;
END IF;
ASK tempHier TO SetLevel(level+1);
IF deepestLevel = 0
FOREACH tempHier2 IN hierGroup
IF tempHier2.level > deepestLevel
deepestLevel := tempHier2.level
END IF;
END FOREACH;
ELSIF tempHier.level > deepestLevel
deepestLevel := tempHier.level;
END IF;
ASK tempHier TO SetChildLevels;
END IF;
END FOREACH;
END METHOD;
ASK METHOD MassEditHier(IN changeP, useP, changeDep, changeName : BOOLEAN;
IN newDep : INTEGER;
IN newDepType, nameChangeType, newName : STRING;
OUT namemsg : BOOLEAN);
VAR
i : INTEGER;
tempName : STRING;
hierLabel : TextObj;
BEGIN
IF changeP
usesPhasing:=useP;