-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.pas
More file actions
4753 lines (4168 loc) · 167 KB
/
Data.pas
File metadata and controls
4753 lines (4168 loc) · 167 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
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
// Application Specific Data Declarations and Definitions
// Date 28.05.22
// Limits: Delphi sensor pressure = 80% of 20bar = 16bar = 160m (Sensor.pas)
unit Data;
interface
uses
Windows, SysUtils, Classes, TypInfo, Variants, Forms, Math, Global;
procedure InitGlobalData;
procedure InitApplication;
procedure SetGlobalData;
procedure AddGlobalPar(Par: Word);
procedure GetSigNum(Sig: Word; var Num: Long);
procedure FormatValue(Dtype: Byte; Ival: Word; var Oval: string);
procedure ConvertValue(var Vact: Long; var Prec: Byte; Tuni: Byte);
procedure CompressTime(Itime: Long; var Otime: Word);
procedure ExpandTime(Itime: Word; var Otime: Long);
const
DEVSTATUS = 4; // development status (2=P2/P2A, 3=P3/P3A/P3B, 4=P4)
MAINCODE = '4711'; // security code for debugging
// task control and timing
//========================
DAQDELAY = 250; // loop delay for data acquisition [ms]
LOWLOOP = 39; // number of loops for low priority actions (39x250ms)
MEDLOOP = 17; // number of loops for medium priority actions (17x250ms)
HIGLOOP = 11; // number of loops for high priority actions (11x250ms)
ANYLOOP = 1; // number of loops for highest priority (every loop)
GUIDELAY = 70; // loop delay for user interface [ms]
GUISPEEDUP = 4; // loop delay speed up for DELPHI only (70/4=17ms)
KEYDELAY = 250; // key disable time for menu opening [ms]
DISPLOOP = 10; // number of loops for display refresh (10x70ms)
HEADLOOP = 5; // number of loops for compass refresh (5x70ms)
KEYLOOP = 50; // number of loops for key acceptance (50x70ms)
TONELOOP = 15; // number of loops for tone repetition (15x70ms)
EXITLOOP = 600; // number of loops for timeout exit (600x70ms=42s)
TASKDELAY = 2000; // delay time for task starting (2000ms)
INITDELAY = 5000; // delay time for initial phase (5000ms)
DISPDELAY = 3000; // delay time for display messages (3000ms)
MAXLOOP = 1000; // reset value for loop counter
ALARMDELAY = 10; // max alarm life time = 10min
COMDELAY = 50; // loop delay for serial communication [ms]
MAXTASK = 5; // max number of running tasks
TASKRUN = 0; // runtime system
TASKDAQ = 1; // data acquisition
TASKGUI = 2; // user interface
TASKCOM = 3; // host communication
PRIORUN = 20; // task priorities (1=low .. 255=high)
PRIODAQ = 40; // total=100%
PRIOGUI = 40; // RUN=20%, DAQ=40%, GUI=40%
PHASENONE = 0; // dive phases
PHASEINITIAL = 1; // -initial phase
PHASEINTERVAL = 3; // -interval phase
PHASEADAPTION = 4; // -adaption phase
PHASEREADY = 5; // -ready phase
PHASEPREDIVE = 6; // -pre-dive phase
PHASEDIVE = 7; // -dive phase
PHASEPOSTDIVE = 8; // -post-dive phase
MODEOFF = 0; // main run modes
MODESLEEP = 1; // -sleep mode
MODESTART = 2; // -restart mode
MODERUN = 3; // -operation mode
MODEAUTO = 4; // -automatic mode
MODECOMM = 5; // -communication mode
MODEUSER = 6; // -user mode //nk// obsolete ? !!!!
SIGMAXNUM = 15; // number of signals (Bit 1..16)
SIGNONE = 0; // no signal pending
SIGWARNTEMP = 1; // lowest priority
SIGWARNBREATH = 2;
SIGWARNDEPTH = 3;
SIGWARNSPEED = 4;
SIGWARNTANK = 5;
SIGWARNACCU = 6;
SIGWARNOXDOSE = 7;
SIGWARNOXPRESS = 8;
SIGWARNGAS = 9;
SIGALARMSPEED = 10;
SIGALARMTANK = 11;
SIGALARMACCU = 12;
SIGALARMDECO = 13;
SIGALARMOXDOSE = 14;
SIGALARMOXPRESS = 15;
SIGALARMGAS = 16; // highest priority
SIGMESSAGE = 17; // signal for message window
SIGCLOCKALARM = 18; // signal for alarm clock
// serial communication
//=====================
SERPINMASK = $030; // disable SER0 / enable SER1 08.12.05 nk add
SERSPEED = 38400; // serial port: 38400 baud (Tiger=18=12h)
SERDATA = 8; // 8 data bit / no parity (Tiger=3)
SERPARAM = '38400/8/1/N';
// graphic display
//================
LCDTYPE = 9; // display type 128x128 dots/8x8 dot char
LCDPINS = $0EE; // display control pins
LCDCOMM = 150; // display communication speed
LCDSPEED = $11; // display refresh rate
LCDDPORT = 6; // display data port
LCDCPORT = 8; // display control port
LCDRESET = 4; // display reset pin (P84)
LCDFONTSEL = 5; // display font select pin (P85)
LCDXRANGE = 128; // display graphic area X-range [dots]
LCDYRANGE = 128; // display graphic area Y-range [dots]
LCDBUFFLEN = 2048; // display screen buffer size [byte] (5120 for mode 6)
// power management // 17.02.07 nk new pwr-definitions and functions
//=================
PWRHOLD = 1; // switch processor module on/off (self hold)
PWRDISP = 2; // switch display on/off
PWRLITE = 3; // switch backlite on/off
PWRSALT = 4; // switch salinity sensor on/off
PWRSONAR = 5; // switch sonar receiver on/off
PWRMODUL = 6; // switch external module on/off
PWRDISPPIN = 85; // display control pin (P85)
PWRLITEPIN = 86; // backlite control pin (P86)
PWRHOLDPIN = 87; // processor control pin (P87)
PWRSALTPIN = 90; // salinity control pin (P90)
PWRSONARPIN = 91; // sonar control pin (P91)
PWRMODULPIN = 92; // external control pin (P92)
// digipot write addresses:
PWRCONTRAST = $50; // contrast - suffix L
PWRBRIGHTNESS = $54; // brightness - suffix N
PWRLOUDNESS = $58; // loudness - suffix M
ACCUMIN = 6000; // min accu voltage = 6.0V (0%)
ACCUMAX = 8400; // max accu voltage = 8.4V (100%) 2xLiIon 3.7V/2400mAh
ACCUATTEN = 2; // accu voltage attenuation
ACCUGRADE = 100000; // 26.07.17 nk add for defph to simulate accu discharge (100 -> 0% ~ 400min.)
// analog/digital converter
//=========================
ADCACCU = 0; // adc accu pack voltage (P50) (div 2)
ADCSENS = 1; // adc sensor module voltage (P51) 3.3V
ADCSALT = 2; // adc salinity sensor voltage (P52)
ADCSONAR = 3; // adc sonar signal level (P53)
// MEM flash memory
//=================
//24.05.07 nk TIGER mov to Flash
//MEMSECTSIZE = 65536; // flash sector size = 65'536bytes = 64kB
//MEMPROTECT = 0; // no protected flash sectors
MEMSECTMIN = 2; // min free flash sectors for dive data
// I2C bus (P4)
//========
I2CPORT = 3; // I2C bus port
I2CSCL = 3; // I2C bus clock pin (P33)
I2CSDA = 4; // I2C bus data I/O pin (P34)
// the new low level I2C will be used if defined
I2CDELAY = 20; // I2C bus send delay (0=200kHz, 1=100kHz..20=30kHz)
I2CMODE = 0; // I2C bus mode (0=LSB first, 1=MSB first=ISO7816)
// SPI bus
//========
SPIPORT = 3; // SPI bus port
SPIMOSI = 5; // SPI bus data output pin (P35)
SPIMISO = 6; // SPI bus data input pin (P36)
SPICLK = 7; // SPI bus clock pin (P37)
SPICS = -1; // SPI bus chip select (new SPI feature=n/u)
SPIMODE = 1; // SPI bus mode (0=LSB first, 1=MSB first)
// audio & sound (P4)
//==============
AUDPORT = 9; // audio output port
AUDPIN = 5; // audio output pin (P95)
// joystick
//=========
KEYPORT = 7; // keypad parallel port
KEYPIN1 = 0; // key #1 pin (P70)
KEYPIN2 = 1; // key #2 pin (P71)
KEYPIN3 = 2; // key #3 pin (P72)
KEYPIN4 = 3; // key #4 pin (P73)
KEYPINS = 15; // keypad init pattern
KEYLEVEL = 0; // keypad logic level=LO when pressed
KEYMOVE = 2; // up/down key (move pointer)
KEYTURN = 4; // left/right key (turn selection)
KEYBACK = 8; // close menu and go back
KEYPAGE = 16; // next/previous page
KEYEXIT = 32; // no key within timeout
KEYWAIT = 255; // wait on key return code
KEYINIT = 255; // initial state
KEYREP = 10; // key repetition rate [loops]
// compass module
//===============
HEADMIDDLE = 56; // middle position of compass pointer
HEADOFFSET = 68; // bitmap offset for north pointer
HEADPIXEL = 15; // 15ddeg = 1.5°/pixel
HEADSTEP = 30; // 30ddeg = 3°/click (DELPHI only)
// data acquisition
//=================
MAXCOMP = 17; // max number of compartments (-1)
DECODISP = 99; // 05.06.07 nk add deco font change if >99m/ft or >59min
DECORANGE = 106; // max deco ceiling [m] (~75% of max depth range)
DEPTHDISP = 19900; // max display depth range = 199m
TIMESHORT = 5999; // max short time range [s] = 99min
TIMERANGE = 35999; // max operating time range [s] = 9h59
TIMEDISP = 359999; // max display time range [s] = 99h59m
TIMELIMIT = 57600; // time limit for sec/min [s] = 960.0min = 16h00
TIMELIMMSEC = 57600000; // time limit for sec/min [ms] = 960.0min = 16h00
SPEEDBUFLEN = 8; // integral lenght for speed buffer
SPEEDRATE = 240; // dive speed = 5cm/s every 12m depth
SPEEDMIN = 10; // min dive speed 10cm/s
SPEEDMAX = 50; // max dive speed 50cm/s
SPEEDDOWN = 30; // max descending dive speed 30cm/s
SPEEDDISP = 999; // max display dive speed range = +/-999%
ALTITUDEMAX = 5000; // max altitude = 5000m above sea level
AIRPRESSMIN = 540; // min air pressure = 540hPa (5000mM)
AIRPRESSMAX = 1085; // max air pressure = 1085hPa
BAROMIN = 930; // barometer range = 930..1030hPa (0..100%)
BAROMAX = 1030; // barometer maximum
BAROHIST = 21; // barometer history time = 20h
OXPSTEP = 18; // number of steps for cns clock calculation
OXPPART = 100; // oxygen partial pressure per step [mbar]
OXPMIN = 500; // min oxygen partial pressure = 500mbar
OXRANGE = 9999; // max oxygen pressure range (9999mbar)
OXDISP = 9990000; // max oxygen toxicity range [ppm] (999%)
OXMAXDOSE = 850; // max oxygen dose per day (100%=850 OTU)
OXHALFTIME = 5400; // oxygen clock half time [s] (CNS=90min)
FOXYGEN = 210; // oxygen fraction in air [ppt] = 21%
FNITROGEN = 790; // nitrogen fraction in air [ppt] = 79%
FHELIUM = 10; // helium fraction in air [ppt] = 1%
PDESAT = 30; // diff pressure for desaturation = 30mbar
PFLIGHT = 50; // diff pressure for flying = 50mbar
PVAPOR = 63; // vapor pressure (pH2O) in lung = 63mbar
SCOREMIN = 25; // min diver score = 25%
SCOREMAX = 100; // max diver score = 100%
TANKRESERVE = 20000; // tank reserve pressure [mbar] = 20bar
// user interface
//===============
MAXWIN = 12; // max number of windows (incl. pseudo window)
INITWIN = 7; // init window (7=logo)
WINDEF = 7; // number of window definitions
MAXBOX = 250; // max number of user boxes (incl. pseudo box)
BOXDEF = 10; // number of box definitions
MAXOBJ = 20; // max number of message objects
OBJDEF = 10; // number of object definitions
WINNONE = 0; // window names and numbers
WINDEPTH = 1;
WINTIME = 2;
WINDECO = 3;
WINGAS = 4;
WINNAVIGATION = 5;
WINMENU = 6;
WINCLOCK = 7;
WINCALENDAR = 8;
WINPOWER = 9;
WINSATURATION = 10;
WINBARO = 11;
WINPLAN = 12; // 02.02.07 nk add dive planner window
MENULEVEL = 5; // number of menu sub-levels
MENUDISP = 9; // number of display menu
MENUCLOCK = 10; // number of clock menu
SETMENU = 12; // number of selection menus
SETBOX = 10; // number of selection boxes
SETDEF = 5; // number of selection definitions (0..4)
SETFIRST = 50; // number of 1st selection box
SETPARS = 60; // number of setting parameter = 2blocks x 30bytes
COMMCLOSE = 0; // command for close the main window
COMMNODATA = 59; // command for no data info
COMMSAVE = 251; // command for save settings
COMMFIX = 252; // command for fix (not selectable) values
COMMNOP = 253; // command not defined
COMMBACK = 254; // command for return of selection menu
COMMEXIT = 255; // command for close the menu window
LANGOFFSET = 15; // y-offset in bitmap for different languages
SATOFFSET = 15; // bitmap offset for saturation bar graph
SATMAXLOAD = 120; // max saturation overload [%] in bar graph
MAXDAYDIVE = 9; // max number of dives per day to display (1..9)
MAXLOGDIVE = 9999; // max number of dives in flash memory (1..9999)
MAXCATDIVE = 200; // max number of dives in dive catalog (1..200)
MAXCATPARS = 8; // number of parameter in dive catalog (0..7)
MAXLOGPOINT = 160; // max number of dive profile points (0..159)
MAXLOGPARS = 3; // number of profile parameter per point (0..2)
MAXDIVEDATA = 40; // number of dive data for log book (0..40)
LOGBLOCKPAR = 0; // block buffer for dive parameter
LOGBLOCKSET = 1; // block buffer for setting parameter
LOGPAGES = 4; // number of pages for dive log parameters
LOGHEADER = 4; // number of logged header lines
// LogType = lower byte of LogIdent (1st byte of a block)
LOGBAD = 0; // bad (unusable) block
LOGSTART = 1; // pre dive parameter
LOGINIT = 2; // initial dive point
LOGMAJOR = 3; // major dive parameter
LOGFAST = 4; // fast saturation parameter
LOGMINOR = 5; // minor dive parameter
LOGSLOW = 6; // slow saturation parameter
//reserved 8..9 // reserved for future use
LOGEND = 10; // post dive parameter
LOGGAS = 20; // breathing gas parameter
LOGNAV = 30; // navigation parameter
LOGSET = 40; // setting parameter
LOGERRORS = 14; // system error and status //nk// obsolete ??
LOGFREE = 15; // free (usable) block //nk// obsolete or 255
LOGTIMESTART = 1; // label of first time range
LOGTIMESCALE = 7; // time scale of 1st range = 1..7min
LOGTIMERANGE = 142; // number of time ranges from 7..994min
LOGDEPTHSTART = 2; // label of first depth range
LOGDEPTHSCALE = 10; // depth scale of 1st range = 2..10m
LOGDEPTHRANGE = 30; // number of depth ranges from 10..300m
//nk//LOGLINES = 6; // number of lines per page for dive parameters
SIMLINES = 7; // number of lines per page for dive simulation
DIVELINES = 10; // number of lines per page for dive data
CALENDARDIM = 37; // dim of calendar table [days]
LOGPORT = 1; // serial port for message logging = SER1
COMPORT = 1; // serial port for communication = SER1
//MESSAGELEN = 255; // max length of message buffer [char] //XE3//25.07.17 nk del
MESSAGELINES = 15; // max number of message lines
var // module variables
DatBuff: string; // modul message buffer //XE3//25.07.17 nk del MESSAGELEN
// global dive data declaration
//======================================
Head: string; // global message buffers //XE3//25.07.17 nk del MESSAGELEN ff
Body: string;
Tail: string;
WinSpec: array[0..MAXWIN, 0..WINDEF] of Byte;
BoxSpec: array[0..MAXBOX, 0..BOXDEF] of Byte;
ObjSpec: array[0..MAXOBJ, 0..OBJDEF] of Byte;
ObjTime: array[0..MAXOBJ] of Long;
GlobalSet: array[0..SETMENU, 0..SETBOX, 0..SETDEF] of Byte;
GlobalPar: array[0..SETPARS] of Word;
BaroPress: array[0..BAROHIST] of Word;
DiveCatalog: array[0..MAXCATDIVE, 0..MAXCATPARS] of Word;
DiveProfile: array[0..MAXLOGPOINT, 0..MAXLOGPARS] of Word;
DiveData: array[0..MAXDIVEDATA] of Word;
Pt: array[0..MAXCOMP] of Real; // inert gas pressure in tissues [mbar] for real time
Px: array[0..MAXCOMP] of Real; // inert gas pressure in tissues [mbar] for simulation
Rg: array[0..MAXCOMP] of Word; // relation Pt/Pg [%]
Rc: array[0..MAXCOMP] of Word; // relation Pa/Pc [%]
Kt: array[0..MAXCOMP] of Word; // tissue half times [min]
Ka: array[0..MAXCOMP] of Word; // Buehlmann parameter a [mbar]
Kb: array[0..MAXCOMP] of Word; // Buehlmann parameter b [-]
Op: array[0..OXPSTEP] of Word; // oxygen cns clock values [ppm/s]
//variable name type unit display unit remarks
//==============================================================================
DivePhase: Byte; // 0=none 1=init 3=interval 4=adaption 5=ready 6=predive 7=dive 8=postdive
RunMode: Byte; // 0=off 1=sleep 2=start 3=run 4=auto 5=user
WinPos1: Byte; // window pos top/left ---------
WinPos2: Byte; // window pos top/right | 1 | 2 |
WinPos3: Byte; // window pos bottom/left | 3 | 4 |
WinPos4: Byte; // window pos bottom/right ---------
WinPre3: Byte; // previous opend window at pos 3
WinPre4: Byte; // previous opend window at pos 4
InitFlag: Byte; // INIT=SYS initialized
InitDaq: Byte; // INIT=DAQ initialized
InitGui: Byte; // INIT=GUI initialized
SysCtr: Long;
DaqCtr: Long;
GuiCtr: Long;
ObjFlag: Byte; // OFF=no object to show
DebugFlag: Byte; // OFF=no debugging / ON=debugging
WaterFlag: Byte; // OFF=surface / ON=immersed
DiveFlag: Byte; // OFF=surface / ON=dived
DecoFlag: Byte; // OFF=no deco / ON=deco stop
TankFlag: Byte; // OFF=no tank data / ON=tank data available
SonarFlag: Byte; // OFF=no sonar / ON=sonar available
LiteFlag: Byte; // OFF=no backlite / ON=backlite on
PhaseFlag: Byte; // OFF=phase not changed / ON=phase has changed
SaveFlag: Byte; // OFF=no setting changed / ON=save settings
PlanFlag: Byte; // OFF=no dive planning / ON=dive planning mode
LogFlag: Byte; // OFF=dive log closed / ON=dive log open 09.05.07 nk add
StatusWord: Word; // - bit coded status and error flags 0..15
SigNum: Long; // -
BoxNum: Long; // -
DiveDayNum: Long; // - n dive number of day (1..9, 0=n/u) long!!
DiveLogNum: Word; // - nnnn total number of logged dives (1..9999)
StartTime: Long; // s hh:mm min absolute RTC time
EndTime: Long; // s hh:mm min absolute RTC time
DecoTime: Long; // s hh:mm min 9:59
NullTime: Long; // s hh:mm min 9:59
FlightTime: Long; // s hh:mm min 99:59
DesatTime: Long; // s hh:mm min 99:59
GasTime: Long; // s hh:mm min 99:59
AscentTime: Long; // s hh:mm min 99:59
TotalDecoTime: Long; // s
DirectTime: Long; // s
SystemTicks: Long; // ms
ScanTime: Long; // ms
RunTime: Long; // ms 07.06.07 nk add
InitTime: Long; // ms
DiveTime: Long; // ms hh:mm min 99:59
TotalDiveTime: Long; // ms hh:mm min 99:59
SurfaceTime: Long; // ms hh:mm min 99:59
LogTime: Long; // ms
LogStep: Byte; // - LOGSTART...LOGEND
LogSectors: Byte; // -
LogBlock: Word; // - number of dive data blocks
LogIdent: Word; // - log block identifier
LogWrite: Long; // - log start address in flash memory
DiveDepth: Long; // cm nn.n / nnn m / ft
MaxDepth: Long; // cm nn.n / nnn m / ft
DeltaDepth: Long; // cm
DecoDepth: Long; // cm nnn m / ft
InertPress: Long; // mbar
DecoCeil: Long; // mbar mbar=cm
AmbPress: Long; // mbar - mbar=cm
AirPress: Long; // mbar nnnn mbar=hPa
FillPress: Long; // mbar
TankPress: Long; // mbar nnn/nnnn bar / psi
LastPress: Long; // mbar tank pressure last measured
GasConsum: Long; // mbar nnn/nnnn bar / psi //nk// obsolete ??
TotalDecoGas: Long; // mbar
DiveSpeed: Long; // % +/-nnn % + = up / - = down
DesatRate: Byte; // % wird wo gesetzt //nk// zZ 100% const
DiverScore: Byte; // %
LeadTissue: Word; // %
BreathRate: Long; // mbar/s reduced to surface (1bar)
Altitude: Long; // m nnnnn m / ft above sea level
AmbTemp: Long; // cC -nnn.n °C / °F cC=1/100°C
AirTemp: Long; // cC -nnn.n °C / °F cC=1/100°C
WaterTemp: Long; // cC -nnn.n °C / °F cC=1/100°C
WaterSalt: Word; // ppt n.n %
WaterDens: Word; // g/dl 100mbar=1m (EN/DIN)
GasMix: Byte; // - n 0=Oxygen, 1=Air, 2..9=Mix Gases
OxFract: Word; // ppt
NiFract: Word; // ppt
HeFract: Word; // ppt
OxClock: Long; // ppm nnn %CNS
OxUnits: Long; // ppm nnn %OTU
OxDose: Long; // mOTU cumulated mOTU (100%=850 OTU)
OxPress: Long; // mbar
NiPress: Long; // mbar
HePress: Long; // mbar
SonarSignal: Word; // - sonar signal strength 0=bad..5=excellent
SoundSpeed: Word; // dm/s nnnn m/s / ft/s
HomeDist: Word; // dm nnnn m / yd
Heading: Word; // ddeg nnn °
Bearing: Word; // ddeg nnn °
WeekDay: Long; // - n 0=monday..6=sunday
AlarmTime: Long; // s - remaining time till alarm
AccuTime: Long; // s hh:mm min 99:59
AccuPower: Long; // % nnn remaining accu power
AccuRate: Long; // mV/s - have to be measured
SimDiveTime: Long; // ms
SimDiveDepth: Long; // cm
SimDecoTime: Long; // s
SimNullTime: Long; // s
SimDecoDepth: Long; // cm
SimDesatTime: Long; // s
SimFlightTime: Long; // s
SimDecoGas: Long; // mbar
SimAltitude: Long; // m
// PERSON SETTINGS
DiverAge: Byte; // -
DiverHeight: Word; // cm nnn m.cm / ft.in
DiverWeight: Word; // kg nnn kg / lb
DiverGender: Byte; // - A 0=male, 1=female
DiverGrade: Byte; // - n 1=basic...6=expert
DiverYears: Byte; // Y nn years diving
DiverSmoker: Byte; // - n 0=never, 1=sometimes, 2=often
DiverFitness: Byte; // - n 1=poor...6=excellent
// EQUIPMENT SETTINGS
TankSize: Byte; // l nnn l / hCuFt
// DIVE GASES SETTING
// LIMITS SETTINGS
WarnTemp: Word; // cC nn °C / °F
WarnBreath: Byte; // %
WarnDepth: Word; // cm nnn m / ft
WarnSpeed: Byte; // % nn % + 100
WarnTank: Word; // % nn %
WarnPower: Byte; // % nn %
WarnOxDose: Long; // ppm
WarnOxPress: Word; // mbar n.n bar
WarnNiPress: Word; // mbar n.n bar
WarnGas: Word; // s
AlarmSpeed: Byte; // % WarnSpeed + 20%
AlarmTank: Word; // % nn %
AlarmPower: Byte; // %
AlarmOxDose: Long; // ppm
AlarmOxPress: Word; // mbar WarnOxPress + 100mbar
AlarmGas: Word; // s
// PARAMETER SETTINGS
ActivDepth: Word; // cm nnn cm / ft
DecoStep: Word; // m nn m / ft
SafetyTime: Long; // s mm min
DeepFlag: Byte; // 0=OFF / 1=ON deep deco stops
DepthFlag: Byte; // 0=OFF / 1=TRUE depth calculation
DiveRepTime: Long; // ms mm min
AutoOffTime: Long; // s mm min
LogInterval: Long; // ms nn s
IntervalTime: Long; // ms hh:mm min
// DISPLAY SETTINGS
LangFlag: Byte; // 0=EN 1=DE 2=FR 3=IT
UnitFlag: Byte; // OFF=metrical (SI) / ON=imperial
TimeFlag: Byte; // 0=EU / 1=US / 2=ISO time format
SutiFlag: Byte; // 0=NO / 1=EU / 2=US summer time
Brightness: Byte; // %
Contrast: Byte; // %
Backlight: Byte; // s
Loudness: Byte; // %
// CLOCK SETTINGS
RealYear: Long; // real date
RealMonth: Long;
RealDay: Long;
RealHour: Long; // real time
RealMin: Long;
AlarmHour: Long; // alarm time
AlarmMin: Long;
AlarmSet: Byte; // alarm activated
RealSec: Long;
implementation
uses
SYS, FMain, FLog, FGui, FDaq, FTrack, FProfile, FPlan, Clock, Texts;
//------------------------------------------------------------------------------
// INITGLOBALDATA - Initialize global data with default values
//------------------------------------------------------------------ 17.02.07 --
procedure InitGlobalData;
var
i, j, k: Word;
begin
Head := sEMPTY; // clear global text buffers
Body := sEMPTY;
Tail := sEMPTY;
DivePhase := PHASEINITIAL; // initial phase
RunMode := MODERUN; // run mode
WinPos1 := WINBARO;
WinPos2 := WINCLOCK;
WinPos3 := WINPOWER;
WinPos4 := WINDECO;
WinPre3 := WINPOWER;
WinPre4 := WINDECO;
SysCtr := cCLEAR;
DaqCtr := cCLEAR;
GuiCtr := cCLEAR;
InitFlag := cOFF; // OFF (not initialized)
InitDaq := cOFF; // OFF (not initialized)
InitGui := cOFF; // OFF (not initialized)
ObjFlag := cOFF; // OFF (no object to show)
DebugFlag := cOFF; // OFF (no debugging)
WaterFlag := cOFF; // OFF (not immersed)
DiveFlag := cOFF; // OFF (not dived)
DecoFlag := cOFF; // OFF (no deco)
TankFlag := cOFF; // OFF (no tank data)
SonarFlag := cOFF; // OFF (no sonar navigation)
LiteFlag := cOFF; // OFF (no backlite)
PhaseFlag := cOFF; // OFF (phase not changed)
SaveFlag := cOFF; // OFF (nothing to save)
PlanFlag := cOFF; // OFF (no dive planning)
LogFlag := cOFF; // OFF (dive log closed)
StatusWord := cCLEAR; // initial status / no errors
SigNum := SIGNONE; // object signal number
BoxNum := cCLEAR;
DiveDayNum := cCLEAR; // daily dive counter 1..MAXDAYDIVE (0=no dives)
DiveLogNum := cCLEAR; // total dive counter 1..MAXLOGDIVE
StartTime := cCLEAR;
EndTime := cCLEAR;
DecoTime := cCLEAR;
NullTime := TIMERANGE; // 9h59m
FlightTime := TIMEDISP; // 99h59m
DesatTime := TIMEDISP; // 99h59m
GasTime := TIMEDISP; // 99h59m
AscentTime := cCLEAR;
DirectTime := cCLEAR;
TotalDecoTime := cCLEAR;
SystemTicks := cCLEAR;
ScanTime := cCLEAR;
RunTime := cCLEAR;
InitTime := cCLEAR;
DiveTime := cCLEAR;
TotalDiveTime := cCLEAR;
SurfaceTime := cCLEAR;
LogTime := cCLEAR;
LogStep := cCLEAR;
LogSectors := cCLEAR;
LogBlock := cCLEAR;
LogIdent := cCLEAR;
LogWrite := cCLEAR;
DiveDepth := cCLEAR;
MaxDepth := cCLEAR;
DeltaDepth := cCLEAR;
DecoDepth := cCLEAR;
DecoCeil := cCLEAR;
InertPress := ISOSAT; // 750mbar
AmbPress := ISOPRESS; // 1013mbar (initial pressure)
AirPress := ISOPRESS; // 1013mbar (standard sea level)
FillPress := cCLEAR;
TankPress := cCLEAR;
LastPress := cCLEAR;
GasConsum := cCLEAR;
TotalDecoGas := cCLEAR;
DiveSpeed := cCLEAR;
DesatRate := PROCENT; // 100%
DiverScore := PROCENT; // 100%
LeadTissue := cCLEAR;
BreathRate := cCLEAR; // 0mbar/s
Altitude := cCLEAR; // 0m (sea level)
AmbTemp := ISOTEMP; // 1500cC = 15°C
AirTemp := ISOTEMP; // 1500cC = 15°C
WaterTemp := ISOTEMP; // 1500cC = 15°C
WaterSalt := cCLEAR; // 0ppt (fresh water)
WaterDens := ISODENS; // 100mbar = 1m (EN/DIN)
SoundSpeed := ISOSPEED; // 15067dm/s = 1506.7m/s
SonarSignal := cCLEAR; // 0=bad..5=excellent
HomeDist := cCLEAR;
Heading := cCLEAR;
Bearing := cCLEAR;
GasMix := 1; // 0=Oxygen, 1=Air, 2..9=Mix gases
OxClock := cCLEAR; // CNS% cumulated
OxUnits := cCLEAR; // OTU% rel 850
OxDose := cCLEAR; // cumulated mOTU (100%=850 OTU)
OxFract := FOXYGEN; // fraction of oxygen in air = 21%
NiFract := FNITROGEN; // fraction of nitrogen in air = 79%
HeFract := FHELIUM; // fraction of helium in air = 1%
OxPress := FOXYGEN; // oxygen partial pressure = 210mbar
NiPress := FNITROGEN; // nitrogen partial pressure = 790mbar
HePress := FHELIUM; // helium partial pressure = 10mbar
WeekDay := cCLEAR;
AlarmTime := cCLEAR;
AccuTime := cCLEAR;
AccuPower := cFULL;
SimDiveTime := cCLEAR;
SimDiveDepth := cCLEAR;
SimDecoTime := cCLEAR;
SimDecoDepth := cCLEAR;
SimNullTime := cCLEAR;
SimDesatTime := cCLEAR;
SimFlightTime := cCLEAR;
SimDecoGas := cCLEAR;
// PERSON SETTINGS
DiverAge := 30;
DiverHeight := 178; // 178cm=70in=5.84ft=5ft10in
DiverWeight := 73; // 73kg=161lb
DiverGender := 0; // 0=male
DiverGrade := 2; // 2=open water
DiverYears := 2; // 2 years diving
DiverSmoker := 0; // 0=never
DiverFitness := 3; // 3=moderate
// EQUIPMENT SETTINGS
TankSize := 20; // 20l
// DIVE GASES SETTINGS
// LIMITS SETTINGS
WarnTemp := 1000; // [cC] 10°C
WarnBreath := 120; // [%] 120%
WarnDepth := 3900; // [cm] 39m
WarnSpeed := 120; // [%] 120%
WarnTank := 50; // [%] 50%
WarnPower := 25; // [%] 25%
WarnOxDose := 750000; // [ppm] 75%
WarnOxPress := 1400; // [mbar] 1.4bar
WarnNiPress := 4000; // [mbar] 4.0bar
WarnGas := 120; // [s] 2min
AlarmSpeed := WarnSpeed + 20; // [%] +20%
AlarmTank := 20; // [%] 20%
AlarmPower := 10; // [%] 10%
AlarmOxDose := 950000; // [ppm] 95%
AlarmOxPress := WarnOxPress + 100; // [mbar] 1.5bar
AlarmGas := 60; // [s] 1min
// PARAMETER SETTINGS
ActivDepth := 60; // 60cm
DecoStep := 3; // 3m
SafetyTime := 3; // 3min
DeepFlag := cOFF; // OFF (no deep deco stops)
DepthFlag := cOFF; // OFF (norm depth calculation)
DiveRepTime := 300000; // 5min
AutoOffTime := 1800; // 30min
LogInterval := 10000; // 10s
IntervalTime := DiveRepTime;
// DISPLAY SETTINGS
LangFlag := cOFF; // EN (english language)
UnitFlag := cOFF; // MET (metrical unit system)
TimeFlag := cOFF; // EU (european time format)
SutiFlag := cOFF; // OFF (no summer time)
Brightness := 90; // 90%
Contrast := 80; // 80%
Backlight := 5; // 5s
Loudness := 70; // 70%
// CLOCK SETTINGS
RealYear := cCLEAR;
RealMonth := cCLEAR;
RealDay := cCLEAR;
RealHour := cCLEAR;
RealMin := cCLEAR;
AlarmHour := cCLEAR;
AlarmMin := cCLEAR;
AlarmSet := cOFF; // alarm not set
RealSec := cCLEAR;
for i := 0 to MAXOBJ - 1 do begin
ObjTime[i] := cCLEAR; // clear object time array
end;
BaroPress[0] := cCLEAR;
for i := 1 to BAROHIST do begin
BaroPress[i] := ISOPRESS; // init barometer history array
end;
for i := 0 to SETMENU - 1 do begin // clear global settings
for j := 0 to SETBOX - 1 do begin
for k := 0 to SETDEF - 1 do begin
GlobalSet[i, j, k] := cCLEAR;
end;
end;
end;
for i := 0 to MAXCATDIVE - 1 do begin // init dive catalog array
for j := 0 to MAXCATPARS - 1 do begin
DiveCatalog[i, j] := cCLEAR;
end;
end;
for i := 0 to MAXLOGPOINT - 1 do begin // init dive profile array
for j := 0 to MAXLOGPARS - 1 do begin
DiveProfile[i, j] := cCLEAR;
end;
end;
for i := 0 to MAXCOMP - 1 do begin
Pt[i] := ISOSAT; // compartment saturation [mbar] at sea level
Px[i] := ISOSAT; // Pt = fNi*(Pb-Pv) = 0.79*(1013-63) = 750mbar
Rg[i] := PROCENT;
Rc[i] := cCLEAR;
end;
Kt[0] := 20; // compartment half times/10 [min]
Kt[1] := 40;
Kt[2] := 80;
Kt[3] := 125;
Kt[4] := 185;
Kt[5] := 270;
Kt[6] := 383;
Kt[7] := 543;
Kt[8] := 770;
Kt[9] := 1090;
Kt[10] := 1460;
Kt[11] := 1870;
Kt[12] := 2390;
Kt[13] := 3050;
Kt[14] := 3900;
Kt[15] := 4980;
Kt[16] := 6350;
Ka[0] := 3000; // compartment parameter a/10 [mbar]
Ka[1] := 12599;
Ka[2] := 10000;
Ka[3] := 8618;
Ka[4] := 7562;
Ka[5] := 6200;
Ka[6] := 5043;
Ka[7] := 4410;
Ka[8] := 4000;
Ka[9] := 3750;
Ka[10] := 3500;
Ka[11] := 3295;
Ka[12] := 3065;
Ka[13] := 2835;
Ka[14] := 2610;
Ka[15] := 2480;
Ka[16] := 2327;
Kb[0] := 8300; // compartment parameter b/10000
Kb[1] := 5050;
Kb[2] := 6514;
Kb[3] := 7222;
Kb[4] := 7825;
Kb[5] := 8126;
Kb[6] := 8434;
Kb[7] := 8693;
Kb[8] := 8910;
Kb[9] := 9092;
Kb[10] := 9222;
Kb[11] := 9319;
Kb[12] := 9403;
Kb[13] := 9477;
Kb[14] := 9544;
Kb[15] := 9602;
Kb[16] := 9653;
// NOAA [ppm/s] [bar] [%/min]
//------------------------------------
Op[0] := 0; // 0.5 0.00 oxygen cns clock
Op[1] := 24; // 0.6 0.14 1%/min = 167ppm/s
Op[2] := 29; // 0.7 0.17 (1ata = 1bar)
Op[3] := 37; // 0.8 0.22
Op[4] := 47; // 0.9 0.28
Op[5] := 55; // 1.0 0.33
Op[6] := 70; // 1.1 0.42
Op[7] := 80; // 1.2 0.48
Op[8] := 92; // 1.3 0.55
Op[9] := 112; // 1.4 0.67
Op[10] := 139; // 1.5 0.83
Op[11] := 370; // 1.6 2.22
Op[12] := 477; // 1.7 2.86
Op[13] := 667; // 1.8 4.00
Op[14] := 1112; // 1.9 6.67
Op[15] := 1667; // 2.0 10.0
Op[16] := 3334; // 2.1 20.0
Op[17] := 16667; // 2.2 100.0
AddGlobalPar(cCLEAR); // clear setting parameter list
GlobalSet[0, 0, 0] := COMMEXIT; // MAIN SELECTION (command number = exit)
GlobalSet[0, 0, 1] := 11; // arrow symbol
GlobalSet[0, 0, 2] := 16; // pointer symbol
GlobalSet[0, 0, 3] := 0;
GlobalSet[0, 0, 4] := 0; // 1st text number (pointer to Mask$)
GlobalSet[0, 1, 0] := 1; // NAVIGATION (command number)
GlobalSet[0, 1, 1] := 0;
GlobalSet[0, 1, 2] := 0;
GlobalSet[0, 1, 3] := 0;
GlobalSet[0, 1, 4] := 0;
GlobalSet[0, 2, 0] := 2; // SATURATION (command number)
GlobalSet[0, 2, 1] := 0;
GlobalSet[0, 2, 2] := 0;
GlobalSet[0, 2, 3] := 0;
GlobalSet[0, 2, 4] := 0;
GlobalSet[0, 3, 0] := 3; // GAS SELECTION (command number)
GlobalSet[0, 3, 1] := 0;
GlobalSet[0, 3, 2] := 0;
GlobalSet[0, 3, 3] := 0;
GlobalSet[0, 3, 4] := 0;
// 03.06.07 nk change pos 4 and 5
GlobalSet[0, 4, 0] := 4; // SETTINGS (command number)
GlobalSet[0, 4, 1] := 0;
GlobalSet[0, 4, 2] := 0;
GlobalSet[0, 4, 3] := 0;
GlobalSet[0, 4, 4] := 0;
GlobalSet[0, 5, 0] := 5; // SERVICES (command number)
GlobalSet[0, 5, 1] := 0;
GlobalSet[0, 5, 2] := 0;
GlobalSet[0, 5, 3] := 0;
GlobalSet[0, 5, 4] := 9; // 9=hide selection while diving
GlobalSet[0, 6, 0] := 6; // COLD START (command number)
GlobalSet[0, 6, 1] := 0;
GlobalSet[0, 6, 2] := 0;
GlobalSet[0, 6, 3] := 0;
GlobalSet[0, 6, 4] := 9; // 9=hide selection while diving
GlobalSet[0, 7, 0] := 7; // SLEEP MODE (command number)
GlobalSet[0, 7, 1] := 0;
GlobalSet[0, 7, 2] := 0;
GlobalSet[0, 7, 3] := 0;
GlobalSet[0, 7, 4] := 9; // 9=hide selection while diving
GlobalSet[0, 8, 0] := 8; // SHUT DOWN (command number)
GlobalSet[0, 8, 1] := 0;
GlobalSet[0, 8, 2] := 0;
GlobalSet[0, 8, 3] := 0;
GlobalSet[0, 8, 4] := 9; // 9=hide selection while diving
GlobalSet[0, 9, 0] := COMMEXIT; // CLOSE (command number = exit)
GlobalSet[0, 9, 1] := 12; // arrow symbol
GlobalSet[0, 9, 2] := 0;
GlobalSet[0, 9, 3] := 0;
GlobalSet[0, 9, 4] := 0;
GlobalSet[1, 0, 0] := COMMBACK; // GAS SELECTION (command number = return)
GlobalSet[1, 0, 1] := 11; // arrow symbol
GlobalSet[1, 0, 2] := 16; // pointer symbol
GlobalSet[1, 0, 3] := 0;
GlobalSet[1, 0, 4] := 10; // 1st text number (pointer to Mask$)
GlobalSet[1, 1, 0] := 11; // GAS #1 (command number)
GlobalSet[1, 1, 1] := 0;
GlobalSet[1, 1, 2] := 0;
GlobalSet[1, 1, 3] := 0;
GlobalSet[1, 1, 4] := 0;
GlobalSet[1, 2, 0] := 12; // GAS #2 (command number)
GlobalSet[1, 2, 1] := 0;
GlobalSet[1, 2, 2] := 0;
GlobalSet[1, 2, 3] := 0;
GlobalSet[1, 2, 4] := 0;
GlobalSet[1, 3, 0] := 13; // GAS #3 (command number)
GlobalSet[1, 3, 1] := 0;
GlobalSet[1, 3, 2] := 0;
GlobalSet[1, 3, 3] := 0;
GlobalSet[1, 3, 4] := 0;
GlobalSet[1, 4, 0] := 14; // GAS #4 (command number)
GlobalSet[1, 4, 1] := 0;
GlobalSet[1, 4, 2] := 0;
GlobalSet[1, 4, 3] := 0;
GlobalSet[1, 4, 4] := 0;
GlobalSet[1, 5, 0] := 15; // GAS #5 (command number)
GlobalSet[1, 5, 1] := 0;
GlobalSet[1, 5, 2] := 0;
GlobalSet[1, 5, 3] := 0;
GlobalSet[1, 5, 4] := 0;
GlobalSet[1, 6, 0] := 16; // GAS #6 (command number)
GlobalSet[1, 6, 1] := 0;
GlobalSet[1, 6, 2] := 0;
GlobalSet[1, 6, 3] := 0;
GlobalSet[1, 6, 4] := 0;
GlobalSet[1, 7, 0] := 17; // GAS #7 (command number)
GlobalSet[1, 7, 1] := 0;
GlobalSet[1, 7, 2] := 0;
GlobalSet[1, 7, 3] := 0;
GlobalSet[1, 7, 4] := 0;
GlobalSet[1, 8, 0] := 18; // GAS #8 (command number)
GlobalSet[1, 8, 1] := 0;
GlobalSet[1, 8, 2] := 0;
GlobalSet[1, 8, 3] := 0;
GlobalSet[1, 8, 4] := 0;
GlobalSet[1, 9, 0] := COMMEXIT; // CLOSE (command number = exit)
GlobalSet[1, 9, 1] := 12; // arrow symbol