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:
slerena 2009-10-19 10:42:42 +00:00
parent 8186b332d8
commit 04d255f7f8
3 changed files with 22 additions and 9 deletions

View File

@ -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

View File

@ -1010,6 +1010,9 @@ 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'}));
@ -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);

View File

@ -191,6 +191,8 @@ sub is_numeric {
if (!defined($val)){
return 0;
}
# Replace "," for "."
$val =~ s/\,/\./;
my $DIGITS = qr{ \d+ (?: [.] \d*)? | [.] \d+ }xms;
my $SIGN = qr{ [+-] }xms;