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