2009-10-20 Sancho Lerena <slerena@artica.es>
* tools.pm, core.pm: Float data with "," will be replace this character with "." and manage it properly as float. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2035 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8186b332d8
commit
04d255f7f8
|
@ -1,3 +1,9 @@
|
|||
2009-10-20 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* tools.pm, core.pm: Float data with "," will be replace this
|
||||
character with "." and manage it properly as float.
|
||||
|
||||
|
||||
2009-10-16 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* util/pandora_server: Updated error string when service cannot startup
|
||||
|
|
|
@ -1010,10 +1010,13 @@ sub process_data ($$$$$) {
|
|||
return undef;
|
||||
}
|
||||
|
||||
# If is a number, we need to replace "," for "."
|
||||
$data =~ s/\,/\./;
|
||||
|
||||
# Out of bounds
|
||||
return undef if (($module->{'max'} != $module->{'min'}) &&
|
||||
($data > $module->{'max'} || $data < $module->{'min'}));
|
||||
|
||||
|
||||
# Process INC modules
|
||||
if ($module_type =~ m/_inc$/) {
|
||||
$data = process_inc_data ($data, $module, $utimestamp, $dbh);
|
||||
|
@ -1027,6 +1030,8 @@ sub process_data ($$$$$) {
|
|||
$data = $data * $module->{'post_process'};
|
||||
}
|
||||
|
||||
# TODO: Float precission should be adjusted here in the future with a global
|
||||
# config parameter
|
||||
# Format data
|
||||
$data = sprintf("%.2f", $data);
|
||||
|
||||
|
|
|
@ -191,15 +191,17 @@ sub is_numeric {
|
|||
if (!defined($val)){
|
||||
return 0;
|
||||
}
|
||||
# Replace "," for "."
|
||||
$val =~ s/\,/\./;
|
||||
|
||||
my $DIGITS = qr{ \d+ (?: [.] \d*)? | [.] \d+ }xms;
|
||||
my $SIGN = qr{ [+-] }xms;
|
||||
my $NUMBER = qr{ ($SIGN?) ($DIGITS) }xms;
|
||||
if ( $val !~ /^${NUMBER}$/ ) {
|
||||
return 0; #Non-numeric
|
||||
} else {
|
||||
return 1; #Numeric
|
||||
}
|
||||
my $DIGITS = qr{ \d+ (?: [.] \d*)? | [.] \d+ }xms;
|
||||
my $SIGN = qr{ [+-] }xms;
|
||||
my $NUMBER = qr{ ($SIGN?) ($DIGITS) }xms;
|
||||
if ( $val !~ /^${NUMBER}$/ ) {
|
||||
return 0; #Non-numeric
|
||||
} else {
|
||||
return 1; #Numeric
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
|
Loading…
Reference in New Issue