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