lib/App/SeismicUnixGui/specs/model/suaddevent_spec.pm untested

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