lib/App/SeismicUnixGui/specs/statsMath/suconv_spec.pm untested

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