-
Notifications
You must be signed in to change notification settings - Fork 2
/
IDisplay.mod
executable file
·10400 lines (10239 loc) · 455 KB
/
IDisplay.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 : Display +}
{+ Author : Steve Brown +}
{+ Modified : Sept 4, 2008 wds/TES +}
{+ Description : This module initializes the grid area and handles all actions +}
{+ that occur on the grid - mouseclicks, mouse movement, adding +}
{+ or removing items, selecting items, and the pop up menu. +}
{+ +}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
IMPLEMENTATION MODULE Display;
FROM GTypes IMPORT ALL ColorType, DBPositionType(BottomLeft), ALL SysCursorType,
TextBufferType, WindowMapType(XMajorMap), PointType, PointArrayType,
TextFontType(SystemFont,RomanFont,CourierFont,SystemText),
ALL FillStyleType, ALL GraphPartType, ALL WindowStateType,
ALL LineStyleType, TextHorizType(HorizLeft),TextVertType(VertMiddle),
ALL SnapHorizType, ALL SnapVertType, OptionListType;
FROM GProcs IMPORT Transform;
FROM GTab IMPORT TabObj;
FROM Control IMPORT ControlVObj;
FROM Button IMPORT ButtonObj;
FROM TextBox IMPORT ComboBoxObj, TextBoxObj;
FROM MathMod IMPORT POWER,CEIL;
FROM Radio IMPORT RadioBoxObj, RadioButtonObj;
FROM Value IMPORT ValueBoxObj;
FROM Cursor IMPORT RectCursorObj, FixedAspCursorObj;
FROM Check IMPORT CheckBoxObj;
FROM Label IMPORT LabelObj;
FROM Text IMPORT TextObj;
FROM Line IMPORT PolylineObj;
FROM UtilMod IMPORT ClockTimeSecs,ClockRealSecs,GetNumArgs,GetCmdLineArg, DateTime;
FROM OSMod IMPORT Delay, GetProgDir, FileExists, StartBGTask, GetOSType, SystemCall,
CheckBGTask, DirName, BaseName, AppendSlash, DeleteFile;
FROM IOMod IMPORT StreamObj,FileUseType(Output,Input, Append, BinaryInput, BinaryOutput);
FROM Runsim IMPORT StartEngine, FinalArray, AvailGraph,
StartFEVmode, EndFEVmode, FEVmode,FevDepGroup;
FROM Analyze IMPORT RunEFPA;
FROM FileFx IMPORT CloseFFile, OpenFile, SaveFile, OpenPathsCFG, menuPath, menuFile, loadingFile, versionStr;
FROM Intract IMPORT HelpBoxObj, NodeBoxObj, PrefsBoxObj, SimBoxObj, BlockPropObj, SendAlert,
EventsBoxObj, MassEditBoxObj, ConvertToString, ResimBoxObj, GetSpareList, GetResList,
GetTrigList, doorOpen, HierBoxObj, MakeDistString;
FROM Objects IMPORT arrowhead, RBDBasicObj, directionType(INTO, OUTOF, MINUSINTO, MINUSOUTOF),
resetting, poolGroup, triggerGroup, spareList, resList, trigList, coldList,
boolArray, ALL SparingType, InitFactorySettings, RunBogusRBD,ALL BlockStatusType,
ALL EventStatusType, critFactor, deferTrig, CheckColds, PhaseObj {cmc};
FROM Fill IMPORT FillVObj;
FROM GSnap IMPORT SnapShotObj;
FROM Menu IMPORT MenuItemObj;
FROM Menubar IMPORT inStepMode, inEndState, UpOneLevel, Home, FindItem, MassEdit, PauseSim, ResumeSim,
ColorPrefs, ViewOutputs, notPaused, DisplayFailureEffects, GotoHier, Step, Jump, FEVStream,
ReturnToWorkspace;
FROM Form IMPORT DialogBoxObj, MessageDialogBoxObj;
FROM OSMod IMPORT AppendSlash, MakeDir; { wds/TES, 8/18/08 }
VAR
fromBlockRef : STRING;
fromBlockId, i ,lastMove, pasteBlocks, pasteEvents, displaySetting, pasteHiers,
startHier, startOut, rtn : INTEGER;
lastHeight, lastWidth, oldX, oldY,
linkStartX, linkStartY, linkEndX, linkEndY, upLimit, downLimit,
rightLimit, leftLimit, refX, refY, boxStartX, boxStartY, scale,
boxEndX, boxEndY, oldClickX, oldClickY, sampleRate, yShift,
curOffX, curOffY, lastResize, screenOffset, oldx, oldy, lastZoom, outxdiff : REAL;
editFlag, linkMsgExists, draggingStuff, draggingblock,draggingevent,draggingnode,dragginghier,
draggingSymbol, drawingBox,
drawingRed, linkSelected, awaitingResponse, scrollScreen, workingPaste,
depMsg, noCapVals, phasingInUse : BOOLEAN;
linkMessage : ImageObj;
linkText : TextObj;
message : TextBufferType;
zoomRubber : FixedAspCursorObj;
rubberBox : RectCursorObj;
partialFromGroup, partialToGroup : QueueObj;
current, parent : RBDBasicObj;
selected, currentObj : ImageObj;
copyLinks : ARRAY INTEGER OF LinkObj;
copyNodes : ARRAY INTEGER OF RBDNodeObj;
copyBlocks : ARRAY INTEGER OF RBDBlockObj;
copyEvents : ARRAY INTEGER OF RBDEventObj;
copyHiers : ARRAY INTEGER OF RBDHierObj;
widescreen : BOOLEAN; {cmc 5/10/07}
widescreenOffset : REAL; {cmc 5/10/07}
{wds/TES - mods for finding user's "Application Data" directory, 8/14/08}
PROCEDURE getUserFolderPathAux(IN cstr: CArrayType);
BEGIN
userPath := AppendSlash( CHARTOSTR( cstr )) + AppendSlash( "Raptor7" ); { convert to MODSIM string }
END PROCEDURE;
{wds/TES - mods for finding user's "MyDocuments" directory, 9/4/08}
PROCEDURE getUserMyDocsPathAux(IN cstr: CArrayType);
BEGIN
docsPath := AppendSlash( CHARTOSTR( cstr )) + AppendSlash( "Raptor7" ); { convert to MODSIM string }
END PROCEDURE;
PROCEDURE InitDisplay(OUT exploded : BOOLEAN);
VAR
fileToOpen, nextString, opSys,
month, year, today, bmpToLoad, pword : STRING;
kill, day : INTEGER;
saveCancelled, picUp, recovering, done, cjm : BOOLEAN;
defaultStream : StreamObj;
menuitem : MenuItemObj;
buttitem : PaletteButtonObj;
testBox : DialogBoxObj;
testLabel : LabelObj;
bitmap : SnapShotObj;
dialogBox : HelpBoxObj; {remove with unreliable box}
button : ButtonObj; {remove with unreliable box}
radBox : RadioBoxObj; {remove with unreliable box}
screenX, screenY :INTEGER; {cmc 5/10/07}
retval : INTEGER; { wds/TES, 8/18/08 }
BEGIN
NEW(blockGroup);
NEW(nodeGroup);
NEW(eventGroup);
NEW(hierGroup);
NEW(linkGroup);
NEW(capLinkGroup);
NEW(capNodeGroup);
DateTime(today);
GetPassword(today, pword);
IF GetNumArgs > 0
REPEAT
INC(i);
GetCmdLineArg(i,nextString);
IF nextString = "/d"
diagnostics:=TRUE;
ELSIF nextString = "/sd"
simDetails:=TRUE;
ELSIF nextString = "/cjm"
cjm:=TRUE;
ELSIF nextString = "/dev"
devmode:=TRUE;
ELSIF nextString = "/C130" {cmc}
C130File:=TRUE; {cmc}
ELSIF SUBSTR(1, 9, nextString) = "/password"
IF nextString = "/password-"+ pword
password := TRUE;
ELSE
password := FALSE;
END IF;
ELSIF nextString <> ""
fileToOpen := fileToOpen+nextString+" ";
openFromIcon := TRUE;
END IF;
UNTIL nextString = "";
END IF;
day := STRTOINT(SUBSTR(9, 10, today));
month := SUBSTR(5, 7, today);
year := SUBSTR(STRLEN(today)-3, STRLEN(today), today);
versionStr := "RAPTOR 7.0";
compileType:=CompileType;
IF compileType = "demo"
devVersion := "7.0.12 Demo";
ELSIF compileType = "student"
devVersion := "7.0.12 Student";
ELSIF compileType = "release"
devVersion := "7.0.12"; {Pip}
ELSIF compileType = "gmd"
devVersion := "6.5.4"; {}
versionStr := "RAPTOR 6.5";
ELSE
RETURN;
END IF;
devDate := "June 2009"; { wds/TES, 8/18/08 }
nowInitialing := TRUE;
nameOfFile := "Unnamed RBD";
{+++++++++++ Find the User's Application Data directory, wds/TES 8/14/08 +++++++++++}
getUserFolderPath();
retval := MakeDir( userPath ); { if directory already exists, it appears to do nothing }
getUserMyDocsPath();
retval := MakeDir( docsPath ); { if directory already exists, it appears to do nothing }
IF compileType = "release"
pathName := LOWER(GetProgDir("Raptor7.exe"));
ELSIF compileType = "demo"
pathName := LOWER(GetProgDir("Raptor7Demo.exe"));
ELSIF compileType = "student"
pathName := LOWER(GetProgDir("Raptor7Student.exe"));
ELSIF compileType = "gmd"
pathName := LOWER(GetProgDir("Raptor65.exe"));
END IF;
graphicsPath := pathName+"graphics\";
installPath := pathName; {constant}
{rbdPath := docsPath {+"examples\"}; { wds/TES, 9/4/08 } } {cmc 10/8/08}
reportPath := docsPath {+"reports\"}; { wds/TES, 9/4/08 }
libraryPath:= pathName+"Library\";
exampPath := pathName+"examples\";
soundsPath := pathName+"sounds\";
soundPath := GetProgDir("Sndrec32.exe");
filter := "*.rbd";
simColor:= White;
workColor:=MediumGoldenrod;
goggleColor:=LightBlue;
gridColor:= Goldenrod;
linkWorkColor:= Black;
textWorkColor:= Black;
blockGUIColor:= DarkGreen;
globalUnits := "hours";
systemUnits := globalUnits;
gridIsOn := TRUE;
hierLevel := 0;
deepestLevel := 0;
nextId := 0; {default block is first one given id}
nextLinkId := 1;
currentView := "workspace"
{***}
IF diagnostics
NEW(diagnosticsStream);
diagFile:=installPath + INTTOSTR(day)+month+SUBSTR(12,13,today)+SUBSTR(15,16,today)+".TXT";
ASK diagnosticsStream TO Open(diagFile, Output);{Change 'Output' to 'Append' if writing more}
nextString:="System today String = " + today;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
nextString:="Raptor day month year = " + INTTOSTR(day) + " " + month + " " + year;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
nextString:="devVersion " + devVersion;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
nextString:="installPath = " + installPath;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
nextString:="fileToOpen = " + fileToOpen;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
IF simDetails
NEW(simDetailsStream);
ASK simDetailsStream TO Open(installPath + "simDetails.TXT", Output);{Change 'Output' to 'Append' if writing more}
nextString:="System today String = " + today;
ASK simDetailsStream TO WriteString(nextString);
ASK simDetailsStream TO WriteLn;
nextString:="Raptor day month year = " + INTTOSTR(day) + " " + month + " " + year;
ASK simDetailsStream TO WriteString(nextString);
ASK simDetailsStream TO WriteLn;
nextString:="devVersion " + devVersion;
ASK simDetailsStream TO WriteString(nextString);
ASK simDetailsStream TO WriteLn;
ASK simDetailsStream TO Close;
END IF;
{***}
NEW(window);
ASK window TO SetSize(100.,100.);
lastWidth := 100.;
lastHeight := 100.;
IF compileType = "demo"
ASK window TO SetTitle("RAPTOR 7.0 DEMO - "+nameOfFile);
ELSIF compileType = "student"
ASK window TO SetTitle("RAPTOR 7.0 STUDENT - "+nameOfFile);
ELSIF compileType = "gmd"
ASK window TO SetTitle("RAPTOR 6.5 - "+nameOfFile);
ELSE
ASK window TO SetTitle("RAPTOR 7.0 - "+nameOfFile);
END IF;
ASK window TO ShowWorld(0.,0.,960.,960.);
ASK window TO SetMappingMode(XMajorMap);
ASK window TO SetMoveMonitoring(TRUE);
ASK window TO SetSysCursor(BusyCursor);
ASK window TO SetPanes;
ASK window TO SetScrollable(TRUE,TRUE);
screenX:= getXres(); {cmc 5/10/07} {start}
screenY:= getYres();
IF ( FLOAT(screenX)/FLOAT(screenY) > 1.5)
widescreen:=TRUE;
widescreenOffset := 120.0;
ELSE
widescreen:=FALSE;
widescreenOffset := 0.0;
END IF; {cmc 5/10/07} {end}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
ASK diagnosticsStream TO WriteString("Screen Width is: ");
ASK diagnosticsStream TO WriteString(INTTOSTR(screenX));
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO WriteString("Screen Height is: ");
ASK diagnosticsStream TO WriteString(INTTOSTR(screenY));
ASK diagnosticsStream TO WriteLn;
IF window.PixelWidth > 1.800 {640 X 480}
nextString := "640 X 480";
ELSIF window.PixelWidth > 1.469 {800 X 600}
nextString := "800 X 600";
ELSIF window.PixelWidth > 1.212 {1024 X 768}
nextString := "1024 X 768";
ELSIF window.PixelWidth > 1.095
nextString := "???";
ELSIF window.PixelWidth > 1.00
nextString := "???";
ELSIF window.PixelWidth > 0.891 {1280 X 1024}
nextString := "1280 X 1024";
ELSE
nextString := "anything else";
END IF;
ASK diagnosticsStream TO WriteString("Resolution assumed to be " + nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
IF window.PixelWidth > 1.800 {640 X 480}
displaySetting := 640;
NEW(message, 1..2);
message[1] := "The screen resolution in use is not supported. Some dialog ";
message[2] := "boxes will be clipped and controls may not be accessible. ";
result := SendAlert(message, FALSE, FALSE, FALSE);
DISPOSE(message);
screenOffset := 66000000.;
ELSIF window.PixelWidth > 1.469 {800 X 600}
displaySetting := 800;
screenOffset := 59000000.;
ELSIF window.PixelWidth > 1.212 {1024 X 768}
displaySetting := 1024;
screenOffset := 7000000.;
ELSIF window.PixelWidth > 1.095
{displaySetting := ????;}
screenOffset := -16500000.;
ELSIF window.PixelWidth > 1.00
{displaySetting := ????;}
screenOffset := -33500000.;
ELSIF window.PixelWidth > 0.891 {1280 X 1024}
displaySetting := 1280;
screenOffset := -130000000.; {-130000000.}
ELSE
{displaySetting := ????;}
screenOffset := -63000000.;
END IF;
cusZoomVal := 24.;
ASK window TO Draw;
{***}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Raptor main window initialized......";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
NEW(bitmap);
ASK window TO AddGraphic(bitmap);
CASE month
WHEN "Jul":
IF (day >= 2) AND (day <= 4)
bmpToLoad := "IntroFlag";
END IF;
WHEN "Dec":
IF (day >= 18) AND (day <= 31)
bmpToLoad := "IntroXmas";
END IF;
OTHERWISE
bmpToLoad := "";
END CASE;
IF bmpToLoad = ""
IF compileType = "demo"
bmpToLoad := "IntroDemo"; {IntroDemo}
ELSIF compileType = "student"
bmpToLoad := "IntroStudent"; {IntroStudent}
ELSIF compileType = "gmd"
bmpToLoad := "Intro65";
ELSE
bmpToLoad := "Intro7";
END IF;
END IF;
IF FileExists(graphicsPath + bmpToLoad+".bmp");
ASK bitmap TO SetFile(graphicsPath + bmpToLoad);
ASK bitmap TO SetAlignment(SnapHorizCentered, SnapVertMiddle);
ASK bitmap TO SetTranslation(480.,340.);
ASK bitmap TO Draw;
IF (NOT devmode)
picUp := TRUE;
END IF;
{***}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Displayed bitmap = "+ bmpToLoad+".bmp" ;
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
END IF;
NEW(baseroot);
ASK window TO AddGraphic(baseroot);
NEW(scaleroot);
ASK baseroot TO AddGraphic(scaleroot);
NEW(root);
ASK scaleroot TO AddGraphic(root);
typeOfCursor := dialogC;
NEW(sound);
fileIsOpen := TRUE;
IF FileExists(exampPath + "cksrule.rbd");
NEW(message,1..2);
message[1] := "RAPTOR appears to have been abnormally exited during the last session. ";
message[2] := "would you like to recover the .rbd from that session? ";
result := SendAlert(message, FALSE, TRUE, FALSE);
DISPOSE(message);
IF result
fileToOpen := exampPath + "cksrule.rbd";
recovering := TRUE;
ELSE
kill := DeleteFile(exampPath + "cksrule.rbd");
END IF;
END IF;
IF FileExists(userPath + "prefs70.cfg") { wds/TES, 8/15/08 }
NEW(defaultStream);
ASK defaultStream TO Open((userPath + "prefs70.cfg"), Input); { wds/TES, 8/15/08 }
IF defaultStream.ioResult <> 0
globalImage := "Equalizer";
systemImage := globalImage;
saveIsOn := FALSE;
saveInc := 15;
soundIsOn:=TRUE;
lambdaMode:=FALSE;
muSigmaMode:=FALSE;
globalUnits := "hours";
systemUnits := globalUnits;
RETURN;
ELSE
ASK defaultStream TO ReadLine(nextString);
IF SUBSTR(1,15,nextString) = "Raptor 7.0 Pref"
ASK defaultStream TO ReadLine(nextString);
ASK defaultStream TO ReadLine(nextString);
globalImage := SUBSTR(29, STRLEN(nextString), nextString);
systemImage := globalImage;
ASK defaultStream TO ReadLine(nextString);
globalUnits := SUBSTR(26, STRLEN(nextString), nextString);
systemUnits := globalUnits;
ASK defaultStream TO ReadLine(nextString);
IF SUBSTR(13, STRLEN(nextString), nextString) = "ON"
saveIsOn:=TRUE;
END IF;
ASK defaultStream TO ReadLine(nextString);
saveInc := STRTOINT(SUBSTR(26, 31, nextString))*60;
ASK defaultStream TO ReadLine(nextString);
IF SUBSTR(10, STRLEN(nextString), nextString) = "ON"
soundIsOn:=TRUE;
END IF;
ASK defaultStream TO ReadLine(nextString);
IF SUBSTR(16, STRLEN(nextString), nextString) = "ON"
lambdaMode:=TRUE;
END IF;
ASK defaultStream TO ReadLine(nextString);
IF SUBSTR(18, STRLEN(nextString), nextString) = "ON"
muSigmaMode:=TRUE;
END IF;
ASK defaultStream TO ReadLine(nextString);
ELSE
globalImage := "Equalizer";
systemImage := globalImage;
saveIsOn := FALSE;
saveInc := 15;
soundIsOn:=TRUE;
lambdaMode:=FALSE;
muSigmaMode:=FALSE;
globalUnits := "hours";
systemUnits := globalUnits;
END IF;
END IF;
DISPOSE(defaultStream);
{***}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Prefs70.cfg opened and read";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
ELSE
globalImage := "Equalizer";
systemImage := globalImage;
globalUnits := "hours";
systemUnits := globalUnits;
saveIsOn := FALSE;
saveInc := 15;
opSys := GetOSType();
IF (POSITION(opSys, "UNICODE") > 0) OR (soundPath = "")
soundIsOn := FALSE;
ELSE
soundIsOn:=TRUE;
END IF;
lambdaMode:=FALSE;
muSigmaMode:=FALSE;
{***}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Prefs70.cfg not found...defaults set";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
END IF;
flowGenerated := 1;
sysLostCost := 0.0;
systemRedCost := 0.0;
lastSave := TRUNC(ClockRealSecs);
IF soundIsOn AND (FileExists(soundsPath + "Intro.wav"))
ASK sound TO PlayMe(soundsPath + "Intro.wav");
END IF;
IF picUp
Delay(3);
END IF;
NEW(dialogs);
IF (compileType = "release") AND (NOT training) {eag training}
ASK dialogs TO ReadFromFile(pathName + "graphics\dialogs70release.sg2");
NEW(testBox);
ASK testBox TO LoadFromLibrary(dialogs,"CompileTypeBox");
testLabel := ASK testBox Child("CompileType", 0);
IF testLabel.Label <> "release"
exploded := TRUE;
NEW(message,1..3);
message[1] := "Mismatched DLLs. Contact the Raptor Technical Support ";
message[2] := "Team at raptortech@arinc.com or call 1-505-248-0718 to";
message[3] := "obtain a licensed version.";
result := SendAlert(message, FALSE, FALSE, TRUE);
DISPOSE(message);
RETURN;
END IF;
ELSIF ((compileType = "release") AND training) OR (compileType = "demo") {eag training}
ASK dialogs TO ReadFromFile(pathName + "graphics\dialogs70demo.sg2");
ELSIF compileType = "student"
ASK dialogs TO ReadFromFile(pathName + "graphics\dialogs70student.sg2");
ELSIF compileType = "gmd"
ASK dialogs TO ReadFromFile(pathName + "graphics\dialogs70gmd.sg2");
END IF; IF cjm compileType:="release"; END IF;
ASK window TO SetColor(workColor);
NEW(images);
ASK images TO ReadFromFile(pathName + "graphics\images70.sg2");
NEW(menubar);
ASK menubar TO LoadFromLibrary(dialogs,"MenuBar");
ASK window TO AddGraphic(menubar);
NEW(menuTool);
ASK menuTool TO LoadFromLibrary(dialogs,"MenuTools");
ASK window TO AddGraphic(menuTool);
NEW(grid);
typeOfCursor := nilC;
NEW(simMenuBar);
ASK simMenuBar TO LoadFromLibrary(dialogs,"SimMenuBar");
ASK window TO AddGraphic(simMenuBar);
ASK simMenuBar TO SetHidden(TRUE);
NEW(simToolBar);
ASK simToolBar TO LoadFromLibrary(dialogs,"SimToolBar");
ASK window TO AddGraphic(simToolBar);
ASK simToolBar TO SetHidden(TRUE);
NEW(weakMenuBar);
ASK weakMenuBar TO LoadFromLibrary(dialogs,"WeakMenuBar");
ASK window TO AddGraphic(weakMenuBar);
ASK weakMenuBar TO SetHidden(TRUE);
NEW(weakToolBar);
ASK weakToolBar TO LoadFromLibrary(dialogs,"WeakToolBar");
ASK window TO AddGraphic(weakToolBar);
ASK weakToolBar TO SetHidden(TRUE);
NEW(fevMenuBar);
ASK fevMenuBar TO LoadFromLibrary(dialogs,"FEVMenuBar");
ASK window TO AddGraphic(fevMenuBar);
ASK fevMenuBar TO SetHidden(TRUE);
NEW(fevToolBar);
ASK fevToolBar TO LoadFromLibrary(dialogs,"FEVToolBar");
ASK window TO AddGraphic(fevToolBar);
ASK fevToolBar TO SetHidden(TRUE);
NEW(defaultBlock);
ASK defaultBlock TO LoadFromLibrary(images, "RBDBlock");
ASK defaultBlock TO SetID("RBDBlock", 0);
ASK root TO AddGraphic(defaultBlock);
ASK defaultBlock TO SetHidden(TRUE);
{***}
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="SG2 file opened and read";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
InitFactorySettings;
IF FileExists(userPath + "PATHS.CFG") { wds/TES, 8/15/08 }
OpenPathsCFG(userPath, exampPath); { wds/TES, 8/15/08 }
{***}
rbdPath := pathName; { cmc 10/8/08 }
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Paths.cfg opened and read";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
ELSE
IF compileType = "demo"
ASK menubar TO SetFileNames(exampPath, "BasicDemo.rbd", exampPath, "EventsDemo.rbd",
exampPath, "FactoryDemo.rbd", exampPath, "PhasingDemo.rbd",
exampPath, "PreventMxDemo.rbd", exampPath, "MotorDemo.rbd");
ELSIF compileType = "student" {set to student files}
ASK menubar TO SetFileNames(exampPath, "Cascade.rbd", exampPath, "Complex.rbd",
exampPath, "ElectricMotor.rbd", exampPath, "Events.rbd",
exampPath, "Hierarchy.rbd", exampPath, "SpaceStation.rbd");
ELSIF compileType = "gmd" {set to 6.5 gmd files}
ASK menubar TO SetFileNames(exampPath, "Basic.rbd", exampPath, "Distributions.rbd",
exampPath, "Logistics.rbd", exampPath, "Events.rbd",
exampPath, "Dependence.rbd", exampPath, "Standby.rbd");
ELSE
ASK menubar TO SetFileNames(exampPath, "Basic1.rbd", exampPath, "Distributions1.rbd",
exampPath, "Logistics1.rbd", exampPath, "Events1.rbd",
exampPath, "Dependence1.rbd", exampPath, "Standby1.rbd");
END IF;
{***}
rbdPath := exampPath;;
IF diagnostics
ASK diagnosticsStream TO Open(diagFile, Append);
nextString:="Paths.cfg file not found...defaults set";
ASK diagnosticsStream TO WriteString(nextString);
ASK diagnosticsStream TO WriteLn;
ASK diagnosticsStream TO Close;
END IF;
{***}
END IF;
DISPOSE(bitmap);
ASK root TO AddBeforeGraphic(defaultBlock, grid);
ASK grid TO Colorize("Normal");
ASK menubar TO Draw;
xOrigin := 0.;
yOrigin := 80.;
SetView(cusZoomVal,0.,80.);
AddStartEndNodes;
ASK grid TO Draw;
menuitem := ASK menubar Descendant("separator", 0);
ASK menuitem TO Deactivate;
menuitem := ASK menubar Descendant("InputItem",3015);
ASK menuitem TO Deactivate;
menuitem := ASK menubar Descendant("HierInputItem",3014);
ASK menuitem TO Deactivate;
IF compileType <> "release"
menuitem := ASK menubar Descendant("RefItem", 604);
ASK menuitem TO Deactivate;
END IF;
{IF NOT password
menuitem := ASK menubar Descendant("FEVItem",502);
ASK menuitem TO Deactivate;
buttitem := ASK menuTool Descendant("FEVButton", 930);
ASK buttitem TO Deactivate;
END IF;}
ASK menubar TO Disable(1);
ASK menubar TO Disable(2);
ASK menubar TO Disable(3);
ASK menubar TO Disable(4);
ASK menubar TO Disable(7);
ASK menubar TO Disable(8);
ASK menubar TO Disable(10);
ASK menubar TO Disable(12);
ASK menubar TO Disable(13);
ASK menubar TO Disable(14);
ASK menubar TO Disable(16);
ASK menubar TO SetChecks;
ASK window TO SetSysCursor(NormalCursor);
dTimeTrunc := 1000.;
dTimeStartTime := 0.;
dNumberOfRuns := 1.;
dTimeSlice := 10000000.0;
dFailTrunc := 25.;
dFailStartTime := 0.;
dCycleTrunc := 0.;
dCycleStartTime := 0.;
dSimWithGraph := TRUE;
termType := 1; {time = 1, failure = 2, cycle = 3}
negShutUp := FALSE;
statusBarOn := TRUE;
analViewAvail := FALSE;
configFrozen := FALSE;
doorOpen := FALSE;
weakLinkAnalType := 1;
GYthreshold := 0.95;
YRthreshold := 0.90;
yMin := 0.0;
yMax := 1.0;
NEW(poolGroup);
NEW(triggerGroup);
NEW(spareList, 1..1);
NEW(coldList, 1..1);
NEW(resList, 1..1);
NEW(trigList, 1..1);
spareList[1] := "unnamed";
coldList[1] := "unnamed";
resList[1] := "unnamed";
trigList[1] := "unnamed";
NEW(sysStreams, 1..11);
sysStreams[1] := 7; sysStreams[3] := 9;
sysStreams[2] := 8; sysStreams[4] := 10;
sysStreams[5] := 70; sysStreams[6] := 71;
sysStreams[7] := 72; sysStreams[8] := 73;
sysStreams[9] := 74; sysStreams[10] :=75;
sysStreams[11] := 101;
activePhases := 0;
NEW(selectGroup);
NEW(selectedLinksGroup);
NEW(partialFromGroup);
NEW(partialToGroup);
NEW(current);
NEW(popupMenu);
ASK window TO AddGraphic(popupMenu);
ASK popupMenu TO Erase;
nowInitialing := FALSE;
{IF NOT devmode
NEW(dialogBox);
ASK dialogBox TO LoadFromLibrary(dialogs, "UnreliableBox");
ASK window TO AddGraphic(dialogBox);
ASK dialogBox TO Draw;
radBox := ASK dialogBox Descendant("RadBox", 0);
button := ASK dialogBox TO AcceptInput();
IF ASK button ReferenceName = "OKButton"
IF radBox.SelectedButton.Id = 2
ASK window TO BeClosed;
END IF;
END IF;
END IF; }
RunBogusRBD;
IF fileToOpen <> ""
REPEAT
IF SUBSTR(STRLEN(fileToOpen), STRLEN(fileToOpen), fileToOpen) = " "
fileToOpen := SUBSTR(1, STRLEN(fileToOpen)-1, fileToOpen);
ELSE
done := TRUE;
END IF;
UNTIL done;
openMenuFile := TRUE;
menuFile := BaseName(fileToOpen);
menuPath := AppendSlash(DirName(fileToOpen));
ASK menubar TO Disable1Thru8;
OpenFile(TRUE, FALSE, totalBlocks, totalNodes, totalLinks, totalHiers, totalEvents, 0, gridIsOn, fileIsOpen,
menuFile, menuPath, filter, saveCancelled);
SetView(cusZoomVal, xOrigin, yOrigin);
nameOfFile := menuFile;
IF recovering
nameOfFile := "Unnamed RBD";
END IF;
CheckOpenFileStatus;
ASK menubar TO SetChecks;
ELSE
IF diagnostics
IF compileType = "demo"
ASK window TO SetTitle("RAPTOR 7.0 DEMO Diagnostics - " + nameOfFile);
ELSIF compileType = "student"
ASK window TO SetTitle("RAPTOR 7.0 STUDENT Diagnostics - " + nameOfFile);
ELSIF compileType = "gmd"
ASK window TO SetTitle("RAPTOR 6.5 Diagnostics - " + nameOfFile);
ELSE
ASK window TO SetTitle("RAPTOR 7.0 Diagnostics - " + nameOfFile);
END IF;
ELSE
IF compileType = "demo"
ASK window TO SetTitle("RAPTOR 7.0 DEMO - " + nameOfFile);
ELSIF compileType = "student"
ASK window TO SetTitle("RAPTOR 7.0 STUDENT - " + nameOfFile);
ELSIF compileType = "gmd"
ASK window TO SetTitle("RAPTOR 6.5 - " + nameOfFile);
ELSE
ASK window TO SetTitle("RAPTOR 7.0 - " + nameOfFile);
END IF;
END IF;
END IF;
IF password
ASK window TO ShowStatus(0,"Open");
END IF;
ASK window TO Update;
END PROCEDURE; {InitDisplay}
PROCEDURE GetPassword(IN today : STRING; OUT pword :STRING);
VAR
nextNumber,nextLetter, month :STRING;
BEGIN
month := SUBSTR(5, 7, today);
IF month="Jan"
pword:="zt";
ELSIF month="Feb"
pword:="zn";
ELSIF month="Mar"
pword:="zm";
ELSIF month="Apr"
pword:="zr";
ELSIF month="May"
pword:="zl";
ELSIF month="Jun"
pword:="zs";
ELSIF month="Jul"
pword:="zk";
ELSIF month="Aug"
pword:="zv";
ELSIF month="Sep"
pword:="zb";
ELSIF month="Oct"
pword:="tz";
ELSIF month="Nov"
pword:="tt";
ELSIF month="Dec"
pword:="tn";
END IF;
nextLetter := SUBSTR(9, 9, today);
ConvertNumber(nextLetter);
pword:=pword+nextLetter;
nextLetter := SUBSTR(10, 10, today);
ConvertNumber(nextLetter);
pword:=pword+nextLetter;
nextLetter := SUBSTR(23, 23, today);
ConvertNumber(nextLetter);
pword:=pword+nextLetter;
nextLetter := SUBSTR(24, 24, today);
ConvertNumber(nextLetter);
pword:=pword+nextLetter;
END PROCEDURE;
PROCEDURE ConvertNumber(INOUT a : STRING);
BEGIN
IF a="1"
a:="t";
ELSIF a="2"
a:="n";
ELSIF a="3"
a:="m";
ELSIF a="4"
a:="r";
ELSIF a="5"
a:="l";
ELSIF a="6"
a:="s";
ELSIF a="7"
a:="k";
ELSIF a="8"
a:="v";
ELSIF a="9"
a:="b";
ELSIF a="0"
a:="z";
END IF;
END PROCEDURE;
PROCEDURE AddStartEndNodes;
VAR
node : RBDNodeObj;
BEGIN
somethingChanged :=TRUE;
NEW(node); {Start Node}
ASK nodeGroup TO Add(node);
INC(totalNodes);
INC(totalObjects);
ASK node TO LoadFromLibrary (images, "RBDStartNode");
ASK node TO SetID("RBDNode", nextId);
startId := node.Id;
ASK root TO AddAfterGraphic(defaultBlock,node);
ASK node TO SetScaling(1.,1.);
{ASK node TO SetScaling(scale,scale);
ASK window TO AddGraphic(node); }
ASK node TO DisplayAt(1., 73.);
{ASK node TO SetSnapShot(FALSE);}
ASK node TO SetName("start");
{ASK node TO SetTranslation(node.Translation.x, node.Translation.y);}
ASK node TO SetType(1);
ASK node TO SetNum(node.Id);
ASK node TO SetParentID(0);
ASK node TO SetGoodPaths(1);
ASK node TO SetFullFlow(TRUE);
ASK node TO SetAnyPath(TRUE);
ASK node TO Draw;
NEW(node); {End Node}
ASK nodeGroup TO Add(node);
INC(totalNodes);
INC(totalObjects);
ASK node TO LoadFromLibrary (images, "RBDEndNode");
ASK node TO SetID("RBDNode", nextId);
endId := node.Id;
ASK root TO AddAfterGraphic(defaultBlock,node);
ASK node TO SetScaling(1.,1.);
{ASK node TO SetScaling(scale,scale);
ASK window TO AddGraphic(node); }
ASK node TO DisplayAt(22., 73.);
{ASK node TO SetSnapShot(FALSE);}
ASK node TO SetName("end");
{ASK node TO SetTranslation(node.Translation.x, node.Translation.y);}
ASK node TO SetType(3);
ASK node TO SetNum(node.Id);
ASK node TO SetParentID(0);
ASK node TO SetGoodPaths(1);
ASK node TO SetFullFlow(TRUE);
ASK node TO SetAnyPath(TRUE);
ASK node TO Draw;
END PROCEDURE;
PROCEDURE CheckTimeBomb(OUT exploded : BOOLEAN);
VAR
Today : STRING;
JDay,LastUsed,ElimiDate : INTEGER;
expired, diddledClock, diddledFile : BOOLEAN;
securityFileStream : StreamObj;
BEGIN;
DateTime(Today);
JDay :=0;
CASE SUBSTR(5,7,Today)
WHEN "Jan" : JDay := 0;
WHEN "Feb" : JDay := 31;
WHEN "Mar" : JDay := 31+28;
WHEN "Apr" : JDay := 31+28+31;
WHEN "May" : JDay := 31+28+31+30;
WHEN "Jun" : JDay := 31+28+31+30+31;
WHEN "Jul" : JDay := 31+28+31+30+31+30;
WHEN "Aug" : JDay := 31+28+31+30+31+30+31;
WHEN "Sep" : JDay := 31+28+31+30+31+30+31+31;
WHEN "Oct" : JDay := 31+28+31+30+31+30+31+31+30;
WHEN "Nov" : JDay := 31+28+31+30+31+30+31+31+30+31;
WHEN "Dec" : JDay := 31+28+31+30+31+30+31+31+30+31+30;
END CASE;
JDay := JDay + STRTOINT(SUBSTR(9,10,Today));
JDay := JDay + (STRTOINT(SUBSTR(21,24,Today))-2001)*365;
NEW(securityFileStream);
{ Modifications by SJP 12/4/08 - Change check to look in userPath and create .stf file if it does not exist }
ASK securityFileStream TO Open(userPath+"raptor.stf", BinaryInput);
IF securityFileStream.ioResult <> 0
ElimiDate:=JDay+elimiDays;
ASK securityFileStream TO Open(userPath+"raptor.stf", BinaryOutput);
ASK securityFileStream TO WriteInt(JDay,3);
ASK securityFileStream TO WriteInt(ElimiDate,3);
ELSE
ASK securityFileStream TO ReadInt(LastUsed);
ASK securityFileStream TO ReadInt(ElimiDate);
IF (LastUsed > JDay) OR (JDay < 0)
diddledClock := TRUE;
NEW(message,1..3);
message[1] := "The system clock has been reset to a date ";
message[2] := "prior to the last date Raptor was used.";
message[3] := "Raptor will not work.";
result := SendAlert(message,FALSE,FALSE,TRUE);
DISPOSE(message);
END IF;
IF NOT(diddledClock)
ASK securityFileStream TO Open(userPath+"raptor.stf", BinaryOutput);
ASK securityFileStream TO WriteInt(JDay,3);
ASK securityFileStream TO WriteInt(ElimiDate,3);
END IF;
END IF;
IF ((compileType="demo") OR (compileType="student"))
IF JDay > ElimiDate
expired := TRUE;
NEW(message, 1..2);
message[1] := "This version of Raptor has expired. Please contact ";
message[2] := "raptortech@arinc.com for extensions or more information.";
result := SendAlert(message, FALSE, FALSE, FALSE);
DISPOSE(message);
END IF;
ELSIF training
IF JDay > (ElimiDate - 60) {expireDate -- eag changed, expireDate isn't used anymore right (did thorough search
of all modules and found no other use of the "expireDate" variable except for initial
definition in DDisplay)?, used to never hit this code if "release"}
expired := TRUE;
NEW(message, 1..2);
message[1] := "This Training version of Raptor has expired. Please contact";
message[2] := "raptortech@arinc.com for more information. ";
result := SendAlert(message, FALSE, FALSE, FALSE);
DISPOSE(message);
END IF;
END IF;
ASK securityFileStream TO Close
exploded := (diddledClock OR diddledFile OR expired);
END PROCEDURE;