line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
####################################### |
2
|
|
|
|
|
|
|
# Module : Deco::Dive::Table.pm |
3
|
|
|
|
|
|
|
# Author : Jaap Voets |
4
|
|
|
|
|
|
|
# Date : 10-10-2006 |
5
|
|
|
|
|
|
|
####################################### |
6
|
|
|
|
|
|
|
package Deco::Dive::Table; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
880
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
10
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use constant INITIAL_NODECO => 1000000; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1116
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Constructor |
17
|
|
|
|
|
|
|
sub new { |
18
|
2
|
|
|
2
|
1
|
765
|
my $class = shift; |
19
|
2
|
|
|
|
|
3
|
my $dive = shift; |
20
|
|
|
|
|
|
|
|
21
|
2
|
100
|
|
|
|
27
|
croak "Please provide a Deco::Dive object for plotting" unless ref($dive) eq 'Deco::Dive'; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
my $self = { dive => $dive }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# depth in meters, we will use these for the table |
26
|
|
|
|
|
|
|
# can be overridden by ->setdepths |
27
|
1
|
|
|
|
|
4
|
$self->{depths} = [10, 12, 14, 16, 18, 20, 24, 27, 30, 33, 36, 40, 42, 45, 50]; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# the controlling tissue |
30
|
1
|
|
|
|
|
2
|
$self->{controlling_tissue} = undef; |
31
|
1
|
|
|
|
|
2
|
$self->{excess_pressure_step_size} = 0.05; # in bar, which is 1/2 meter |
32
|
1
|
|
|
|
|
2
|
$self->{start_pressure} = undef; |
33
|
1
|
|
|
|
|
2
|
$self->{end_pressure} = undef; |
34
|
|
|
|
|
|
|
# place to store our numbers |
35
|
1
|
|
|
|
|
2
|
$self->{nodeco_table} = undef; |
36
|
1
|
|
|
|
|
2
|
$self->{table} = undef; |
37
|
1
|
|
|
|
|
2
|
bless $self, $class; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
3
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# what tissue controls the repetitive group behaviour? |
43
|
|
|
|
|
|
|
sub controlling_tissue { |
44
|
3
|
|
|
3
|
1
|
1296
|
my $self = shift; |
45
|
3
|
|
|
|
|
4
|
my $tissue_num = shift; |
46
|
|
|
|
|
|
|
|
47
|
3
|
100
|
|
|
|
10
|
if (defined $tissue_num) { |
48
|
|
|
|
|
|
|
# we want to set the tissue |
49
|
2
|
|
|
|
|
4
|
my $found = 0; |
50
|
|
|
|
|
|
|
# check if it really exists |
51
|
2
|
|
|
|
|
4
|
foreach my $tissue ( @{ $self->{dive}->{tissues} } ) { |
|
2
|
|
|
|
|
9
|
|
52
|
17
|
100
|
|
|
|
35
|
next if ! defined $tissue; |
53
|
15
|
100
|
|
|
|
39
|
if ( $tissue->nr() == $tissue_num ) { |
54
|
1
|
|
|
|
|
2
|
$found = 1; |
55
|
1
|
|
|
|
|
4
|
$self->{start_pressure} = 1; # shall we do 1 bar, or topside pressure? |
56
|
1
|
|
|
|
|
6
|
$self->{end_pressure} = $tissue->M( depth => 0 ); # get the allowed surfacing tension |
57
|
1
|
|
|
|
|
3
|
$self->{controlling_tissue} = $tissue; |
58
|
1
|
|
|
|
|
2
|
last; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
100
|
|
|
|
32
|
croak "The tissue number $tissue_num is not valid" unless $found; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
# if the tissue was not set before, croak if someone want to retrieve it |
65
|
2
|
50
|
|
|
|
7
|
croak "No controlling tissue set" unless ref($self->{controlling_tissue}) eq 'Deco::Tissue'; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
5
|
return $self->{controlling_tissue}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# set / get the pressure step size used for each group |
71
|
|
|
|
|
|
|
sub pressure_step { |
72
|
24
|
|
|
24
|
1
|
24
|
my $self = shift; |
73
|
24
|
|
|
|
|
25
|
my $stepsize = shift; |
74
|
|
|
|
|
|
|
|
75
|
24
|
50
|
|
|
|
43
|
if (defined $stepsize) { |
76
|
0
|
0
|
|
|
|
0
|
croak "Provide a step size in bar " unless ($stepsize =~ /^\d+\.?\d*/); |
77
|
0
|
|
|
|
|
0
|
$self->{excess_pressure_step_size} = $stepsize; |
78
|
|
|
|
|
|
|
} |
79
|
24
|
|
|
|
|
74
|
return $self->{excess_pressure_step_size}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# set the depths for the table you want |
83
|
|
|
|
|
|
|
sub setdepths { |
84
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
85
|
0
|
|
|
|
|
0
|
$self->{depths} = \@_; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# calculate the no-stop times |
89
|
|
|
|
|
|
|
sub _calculate_nostop { |
90
|
1
|
|
|
1
|
|
612
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
1
|
foreach my $depth ( @{ $self->{depths} } ) { |
|
1
|
|
|
|
|
7
|
|
93
|
15
|
|
|
|
|
32
|
my $nodeco_min = INITIAL_NODECO; |
94
|
15
|
|
|
|
|
19
|
foreach my $tissue ( @{ $self->{dive}->{tissues} } ) { |
|
15
|
|
|
|
|
60
|
|
95
|
150
|
100
|
|
|
|
323
|
next if ! defined $tissue; # first array element is empty |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# we go instantly to the depth and ask for the no_deco time |
98
|
135
|
|
|
|
|
390
|
$tissue->point( 0, $depth ); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# we like to have |
101
|
|
|
|
|
|
|
# no_deco time, is special, it can return - for not applicable |
102
|
135
|
|
|
|
|
372
|
my $nodeco = $tissue->nodeco_time(); |
103
|
135
|
100
|
|
|
|
404
|
$nodeco = undef if $nodeco eq '-'; |
104
|
|
|
|
|
|
|
|
105
|
135
|
100
|
|
|
|
431
|
if ($nodeco) { |
106
|
108
|
100
|
|
|
|
466
|
if ($nodeco < $nodeco_min) { |
107
|
19
|
|
|
|
|
52
|
$nodeco_min = int($nodeco); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
15
|
50
|
|
|
|
40
|
if ($nodeco_min == INITIAL_NODECO) { |
112
|
0
|
|
|
|
|
0
|
my $nodeco_min = '-'; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
15
|
|
|
|
|
71
|
$self->{nodeco_table}->{$depth} = $nodeco_min; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# calculate the table with repetive groups |
122
|
|
|
|
|
|
|
sub calculate { |
123
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
2
|
my $tissue = $self->controlling_tissue(); |
126
|
1
|
|
|
|
|
2
|
my %groups; |
127
|
1
|
|
|
|
|
3
|
my $num = 65; # ascii for A |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# fill the pressure groups |
130
|
1
|
|
|
|
|
5
|
for (my $pressure = $self->{start_pressure}; $pressure <= $self->{end_pressure}; |
131
|
|
|
|
|
|
|
$pressure += $self->pressure_step() ) { |
132
|
24
|
|
|
|
|
31
|
my $letter = chr($num); |
133
|
24
|
|
|
|
|
56
|
$groups{$letter} = $pressure; |
134
|
24
|
|
|
|
|
46
|
$num++; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
# save the group letters |
138
|
1
|
|
|
|
|
5
|
$self->{groups} = \%groups; |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
3
|
foreach my $depth ( @{ $self->{depths} } ) { |
|
1
|
|
|
|
|
3
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# we go instantly to the depth and ask for the time_until_pressure |
143
|
15
|
|
|
|
|
44
|
$tissue->point( 0, $depth ); |
144
|
15
|
|
|
|
|
63
|
foreach my $letter ( keys %groups ) { |
145
|
|
|
|
|
|
|
|
146
|
360
|
|
|
|
|
959
|
my $time_until = $tissue->time_until_pressure( pressure => $groups{$letter} ); |
147
|
360
|
100
|
|
|
|
685
|
if ($time_until ne '-') { |
148
|
325
|
|
|
|
|
542
|
$time_until = sprintf('%.0f', $time_until); |
149
|
|
|
|
|
|
|
} |
150
|
360
|
|
|
|
|
983
|
$self->{table}->{$letter}->{$depth} = $time_until; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# generate the output of the table calculation |
156
|
|
|
|
|
|
|
# this will return a string containing the entire table |
157
|
|
|
|
|
|
|
sub output { |
158
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
159
|
1
|
|
|
|
|
2
|
my $output = 'Group: '; |
160
|
|
|
|
|
|
|
|
161
|
1
|
|
|
|
|
2
|
my %groups = %{ $self->{groups} }; |
|
1
|
|
|
|
|
14
|
|
162
|
1
|
|
|
|
|
3
|
foreach my $depth ( @{ $self->{depths} } ){ |
|
1
|
|
|
|
|
3
|
|
163
|
15
|
|
|
|
|
17
|
$output .= $depth . " |"; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
14
|
foreach my $letter ( sort keys %groups ) { |
167
|
24
|
|
|
|
|
44
|
$output .= "$letter :"; |
168
|
24
|
|
|
|
|
22
|
foreach my $depth ( @{ $self->{depths} } ){ |
|
24
|
|
|
|
|
31
|
|
169
|
360
|
|
|
|
|
494
|
$output .= $self->{table}->{$letter}->{$depth} . " |"; |
170
|
|
|
|
|
|
|
} |
171
|
24
|
|
|
|
|
28
|
$output .= "\n"; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
1
|
|
|
|
|
14
|
return $output; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# output the list of no-stop times |
178
|
|
|
|
|
|
|
sub no_stop { |
179
|
2
|
|
|
2
|
1
|
543
|
my $self = shift; |
180
|
2
|
|
|
|
|
6
|
my %opt = @_; |
181
|
|
|
|
|
|
|
|
182
|
2
|
|
|
|
|
5
|
my $template = $opt{'template'}; |
183
|
2
|
100
|
|
|
|
6
|
if (! $template ) { |
184
|
1
|
|
|
|
|
2
|
$template = "No Decompression limit #DEPTH#: #TIME#\n"; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
2
|
|
|
|
|
4
|
my $output = ''; |
188
|
|
|
|
|
|
|
|
189
|
2
|
|
|
|
|
3
|
foreach my $depth ( @{ $self->{depths} }) { |
|
2
|
|
|
|
|
6
|
|
190
|
30
|
|
|
|
|
39
|
my $row = $template; |
191
|
30
|
|
|
|
|
107
|
$row =~ s/#DEPTH#/$depth/gi; |
192
|
30
|
|
|
|
|
290
|
$row =~ s/#TIME#/$self->{nodeco_table}->{$depth}/gi; |
193
|
30
|
|
|
|
|
62
|
$output .= $row; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
2
|
|
|
|
|
9
|
return $output; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
__END__ |