diff lib/hr.pm @ 3:78afd7f439f3 draft default tip

master branch Updating with tag :CI_COMMIT_TAG - - Fxx
author fgiacomoni
date Wed, 15 Feb 2023 15:57:49 +0000
parents 23970530a518
children
line wrap: on
line diff
--- a/lib/hr.pm	Tue Jan 17 10:31:32 2023 +0000
+++ b/lib/hr.pm	Wed Feb 15 15:57:49 2023 +0000
@@ -14,8 +14,8 @@
 
 our $VERSION = "1.0";
 our @ISA = qw(Exporter);
-our @EXPORT = qw( manage_atoms_and_ranges manage_atoms check_hr_exe manage_atom_and_range manage_tolerance manage_mode config_hr_exe );
-our %EXPORT_TAGS = ( ALL => [qw(manage_atoms_and_ranges manage_atoms check_hr_exe manage_atom_and_range manage_tolerance manage_mode config_hr_exe )] );
+our @EXPORT = qw( manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe );
+our %EXPORT_TAGS = ( ALL => [qw(manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe )] );
 
 =head1 NAME
 
@@ -54,6 +54,75 @@
 }
 ### END of SUB
 
+
+=head2 METHOD manageAtomsConf
+
+	## Description : take all max atom values from CONF file and personal choice 
+	## Input : $confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value
+	## Output : $atomFullConfig
+	## Usage : my ( $atomFullConfig ) = manageAtomsConf ( $confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value ) ;
+	
+=cut
+## START of SUB
+sub manageAtomsConf{
+    ## Retrieve Values
+    my $self = shift ;
+    my ($confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value) = @_ ;
+    
+    my %atomFullConfig = () ;
+	$atomFullConfig{'C'} = {'min' => 0, 'max' =>  0} ;
+	$atomFullConfig{'H'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'N'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'O'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'P'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'S'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'F'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'L'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'K'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'B'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'A'} = {'min' => 0, 'max' => 0} ;
+	$atomFullConfig{'1'} = {'min' => 0, 'max' => 0} ;
+	
+	if (defined $C12_max_value)	{ 	$atomFullConfig{'C'}{'max'} = $C12_max_value ; 	}
+	else 						{	$atomFullConfig{'C'}{'max'} = $confFile->{'C'}	}
+	
+	if (defined $H_max_value)	{ 	$atomFullConfig{'H'}{'max'} = $H_max_value ; 	}
+	else 						{	$atomFullConfig{'H'}{'max'} = $confFile->{'H'}	}
+	
+	if (defined $N_max_value)	{ 	$atomFullConfig{'N'}{'max'} = $N_max_value ; 	}
+	else 						{	$atomFullConfig{'N'}{'max'} = $confFile->{'N'}	}
+	
+	if (defined $O_max_value)	{ 	$atomFullConfig{'O'}{'max'} = $O_max_value ; 	}
+	else 						{	$atomFullConfig{'O'}{'max'} = $confFile->{'O'}	}
+	
+	if (defined $P_max_value)	{ 	$atomFullConfig{'P'}{'max'} = $P_max_value ; 	}
+	else 						{	$atomFullConfig{'P'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $S_max_value)	{ 	$atomFullConfig{'S'}{'max'} = $S_max_value ; 	}
+	else 						{	$atomFullConfig{'S'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $F_max_value)	{ 	$atomFullConfig{'F'}{'max'} = $F_max_value ; 	}
+	else 						{	$atomFullConfig{'F'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $Cl_max_value)	{ 	$atomFullConfig{'L'}{'max'} = $Cl_max_value ; 	}
+	else 						{	$atomFullConfig{'L'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $K_max_value)	{ 	$atomFullConfig{'K'}{'max'} = $K_max_value ; 	}
+	else 						{	$atomFullConfig{'K'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $Br_max_value)	{ 	$atomFullConfig{'B'}{'max'} = $Br_max_value ; 	}
+	else 						{	$atomFullConfig{'B'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $Na_max_value)	{ 	$atomFullConfig{'A'}{'max'} = $Na_max_value ; 	}
+	else 						{	$atomFullConfig{'A'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+	
+	if (defined $C13_max_value)	{ 	$atomFullConfig{'1'}{'max'} = $C13_max_value ; 	}
+	else 						{	$atomFullConfig{'1'}{'max'} = $confFile->{'DEFAULT_MAX'}	}
+    
+    return (\%atomFullConfig) ;
+}
+### END of SUB
+
 =head2 METHOD manage_atoms_and_ranges
 
 	## Description : allow from an initial config to add or delete atoms and their range
@@ -66,90 +135,45 @@
 sub manage_atoms_and_ranges {
     ## Retrieve Values
     my $self = shift ;
-    my ( $atomsconfig, $CONF, $atombasic, $atomsupp ) = @_;
-    my ( $atomcleanconfig ) = ( undef ) ;
+    my ( $atomFullconfig, $atombasic, $atomsupp ) = @_;
+    my ( $atomConfigCmd ) = ( undef ) ;
+    my %atomCurrentConfig = () ;
+		$atomCurrentConfig{'C'} = {'min' => 0, 'max' =>  0} ;
+		$atomCurrentConfig{'H'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'N'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'O'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'P'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'S'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'F'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'L'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'K'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'B'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'A'} = {'min' => 0, 'max' => 0} ;
+		$atomCurrentConfig{'1'} = {'min' => 0, 'max' => 0} ;
     
     # basic atoms case:
     foreach my $atom ( (split(",", $atombasic )) ) {
-    	if ( exists $CONF->{$atom} ) 	{ $atomsconfig->{$atom}{'max'} = $CONF->{$atom} ; }
+    	if ( exists $atomFullconfig->{$atom}{'max'} )     { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
     	else {  print "*** $atom not recognized***\n" ; }
     }
     
     # suppl. atoms case
     foreach my $atom ( (split(",", $atomsupp )) ) {
     	#print "*** $atom***\n" ;
-    	if ( exists $atomsconfig->{$atom} ) 	{ $atomsconfig->{$atom}{'max'} = $CONF->{'DEFAULT_MAX'} ; }
+    	if ( exists $atomFullconfig->{$atom}{'max'} ) 	{ $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
     	else {  print "*** $atom not recognized***\n" ; }
     	
     }
     
     # Create atoms and range parameters:    
-    foreach my $selectedAtom ( keys %{$atomsconfig} ) {
-    	$atomcleanconfig .= ' -'.$selectedAtom.' '.$atomsconfig->{$selectedAtom}{'min'}.'-'.$atomsconfig->{$selectedAtom}{'max'} ;
+    foreach my $selectedAtom ( keys %atomCurrentConfig ) {
+    	$atomConfigCmd .= ' -'.$selectedAtom.' '.$atomCurrentConfig{$selectedAtom}{'min'}.'-'.$atomCurrentConfig{$selectedAtom}{'max'} ;
     }
     
-    return ($atomcleanconfig) ;
+    return ($atomConfigCmd) ;
 }
 ### END of SUB
 
-
-     
-=head2 METHOD manage_atoms ### DEPRECATED
-
-	## Description : controles atoms input list and prepare it like hr binary parameter 
-	## Input : $input_atoms, $conf_atoms
-	## Output : $hr_atoms_param
-	## Usage : my ( $hr_atoms_param ) = manage_atoms( $input_atoms, $conf_atoms ) ;
-	### DEPRECATED
-	
-=cut
-## START of SUB
-sub manage_atoms { ### DEPRECATED
-	## Retrieve Values
-    my $self = shift ;
-    my ( $input_atoms, $conf_atoms ) = @_ ;
-    my $hr_atoms_param = undef ;
-    
-    if ( ( defined $$input_atoms ) and ( defined $$conf_atoms )  ) {
-    	if ( ( $$input_atoms eq 'None' ) or ( $$input_atoms eq '' ) or ( $$input_atoms eq ' ' ) )	{  $hr_atoms_param =  $$conf_atoms ; 	}
-    	elsif ( $$input_atoms =~ /[P|S|F|L|K|B|A|1|,]+/ ) { $hr_atoms_param =  $$conf_atoms.','.$$input_atoms ;  }
-    	else 							{  $hr_atoms_param =  $$conf_atoms ;  	}
-    } ## END IF
-    elsif ( !defined $$input_atoms ) { 	$hr_atoms_param =  $$conf_atoms ; }
-    elsif ( !defined $$conf_atoms )  { 	warn "hr module can't manage any atom list (undef values in conf)\n" ; }
-    else {						    	warn "hr module musn't manage any atom list\n" ; }
-    
-    return(\$hr_atoms_param) ;
-}
-## END of SUB
-
-=head2 METHOD manage_atom_and_range ### DEPRECATED
-
-	## Description : build atom range with defined value in conf file
-	## Input : $atom, $min, $max
-	## Output : $hr_range
-	## Usage : my (  ) = manage_atom_and_range( $atom, $min, $max ) ;
-	### DEPRECATED
-	
-=cut
-## START of SUB
-sub manage_atom_and_range { ### DEPRECATED
-	## Retrieve Values
-    my $self = shift ;
-    my ( $atom, $min, $max ) = @_ ;
-    my $hr_range = undef ;
-    
-    if ( ( defined $$atom ) and ( defined $$min ) and ( defined $$max )  ) {
-    	## manage ragne like "-C 0-200"
-    	$hr_range = ' -'.$$atom.' '.$$min.'-'.$$max ;
-    } ## END IF
-    else {
-    	warn "Some argvts are missing to build the current atom range line\n" ;
-    }    
-    return(\$hr_range) ;
-}
-## END of SUB
-
 =head2 METHOD manage_tolerance
 
 	## Description : check range and format of tolerance
@@ -757,7 +781,7 @@
 
 =over 4
 
-=item :ALL is manage_atoms, check_hr_exe, manage_tolerance
+=item :ALL is manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe
 
 =back
 
@@ -773,6 +797,6 @@
 
 version 1 : 02 / 20 / 2014
 
-version 2 : ??
+version 2 : 02/ 15 / 2023 - Add personal max value for each atom manager methods, remove deprecated methods
 
 =cut
\ No newline at end of file