lib/App/SeismicUnixGui/specs/header/setbhed_spec.pm untested

filter: Statementstmt 0.0% 0 / 140 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 185 CC 8 SCAR 14.4
CC
8
Cov
0%
get_binding_index_aref
6.0
get_binding_length
6.0
get_file_dialog_type_aref
6.0
CRAP 4.2
1 package App::SeismicUnixGui::specs::header::setbhed_spec;
2 use Moose;
3 our $VERSION = '0.0.1';
4  
5 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
6 use App::SeismicUnixGui::misc::SeismicUnix qw($bin $su $suffix_bin $suffix_sgy $suffix_su $suffix_txt $txt);
7 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
8 use aliased 'App::SeismicUnixGui::sunix::header::setbhed';
9 my $get = L_SU_global_constants->new();
10 my $Project = Project_config->new();
11 my $setbhed = setbhed->new();
12  
13 my $var = $get->var();
14  
15 my $empty_string = $var->{_empty_string};
16 my $true = $var->{_true};
17 my $false = $var->{_false};
18 my $file_dialog_type = $get->file_dialog_type_href();
19 my $flow_type = $get->flow_type_href();
20  
21 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
22 my $DATA_SEISMIC_SEGY = $Project->DATA_SEISMIC_SEGY(); # input data directory
23 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
24 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
25 my $PL_SEISMIC = $Project->PL_SEISMIC();
26 my $max_index = 6;
27  
28 my $setbhed_spec = {
29 _CONFIG => $PL_SEISMIC,
30 _DATA_DIR_IN => $DATA_SEISMIC_BIN,
31 _DATA_DIR_OUT => $DATA_SEISMIC_BIN,
32 _binding_index_aref => '',
33 _suffix_type_in => $su,
34 _data_suffix_in => $suffix_bin,
35 _suffix_type_out => $su,
36 _data_suffix_out => $suffix_bin,
37 _file_dialog_type_aref => '',
38 _flow_type_aref => '',
39 _has_infile => $true,
40 _has_outpar => $false,
41 _has_pipe_in => $false,
42 _has_pipe_out => $true,
43 _has_redirect_in => $true,
44 _has_redirect_out => $true,
45 _has_subin_in => $false,
46 _has_subin_out => $false,
47 _is_data => $false,
48 _is_first_of_2 => $true,
49 _is_first_of_3or_more => $true,
50 _is_first_of_4or_more => $true,
51 _is_last_of_2 => $false,
52 _is_last_of_3or_more => $false,
53 _is_last_of_4or_more => $false,
54 _is_suprog => $true,
55 _is_superflow => $false,
56 _max_index => $max_index,
57 _prefix_aref => '',
58 _suffix_aref => '',
59 };
60  
61  
62 =head2 sub binding_index_aref
63  
64 =cut
65  
66 sub binding_index_aref {
67  
68 my $self = @_;
69  
70 my @index;
71  
72 # first binding index (0)
73 # connects to second item (1)
74 # in the parameter list
75 $index[0] = 0; # outbound item is bound to _DATA_SEISMIC_BIN
76 $index[1] = 5; # inbound item is bound to _DATA_DIR_TXT
77  
78 $setbhed_spec ->{_binding_index_aref} = \@index;
79 return();
80  
81 }
82  
83  
84 =head2 sub file_dialog_type_aref
85  
86 type of dialog (Data, Flow, SaveAs) is needed by binding
87 one type of dialog for each index
88 =cut
89  
90 sub file_dialog_type_aref {
91  
92 my $self = @_;
93  
94 my @type;
95  
96 # bound index will look for data
97 $type[0] = $file_dialog_type->{_Data};
98 $type[1] = $file_dialog_type->{_Data};
99  
100 $setbhed_spec ->{_file_dialog_type_aref} = \@type;
101 return();
102  
103 }
104  
105  
106 =head2 sub flow_type_aref
107  
108 =cut
109  
110 sub flow_type_aref {
111  
112 my $self = @_;
113  
114 my @type;
115  
116 $type[0] = $flow_type->{_user_built};
117  
118 $setbhed_spec ->{_flow_type_aref} = \@type;
119 return();
120  
121 }
122  
123  
124 =head2 sub get_binding_index_aref
125  
126 =cut
127  
128 sub get_binding_index_aref{
129  
130 my $self = @_;
131 my @index;
132  
133 if ($setbhed_spec->{_binding_index_aref} ) {
134  
135 my $index_aref = $setbhed_spec->{_binding_index_aref};
136 return($index_aref);
137  
138 } else {
139 print("setbhed_spec, get_binding_index_aref, missing binding_index_aref\n");
140 return();
141 }
142  
143 my $index_aref = $setbhed_spec->{_binding_index_aref};
144 }
145  
146  
147 =head2 sub get_binding_length
148  
149 =cut
150  
151 sub get_binding_length{
152  
153 my $self = @_;
154  
155 if ($setbhed_spec->{_binding_index_aref} ) {
156  
157 my $binding_length= scalar @{$setbhed_spec->{_binding_index_aref}};
158 return($binding_length);
159  
160 } else {
161 print("setbhed_spec, get_binding_length, missing binding_length\n");
162 return();
163 }
164  
165 return();
166 }
167  
168  
169 =head2 sub get_file_dialog_type_aref
170  
171 =cut
172  
173 sub get_file_dialog_type_aref{
174  
175 my $self = @_;
176 if ($setbhed_spec->{_file_dialog_type_aref} ) {
177  
178 my $index_aref = $setbhed_spec->{_file_dialog_type_aref};
179 return($index_aref);
180  
181 } else {
182 print("setbhed_spec, get_file_dialog_type_aref, missing get_file_dialog_type_aref\n");
183 return();
184 }
185  
186 return();
187 }
188  
189  
190 =head2 sub get_flow_type_aref
191  
192 =cut
193  
194 sub get_flow_type_aref {
195  
196 my $self = @_;
197  
198 if ($setbhed_spec->{_flow_type_aref} ) {
199  
200 my $index_aref = $setbhed_spec->{_flow_type_aref};
201 return($index_aref);
202  
203 } else {
204 print("setbhed_spec, get_flow_type_aref, missing flow_type_aref\n");
205 return();
206 }
207  
208 }
209  
210  
211 =head2 sub get_incompatibles
212  
213 =cut
214  
215 sub get_incompatibles{
216  
217 my $self = @_;
218 my @needed;
219  
220 my @_need_both;
221  
222 my @_need_only_1;
223  
224 my @_none_needed;
225  
226 my @_all_needed;
227  
228 my $params = {
229  
230 _need_both => \@_need_both,
231 _need_only_1 => \@_need_only_1,
232 _none_needed => \@_none_needed,
233 _all_needed => \@_all_needed,
234  
235 };
236  
237 my @of_two = ('xx','yy');
238 push @{$params->{_need_only_1}} , \@of_two;
239  
240 my $len_1_needed = scalar @{$params->{_need_only_1}};
241  
242 if ($len_1_needed >= 1) {
243  
244 for (my $i=0; $i < $len_1_needed; $i++) {
245  
246 print("setbhed, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n");
247  
248 }
249  
250 } else {
251 print("get_incompatibles, no incompatibles\n")
252 }
253  
254 return($params);
255  
256 }
257  
258  
259 =head2 sub get_prefix_aref
260  
261 =cut
262  
263 sub get_prefix_aref {
264  
265 my $self = @_;
266  
267 if ($setbhed_spec->{_prefix_aref} ) {
268  
269 my $prefix_aref= $setbhed_spec->{_prefix_aref};
270 return($prefix_aref);
271  
272 } else {
273 print("setbhed_spec, get_prefix_aref, missing prefix_aref\n");
274 return();
275 }
276  
277 return();
278 }
279  
280  
281 =head2 sub get_suffix_aref
282  
283 =cut
284  
285 sub get_suffix_aref {
286  
287 my $self = @_;
288  
289 if ($setbhed_spec->{_suffix_aref} ) {
290  
291 my $suffix_aref= $setbhed_spec->{_suffix_aref};
292 return($suffix_aref);
293  
294 } else {
295 print("$setbhed_spec, get_suffix_aref, missing suffix_aref\n");
296 return();
297 }
298  
299 return();
300 }
301  
302  
303 =head2 sub prefix_aref
304  
305 Include in the Set up
306 sections of an output Poop flow.
307  
308 prefixes and suffixes to parameter labels
309 are filtered by sunix_pl
310  
311 =cut
312  
313 sub prefix_aref {
314  
315 my $self = @_;
316  
317 my @prefix;
318  
319 for (my $i=0; $i < $max_index; $i++) {
320  
321 $prefix[$i] = $empty_string;
322  
323 }
324  
325 my $index_aref = get_binding_index_aref();
326 my @index = @$index_aref;
327  
328 # label 1 in GUI is input binary header file and needs a home directory
329 #$prefix[ $index[0] ] = '$DATA_SEISMIC_BIN' . ''.'/'.'';
330  
331 # label 6 in GUI is input par_file and needs a home directory
332 $prefix[ $index[1] ] = '$DATA_SEISMIC_TXT' . ''.'/'.'';
333  
334 $setbhed_spec ->{_prefix_aref} = \@prefix;
335 return();
336  
337 }
338  
339  
340 =head2 sub suffix_aref
341  
342 Initialize suffixes as empty
343 values
344  
345 =cut
346  
347 sub suffix_aref {
348  
349 my $self = @_;
350  
351 my @suffix;
352  
353 for (my $i=0; $i < $max_index; $i++) {
354  
355 $suffix[$i] = $empty_string;
356  
357 }
358  
359 my $index_aref = get_binding_index_aref();
360 my @index = @$index_aref;
361  
362 # label 1 in GUI is output binary header file and needs a home directory
363 $suffix[ $index[0] ] = ''.'' . '$suffix_bin';
364  
365 # label 6 in GUI is input parameter file and needs a home directory
366 $suffix[ $index[1] ] = ''.'' . '$suffix_txt';
367  
368 $setbhed_spec ->{_suffix_aref} = \@suffix;
369 return();
370  
371 }
372  
373  
374 =head2 sub variables
375  
376  
377 return a hash array
378 with definitions
379
380 =cut
381
382 sub variables {
383  
384 my ($self) = @_;
385 my $hash_ref = $setbhed_spec;
386 return ($hash_ref);
387 }
388  
389 1;