mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
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
2775251fe7
commit
e1232298d2
@ -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>
|
2009-10-16 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* util/pandora_server: Updated error string when service cannot startup
|
* util/pandora_server: Updated error string when service cannot startup
|
||||||
|
@ -1010,6 +1010,9 @@ sub process_data ($$$$$) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If is a number, we need to replace "," for "."
|
||||||
|
$data =~ s/\,/\./;
|
||||||
|
|
||||||
# Out of bounds
|
# Out of bounds
|
||||||
return undef if (($module->{'max'} != $module->{'min'}) &&
|
return undef if (($module->{'max'} != $module->{'min'}) &&
|
||||||
($data > $module->{'max'} || $data < $module->{'min'}));
|
($data > $module->{'max'} || $data < $module->{'min'}));
|
||||||
@ -1027,6 +1030,8 @@ sub process_data ($$$$$) {
|
|||||||
$data = $data * $module->{'post_process'};
|
$data = $data * $module->{'post_process'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: Float precission should be adjusted here in the future with a global
|
||||||
|
# config parameter
|
||||||
# Format data
|
# Format data
|
||||||
$data = sprintf("%.2f", $data);
|
$data = sprintf("%.2f", $data);
|
||||||
|
|
||||||
|
@ -191,15 +191,17 @@ sub is_numeric {
|
|||||||
if (!defined($val)){
|
if (!defined($val)){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
# Replace "," for "."
|
||||||
|
$val =~ s/\,/\./;
|
||||||
|
|
||||||
my $DIGITS = qr{ \d+ (?: [.] \d*)? | [.] \d+ }xms;
|
my $DIGITS = qr{ \d+ (?: [.] \d*)? | [.] \d+ }xms;
|
||||||
my $SIGN = qr{ [+-] }xms;
|
my $SIGN = qr{ [+-] }xms;
|
||||||
my $NUMBER = qr{ ($SIGN?) ($DIGITS) }xms;
|
my $NUMBER = qr{ ($SIGN?) ($DIGITS) }xms;
|
||||||
if ( $val !~ /^${NUMBER}$/ ) {
|
if ( $val !~ /^${NUMBER}$/ ) {
|
||||||
return 0; #Non-numeric
|
return 0; #Non-numeric
|
||||||
} else {
|
} else {
|
||||||
return 1; #Numeric
|
return 1; #Numeric
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user