| 1 | package App::SeismicUnixGui::misc::config_superflows; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | Perl package: config_superflows.pm | ||
| 8 | AUTHOR: Juan Lorenzo | ||
| 9 | DATE: June 22 2017 | ||
| 10 | |||
| 11 | DESCRIPTION: | ||
| 12 | V 0.1 June 22 2017 | ||
| 13 | V 0.2 June 23 2017 | ||
| 14 | change class name from sunix.pm | ||
| 15 | |||
| 16 | USED FOR: | ||
| 17 | |||
| 18 | BASED ON: param_sunix | ||
| 19 | inherits from: param_sunix (e.g., sub first_idx) | ||
| 20 | TODO: fully inherit from param_sunix | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | use Moose; | ||
| 25 | our $VERSION = '1.0.0'; | ||
| 26 | use Carp; | ||
| 27 | |||
| 28 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 29 | use aliased 'App::SeismicUnixGui::big_streams::immodpg_global_constants'; | ||
| 30 | use aliased 'App::SeismicUnixGui::misc::big_streams_param'; | ||
| 31 | use aliased 'App::SeismicUnixGui::misc::files_LSU'; | ||
| 32 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 33 | |||
| 34 | =pod | ||
| 35 | |||
| 36 | private hash_ref | ||
| 37 | for widgets | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | my $config_superflows = { | ||
| 42 | _program_name_sref => '', | ||
| 43 | _program_name_sref => '', | ||
| 44 | _label_boxes_w => '', | ||
| 45 | _entry_boxes_w => '', | ||
| 46 | _check_buttons_w => '', | ||
| 47 | _all_aref => '', | ||
| 48 | _first_idx => '', | ||
| 49 | _length => '', | ||
| 50 | _inbound => '', | ||
| 51 | _program_name_config => '', | ||
| 52 | _size => '', | ||
| 53 | }; | ||
| 54 | |||
| 55 | my $get = L_SU_global_constants->new(); | ||
| 56 | my $get_immodpg = immodpg_global_constants->new(); | ||
| 57 | my $var = $get->var(); | ||
| 58 | my $var_immodpg = $get_immodpg->var(); | ||
| 59 | my $on = $var->{_on}; | ||
| 60 | my $off = $var->{_off}; | ||
| 61 | my $nu = $var->{_nu}; | ||
| 62 | my $yes = $var->{_yes}; | ||
| 63 | my $no = $var->{_no}; | ||
| 64 | my $empty_string = $var->{_empty_string}; | ||
| 65 | my $superflow_names = $get->superflow_names_h(); | ||
| 66 | my $superflow_names_gui_h = $get->superflow_names_gui_h(); | ||
| 67 | |||
| 68 | my $alias = $get->alias_superflow_names_h; | ||
| 69 | my $global_lib = $get->global_libs(); | ||
| 70 | my $GLOBAL_CONFIG_LIB = $global_lib->{_param}; | ||
| 71 | |||
| 72 | =head2 sub _get_program_name | ||
| 73 | |||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | sub _get_program_name { | ||
| 78 | |||
| 79 | my ($self) = @_; | ||
| 80 | |||
| 81 | my $result; | ||
| 82 | |||
| 83 | if ( length $config_superflows->{_program_name_sref} ) { | ||
| 84 | |||
| 85 | $result = $config_superflows->{_program_name_sref}; | ||
| 86 | |||
| 87 | } | ||
| 88 | else { | ||
| 89 | print("config_superlows,_get_program_name,missing program name\n"); | ||
| 90 | $result = $empty_string; | ||
| 91 | } | ||
| 92 | |||
| 93 | return ($result); | ||
| 94 | |||
| 95 | } | ||
| 96 | |||
| 97 | sub get_names { | ||
| 98 | my ($self) = @_; | ||
| 99 | |||
| 100 | my $cfg_aref = $config_superflows->{_all_aref}; | ||
| 101 | my $length = $config_superflows->{_length}; | ||
| 102 | my ( $i, $j ); | ||
| 103 | my @names; | ||
| 104 | |||
| 105 | for ( $i = 0, $j = 0 ; $i < $length ; $i = $i + 2, $j++ ) { | ||
| 106 | $names[$j] = @$cfg_aref[$i]; | ||
| 107 | |||
| 108 | # print(" config_superflows, get_names :index $j names: $names[$j]\n"); | ||
| 109 | } | ||
| 110 | return ( \@names ); | ||
| 111 | } | ||
| 112 | |||
| 113 | sub get_check_buttons_settings { | ||
| 114 | my ($self) = @_; | ||
| 115 | my $cfg_aref = $config_superflows->{_all_aref}; | ||
| 116 | my $length = $config_superflows->{_length}; | ||
| 117 | my ( $i, $j ); | ||
| 118 | my @on_off; | ||
| 119 | my @values; | ||
| 120 | |||
| 121 | for ( $i = 1, $j = 0 ; $i < $length ; $i = $i + 2, $j++ ) { | ||
| 122 | $values[$j] = @$cfg_aref[$i]; | ||
| 123 | |||
| 124 | # print("config_superflows, get_check_buttons_settings :index $j values: $values[$j]\n"); | ||
| 125 | |||
| 126 | if ( $values[$j] eq $nu || $values[$j] eq $no ) { | ||
| 127 | |||
| 128 | $on_off[$j] = $off; | ||
| 129 | |||
| 130 | # print("1 config_superflows: get_check_buttons_settings 'nu' or no :index $j setting: $on_off[$j]\n"); | ||
| 131 | |||
| 132 | } | ||
| 133 | elsif ( $values[$j] eq "" ) { # test form empty string | ||
| 134 | $on_off[$j] = $off; | ||
| 135 | |||
| 136 | # print("2 config_superflows: get_check_buttons_settings, empty string :index $j setting: $on_off[$j]\n"); | ||
| 137 | } | ||
| 138 | else { | ||
| 139 | $on_off[$j] = $on; | ||
| 140 | |||
| 141 | # print("3 config_superflows: get_check_buttons_settings, else, :index $j setting: $on_off[$j]\n"); | ||
| 142 | } | ||
| 143 | |||
| 144 | # print("config_superflows: get_check_buttons_settings :index $j setting: $on_off[$j]\n"); | ||
| 145 | } | ||
| 146 | return ( \@on_off ); | ||
| 147 | } | ||
| 148 | |||
| 149 | sub get_values { | ||
| 150 | |||
| 151 | my ($self) = @_; | ||
| 152 | |||
| 153 | my $cfg_aref = $config_superflows->{_all_aref}; | ||
| 154 | my $length = $config_superflows->{_length}; | ||
| 155 | my ( $i, $j ); | ||
| 156 | my @values; | ||
| 157 | |||
| 158 | # print("cfg_aref is @$cfg_aref\n"); | ||
| 159 | |||
| 160 | for ( $i = 1, $j = 0 ; $i < $length ; $i = $i + 2, $j++ ) { | ||
| 161 | $values[$j] = @$cfg_aref[$i]; | ||
| 162 | |||
| 163 | # print("config_superflows, get_values :index $j values:--$values[$j]--\n"); | ||
| 164 | } | ||
| 165 | |||
| 166 | return ( \@values ); | ||
| 167 | } | ||
| 168 | |||
| 169 | =head2 sub length | ||
| 170 | |||
| 171 | length is not the last index but one beyond | ||
| 172 | print("config_superflows, lengthis $config_superflows->{_length}\n"); | ||
| 173 | print("config_superflows, length (x2) is $config_superflows->{_length}\n"); | ||
| 174 | TODO: subroutine will fail unless _defaults are first called | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | sub length { | ||
| 179 | |||
| 180 | my ($self) = @_; | ||
| 181 | |||
| 182 | _get_all(); | ||
| 183 | |||
| 184 | if ( $config_superflows->{_length} ) { | ||
| 185 | |||
| 186 | $config_superflows->{_length} = $config_superflows->{_length} / 2; | ||
| 187 | return ( $config_superflows->{_length} ); | ||
| 188 | } | ||
| 189 | else { | ||
| 190 | print("config_superflows,length. length is missing\n"); | ||
| 191 | return (); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | =pod | ||
| 196 | |||
| 197 | export all the private hash references | ||
| 198 | |||
| 199 | =cut | ||
| 200 | |||
| 201 | sub _get_all { | ||
| 202 | |||
| 203 | my ($self) = ''; | ||
| 204 | |||
| 205 | # print("config_superflows,_get_all \n"); | ||
| 206 | _local_or_defaults( $config_superflows->{_program_name_sref} ); | ||
| 207 | return (); | ||
| 208 | } | ||
| 209 | |||
| 210 | =head2 sub _local_or_defaults | ||
| 211 | |||
| 212 | Read a default specification file | ||
| 213 | If default specification file# does not exist locally, | ||
| 214 | which is in PL_SEISMIC for general superflow conguration files | ||
| 215 | and and in legacy cases for Project.config | ||
| 216 | If Project.config is not found check the user's configuration area: .LSU/configuration/active/Project.config | ||
| 217 | and if not, | ||
| 218 | then use the default one defined under global libs | ||
| 219 | Similary if a general superflow.configuration file is not found under PL_SEISMIC | ||
| 220 | check for one default case under global libs | ||
| 221 | |||
| 222 | Debug with | ||
| 223 | print ("self is $self,program is $program_name\n"); | ||
| 224 | print("params are @$ref_CFG\n"); | ||
| 225 | program name is a hash | ||
| 226 | print("params are @$ref_cfg\n"); | ||
| 227 | print ("self is $self,program is $program_name\n"); | ||
| 228 | print("config_superflows,_local_or_defaults,program_name:$$program_name_sref\n"); | ||
| 229 | print("config_superflows,_local_or_defaults,program_name:$$name_sref\n"); | ||
| 230 | print("config_superflows,_local_or_defaults,program_name:$$program_name_sref\n"); | ||
| 231 | |||
| 232 | =cut | ||
| 233 | |||
| 234 | sub _local_or_defaults { | ||
| 235 | my ($self) = @_; | ||
| 236 | my $name_sref = $config_superflows->{_program_name_sref}; | ||
| 237 | |||
| 238 | # print( | ||
| 239 | #"config_superflows, _local_or_defaults,SCALAR program name=$$name_sref\n" | ||
| 240 | # ); | ||
| 241 | |||
| 242 | my $big_streams_param = big_streams_param->new(); | ||
| 243 | my $flow_type = $get->flow_type_href(); | ||
| 244 | my $pre_built_superflow = $flow_type->{_pre_built_superflow}; | ||
| 245 | |||
| 246 | # set flow type before big_streams_param->get | ||
| 247 | $big_streams_param->set_flow_type($pre_built_superflow); | ||
| 248 | |||
| 249 | # print("1. config_superflows, _local_or_defaults,pre_built_superflow=$pre_built_superflow\n"); | ||
| 250 | my $cfg_aref = $big_streams_param->get($name_sref); | ||
| 251 | $config_superflows->{_all_aref} = $cfg_aref; | ||
| 252 | $config_superflows->{_length} = $big_streams_param->my_length(); | ||
| 253 | |||
| 254 | # length seems > true length + 1, TODO | ||
| 255 | # print("config_superflows, _local_or_defaults,length=$config_superflows->{_length}\n"); | ||
| 256 | return (); | ||
| 257 | } | ||
| 258 | |||
| 259 | =head2 sub get_local_or_defaults | ||
| 260 | |||
| 261 | via big_streams_param: | ||
| 262 | |||
| 263 | Read a default specification file | ||
| 264 | 1) If default specification file does not exist locally (PL_SEISMIC), | ||
| 265 | 2) then check the user's configuration area: .LSU/configuration/active/Project.config | ||
| 266 | and if if still does not exist there, | ||
| 267 | 3) then use the default one defined under global libs. | ||
| 268 | |||
| 269 | Debug with | ||
| 270 | print ("self is $self,program is $program_name\n"); | ||
| 271 | print("params are @$ref_CFG\n"); | ||
| 272 | program name is a hash | ||
| 273 | print("params are @$ref_cfg\n"); | ||
| 274 | print ("self is $self,program is $program_name\n"); | ||
| 275 | print("config_superflows,get_local_or_defaults,program_name:$$program_name_sref\n"); | ||
| 276 | print("config_superflows,get_local_or_defaults,program_name:$$name_sref\n"); | ||
| 277 | print("config_superflows,get_local_or_defaults,program_name:$$program_name_sref\n"); | ||
| 278 | print("config_superflows,get_local_or_defaults, length:$config_superflows->{_length}\n"); | ||
| 279 | |||
| 280 | =cut | ||
| 281 | |||
| 282 | sub get_local_or_defaults { | ||
| 283 | my ( $self, $config_base_name ) = @_; | ||
| 284 | |||
| 285 | print( | ||
| 286 | "config_superflows, get_local_or_defaults,program name=$config_base_name\n" | ||
| 287 | ); | ||
| 288 | |||
| 289 | if ( $config_superflows->{_program_name_sref} ) { | ||
| 290 | |||
| 291 | my $big_streams_param = big_streams_param->new(); | ||
| 292 | my ( $cfg_aref, $size ); | ||
| 293 | |||
| 294 | my $name_sref = $config_superflows->{_program_name_sref}; | ||
| 295 | |||
| 296 | # print("config_superflows, get_local_or_defaults,program name=$$name_sref\n"); | ||
| 297 | print( | ||
| 298 | "config_superflows, get_local_or_defaults,SCALAR program name=$name_sref\n" | ||
| 299 | ); | ||
| 300 | |||
| 301 | $cfg_aref = $big_streams_param->get($name_sref); | ||
| 302 | |||
| 303 | print( | ||
| 304 | "config_superflows, get_local_or_defaults,cfg_aref = @{$cfg_aref}\n" | ||
| 305 | ); | ||
| 306 | return ($cfg_aref); | ||
| 307 | |||
| 308 | # } | ||
| 309 | } | ||
| 310 | else { | ||
| 311 | print( | ||
| 312 | "config_superflows, get_local_or_defaults,missing program_name_sref\n" | ||
| 313 | ); | ||
| 314 | } | ||
| 315 | |||
| 316 | } | ||
| 317 | |||
| 318 | =head2 sub save | ||
| 319 | |||
| 320 | i/p: has a reference with the names values and program name | ||
| 321 | names are in an array reference | ||
| 322 | values are too | ||
| 323 | no need for checkbuttons | ||
| 324 | # print("config_superflows,save\nprog_name: ${$out_hash_ref->{_prog_name}}"); | ||
| 325 | # print(" labels: @{$out_hash_ref->{_ref_labels}}\n"); | ||
| 326 | # print(" values: @{$out_hash_ref->{_ref_values}}\n"); | ||
| 327 | |||
| 328 | =cut | ||
| 329 | |||
| 330 | sub save { | ||
| 331 | |||
| 332 | my ( $self, $in_hash_ref ) = @_; | ||
| 333 | # print( | ||
| 334 | #"config_superflows,save,in_hash_ref:...${$in_hash_ref->{_prog_name_sref}}...)\n" | ||
| 335 | # ); | ||
| 336 | if ( defined $in_hash_ref | ||
| 337 | && ${$config_superflows->{_program_name_sref}} ne $empty_string ) | ||
| 338 | { | ||
| 339 | |||
| 340 | my $out_hash_ref = { | ||
| 341 | _ref_labels => '', | ||
| 342 | _ref_values => '', | ||
| 343 | _prog_name_sref => '', | ||
| 344 | }; | ||
| 345 | |||
| 346 | my $files_LSU = files_LSU->new(); | ||
| 347 | |||
| 348 | $out_hash_ref->{_ref_labels} = $in_hash_ref->{_names_aref}; | ||
| 349 | $out_hash_ref->{_ref_values} = $in_hash_ref->{_values_aref}; | ||
| 350 | |||
| 351 | # N.B. IT is NOT $in_hash_ref->{_prog_name_sref}; | ||
| 352 | $out_hash_ref->{_prog_name_sref} = | ||
| 353 | $config_superflows->{_program_name_sref}; # backup | ||
| 354 | |||
| 355 | # print("config_superflows,save,out_hash_ref, ${$out_hash_ref->{_prog_name_sref}}\n"); | ||
| 356 | # print("config_superflows,save,out_hash_ref,@{$out_hash_ref->{_ref_values}}[1]\n"); | ||
| 357 | # print("config_superflows,save,out_hash_ref,@{$out_hash_ref->{_ref_labels}}\n"); | ||
| 358 | # print("config_superflows,save,values are,@{$out_hash_ref->{_ref_values}}\n"); | ||
| 359 | |||
| 360 | if ( ${ $out_hash_ref->{_prog_name_sref} } eq 'Project' ) { | ||
| 361 | |||
| 362 | # Single special case | ||
| 363 | # print("CASE config_superflows,save, for special Project case\n"); | ||
| 364 | $files_LSU->set_Project_config(); | ||
| 365 | # NEXT 3 are scalar ref | ||
| 366 | $files_LSU->set_prog_name_sref( $out_hash_ref->{_prog_name_sref} ); | ||
| 367 | $files_LSU->set_outbound( $out_hash_ref->{_prog_name_sref} ); | ||
| 368 | $files_LSU->set_superflow_specs($out_hash_ref); | ||
| 369 | |||
| 370 | # to /home/gom/.L_SU/configuration/active/Project.config | ||
| 371 | $files_LSU->write(); | ||
| 372 | |||
| 373 | # also create additional directory and file in the configuration area | ||
| 374 | # of the project. | ||
| 375 | # to /home/gom/.L_SU/configuration/ProjectName/Project.config | ||
| 376 | # If directories are missing some will be created. | ||
| 377 | # scalar ref | ||
| 378 | $files_LSU->set_outbound2( $out_hash_ref->{_prog_name_sref} ); | ||
| 379 | |||
| 380 | $files_LSU->write2(); | ||
| 381 | |||
| 382 | |||
| 383 | } | ||
| 384 | else { | ||
| 385 | my @format; | ||
| 386 | |||
| 387 | # CASE 2 all other superflow configuration files except for Project.config | ||
| 388 | |||
| 389 | $files_LSU->set_config(); | ||
| 390 | $files_LSU->set_prog_name_sref( $out_hash_ref->{_prog_name_sref} ) | ||
| 391 | ; # scalar ref | ||
| 392 | # print("CASE 2 config_superflows,save, for other cases\n"); | ||
| 393 | # print(" config_superflows,save,program name = ${$out_hash_ref->{_prog_name_sref}}\n"); | ||
| 394 | $files_LSU->outbound(); | ||
| 395 | $files_LSU->set_superflow_specs($out_hash_ref); # scalar ref | ||
| 396 | |||
| 397 | my $program_name_sref = _get_program_name(); | ||
| 398 | |||
| 399 | if ( $$program_name_sref ne $empty_string ) { | ||
| 400 | |||
| 401 | if ( $$program_name_sref eq 'immodpg' ) { | ||
| 402 | |||
| 403 | # carp("config_superflows,save,progam_name_sref= ${$program_name_sref}\n"); | ||
| 404 | |||
| 405 | @format = @{ $var_immodpg->{_format_aref} }; | ||
| 406 | |||
| 407 | # print("1. config_superflows, _write,formats =@format \n"); | ||
| 408 | $files_LSU->set_superflow_config_file_format( \@format ); | ||
| 409 | |||
| 410 | } | ||
| 411 | else { | ||
| 412 | # All other superflows/big_streams | ||
| 413 | $format[0] = $var->{_config_file_format}; | ||
| 414 | # print("2. config_superflows, _write,formats =@format \n"); | ||
| 415 | $files_LSU->set_superflow_config_file_format( \@format ); | ||
| 416 | } | ||
| 417 | |||
| 418 | # Just before return statement | ||
| 419 | $files_LSU->check2write(); # to $PL_SEISMIC/prog_name.config | ||
| 420 | |||
| 421 | } | ||
| 422 | } | ||
| 423 | |||
| 424 | } | ||
| 425 | else { | ||
| 426 | print("config_superflows,save, missing values"); | ||
| 427 | } | ||
| 428 | return (); | ||
| 429 | |||
| 430 | } | ||
| 431 | |||
| 432 | |||
| 433 | =head2 sub set_program_name | ||
| 434 | |||
| 435 | i/p is scalar ref | ||
| 436 | o/p is scalar ref | ||
| 437 | print("config_superflows, program_name,:$alias->{ProjectVariables}\n"); | ||
| 438 | |||
| 439 | =cut | ||
| 440 | |||
| 441 | sub set_program_name { | ||
| 442 | my ( $self, $program_name_sref ) = @_; | ||
| 443 | |||
| 444 | # print("config_superflows, set_program_name, program_name=$$program_name_sref\n"); | ||
| 445 | # print("config_superflows, set_program_name, program_name=$superflow_names->{_fk}\n"); | ||
| 446 | if ($program_name_sref) { | ||
| 447 | my $name_sref; | ||
| 448 | |||
| 449 | if ( | ||
| 450 | $$program_name_sref eq $superflow_names->{_fk} # alias does not work | ||
| 451 | or $$program_name_sref eq $superflow_names->{_Sudipfilt} | ||
| 452 | ) | ||
| 453 | { | ||
| 454 | # print("config_superflows, fk name = $superflow_names->{_fk}\n"); | ||
| 455 | $name_sref = \$alias->{fk}; | ||
| 456 | |||
| 457 | # print("config_superflows, alias of $superflow_names->{_fk} is $$name_sref\n"); | ||
| 458 | } | ||
| 459 | |||
| 460 | if ( $$program_name_sref eq $superflow_names->{_iBottomMute} ) { | ||
| 461 | $name_sref = \$alias->{iBottomMute}; | ||
| 462 | } | ||
| 463 | |||
| 464 | if ( $$program_name_sref eq $superflow_names->{_iSpectralAnalysis} ) { | ||
| 465 | $name_sref = \$alias->{iSpectralAnalysis}; | ||
| 466 | } | ||
| 467 | |||
| 468 | if ( $$program_name_sref eq $superflow_names->{_iTopMute} ) { | ||
| 469 | $name_sref = \$alias->{iTopMute}; | ||
| 470 | } | ||
| 471 | |||
| 472 | if ( $$program_name_sref eq $superflow_names->{_iVelAnalysis} | ||
| 473 | or $$program_name_sref eq $superflow_names->{_iVA} ) | ||
| 474 | { | ||
| 475 | |||
| 476 | # print("config_superflows, iVA name = $superflow_names->{_iVelAnalysis}\n"); | ||
| 477 | $name_sref = \$alias->{iVelAnalysis}; | ||
| 478 | |||
| 479 | # print("config_superflows, alias of program name is $$name_sref\n"); | ||
| 480 | } | ||
| 481 | |||
| 482 | if ( $$program_name_sref eq $superflow_names->{_Project} ) { | ||
| 483 | |||
| 484 | # warning: must omit underscore | ||
| 485 | $name_sref = \$alias->{Project}; | ||
| 486 | } | ||
| 487 | |||
| 488 | if ( $$program_name_sref eq $superflow_names->{_ProjectVariables} ) { | ||
| 489 | |||
| 490 | # warning: must omit underscore | ||
| 491 | $name_sref = \$alias->{ProjectVariables}; | ||
| 492 | } | ||
| 493 | |||
| 494 | if ( $$program_name_sref eq $superflow_names->{_Synseis} ) { | ||
| 495 | |||
| 496 | # warning: must omit underscore | ||
| 497 | $name_sref = \$alias->{Synseis}; | ||
| 498 | } | ||
| 499 | |||
| 500 | if ( $$program_name_sref eq $superflow_names->{_Sseg2su} ) { | ||
| 501 | |||
| 502 | # warning: must omit underscore | ||
| 503 | $name_sref = \$alias->{Sseg2su}; | ||
| 504 | } | ||
| 505 | |||
| 506 | if ( $$program_name_sref eq $superflow_names->{_Sucat} ) { | ||
| 507 | |||
| 508 | # warning: must omit underscore | ||
| 509 | $name_sref = \$alias->{Sucat}; | ||
| 510 | } | ||
| 511 | |||
| 512 | if ( $$program_name_sref eq $superflow_names->{_iPick} ) { | ||
| 513 | |||
| 514 | # warning: must omit underscore | ||
| 515 | $name_sref = \$alias->{iPick}; | ||
| 516 | } | ||
| 517 | |||
| 518 | if ( $$program_name_sref eq $superflow_names->{_immodpg} ) { | ||
| 519 | |||
| 520 | # warning: must omit underscore | ||
| 521 | #print("config_superflows, set_program_name,superflow_names=$superflow_names->{_immodpg}\n"); | ||
| 522 | # print("config_superflows, set_program_name,alias superflow_names=$superflow_names->{_immodpg}\n"); | ||
| 523 | |||
| 524 | $name_sref = \$alias->{immodpg}; | ||
| 525 | |||
| 526 | # print("config_superflows, alias of program name is $$name_sref\n"); | ||
| 527 | } | ||
| 528 | |||
| 529 | # accounts for when gui name differs from internal program name | ||
| 530 | if ( | ||
| 531 | $$program_name_sref eq $superflow_names_gui_h->{_ProjectBackup} | ||
| 532 | |||
| 533 | # accounts for when gui name equals internal program name | ||
| 534 | or $$program_name_sref eq $superflow_names->{_BackupProject} | ||
| 535 | ) | ||
| 536 | { | ||
| 537 | |||
| 538 | # warning: must omit underscore | ||
| 539 | # specifies internal program names | ||
| 540 | $name_sref = \$alias->{ProjectBackup}; | ||
| 541 | |||
| 542 | # print("config_superflows, alias of program name is $$name_sref\n"); | ||
| 543 | } | ||
| 544 | |||
| 545 | # accounts for when gui name differs from internal program name | ||
| 546 | if ( | ||
| 547 | $$program_name_sref eq $superflow_names_gui_h->{_ProjectRestore} | ||
| 548 | |||
| 549 | # accounts for when gui name equals internal program name | ||
| 550 | or $$program_name_sref eq $superflow_names->{_RestoreProject} | ||
| 551 | ) | ||
| 552 | { | ||
| 553 | |||
| 554 | # warning: must omit underscore | ||
| 555 | # specifies internal program names | ||
| 556 | $name_sref = \$alias->{ProjectRestore}; | ||
| 557 | |||
| 558 | # print("config_superflows, alias of program name is $$name_sref\n"); | ||
| 559 | } | ||
| 560 | |||
| 561 | if ( $$program_name_sref eq $superflow_names->{_temp} ) { | ||
| 562 | |||
| 563 | # warning: must omit underscore | ||
| 564 | $name_sref = \$alias->{temp}; | ||
| 565 | } | ||
| 566 | |||
| 567 | $config_superflows->{_program_name_sref} = $name_sref; | ||
| 568 | # print( | ||
| 569 | # "config_superflows,set_program_name internal name: ${$config_superflows->{_program_name_sref}}\n"); | ||
| 570 | _get_all(); | ||
| 571 | |||
| 572 | } | ||
| 573 | else { | ||
| 574 | print("config_superflows,set_program_name alias, missing value\n"); | ||
| 575 | } | ||
| 576 | return (); | ||
| 577 | } | ||
| 578 | |||
| 579 | =head2 | ||
| 580 | |||
| 581 | =cut | ||
| 582 | |||
| 583 | sub get_prog_name_config { | ||
| 584 | my ($self) = @_; | ||
| 585 | |||
| 586 | if ( $config_superflows->{_program_name_config} ) { | ||
| 587 | |||
| 588 | my $prog_name_config = $config_superflows->{_program_name_config}; | ||
| 589 | |||
| 590 | # print("config_superflows,get_prog_name_config: $prog_name_config\n"); | ||
| 591 | return ($prog_name_config); | ||
| 592 | |||
| 593 | } | ||
| 594 | else { | ||
| 595 | print("config_superflows, get_prog_name_config: missing \n"); | ||
| 596 | return (); | ||
| 597 | } | ||
| 598 | } | ||
| 599 | |||
| 600 | =head2 | ||
| 601 | |||
| 602 | =cut | ||
| 603 | |||
| 604 | sub _get_prog_name_config { | ||
| 605 | my ($self) = @_; | ||
| 606 | |||
| 607 | if ( $config_superflows->{_program_name_config} ) { | ||
| 608 | |||
| 609 | my $prog_name_config = $config_superflows->{_program_name_config}; | ||
| 610 | return ($prog_name_config); | ||
| 611 | |||
| 612 | } | ||
| 613 | else { | ||
| 614 | print( | ||
| 615 | "config_superflows, _get_prog_name_config: $config_superflows->{_program_name_sref}\n" | ||
| 616 | ); | ||
| 617 | return (); | ||
| 618 | } | ||
| 619 | } | ||
| 620 | |||
| 621 | =head2 sub first_idx | ||
| 622 | |||
| 623 | first usable index is set to 0 | ||
| 624 | |||
| 625 | =cut | ||
| 626 | |||
| 627 | sub first_idx { | ||
| 628 | |||
| 629 | my ($self) = @_; | ||
| 630 | |||
| 631 | $config_superflows->{_first_idx} = 0; | ||
| 632 | |||
| 633 | my $result = $config_superflows->{_first_idx}; | ||
| 634 | return ($result); | ||
| 635 | |||
| 636 | } | ||
| 637 | |||
| 638 | =head2 sub set_prog_name_config | ||
| 639 | |||
| 640 | needs $config_superflows->{_program_name_sref} | ||
| 641 | |||
| 642 | =cut | ||
| 643 | |||
| 644 | sub set_prog_name_config { | ||
| 645 | my ( $self, $program_name_sref ) = @_; | ||
| 646 | if ($program_name_sref) { | ||
| 647 | |||
| 648 | my $prog_name = $$program_name_sref; | ||
| 649 | $config_superflows->{_program_name_config} = $prog_name . '.config'; | ||
| 650 | |||
| 651 | } | ||
| 652 | else { | ||
| 653 | |||
| 654 | print( | ||
| 655 | "config_superflows, set_prog_name_config,_program_name_sref: missing\n" | ||
| 656 | ); | ||
| 657 | } | ||
| 658 | return (); | ||
| 659 | } | ||
| 660 | |||
| 661 | =head2 sub inbound | ||
| 662 | |||
| 663 | print("config_superflows, inbound, prog_name: $prog_name\n"); | ||
| 664 | print("config_superflows, inbound, outbound: $config_superflows->{_program_name_config}\n"); | ||
| 665 | print("config_superflows, inbound, outbound: $config_superflows->{_inbound}\n"); | ||
| 666 | |||
| 667 | =cut | ||
| 668 | |||
| 669 | sub inbound { | ||
| 670 | my ($self) = @_; | ||
| 671 | |||
| 672 | if ( $config_superflows->{_program_name_sref} ) { | ||
| 673 | |||
| 674 | my $Project = Project_config->new(); | ||
| 675 | my $PL_SEISMIC = $Project->PL_SEISMIC(); | ||
| 676 | |||
| 677 | my $prog_name = ${ $config_superflows->{_program_name_sref} }; | ||
| 678 | $config_superflows->{_program_name_config} = $prog_name . '.config'; | ||
| 679 | $config_superflows->{_inbound} = | ||
| 680 | $PL_SEISMIC . '/' . $config_superflows->{_program_name_config}; | ||
| 681 | |||
| 682 | # print("config_superflows, inbound:: $config_superflows->{_inbound}\n"); | ||
| 683 | |||
| 684 | return (); | ||
| 685 | |||
| 686 | } | ||
| 687 | else { | ||
| 688 | |||
| 689 | print("config_superflows, inbound, missing program_name_sref\n"); | ||
| 690 | |||
| 691 | } | ||
| 692 | |||
| 693 | } | ||
| 694 | |||
| 695 | |||
| 696 | =head2 sub check2read | ||
| 697 | |||
| 698 | needs $config_superflows->{_inbound} | ||
| 699 | first look in $PL_SEISMIC and then | ||
| 700 | look in the default global library | ||
| 701 | |||
| 702 | =cut | ||
| 703 | |||
| 704 | sub check2read { | ||
| 705 | my ($self) = @_; | ||
| 706 | |||
| 707 | if ( $config_superflows->{_inbound} ) { | ||
| 708 | |||
| 709 | if ( not -e $config_superflows->{_inbound} ) { #if file does not exist | ||
| 710 | |||
| 711 | use File::Copy; | ||
| 712 | my $prog_name_config = _get_prog_name_config(); | ||
| 713 | |||
| 714 | my $from = $GLOBAL_CONFIG_LIB . $prog_name_config; | ||
| 715 | my $to = $config_superflows->{_inbound}; | ||
| 716 | |||
| 717 | copy( $from, $to ); | ||
| 718 | |||
| 719 | # print("config_superflows copy $from to $to \n"); | ||
| 720 | |||
| 721 | } | ||
| 722 | else { | ||
| 723 | |||
| 724 | # print("config_superflows, write_config, configuration file exists and will be overwritten\n"); | ||
| 725 | |||
| 726 | } | ||
| 727 | } | ||
| 728 | return (); | ||
| 729 | } | ||
| 730 | |||
| 731 | # removes Moose exports | ||
| 732 | # no Moose; | ||
| 733 | # increases speed | ||
| 734 | #__PACKAGE__->meta->make_immutable; | ||
| 735 | 1; |