mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 08:11:44 +00:00
12_HProtocolGateway: fix Filllevel decimal, Strapping table linear interpolation
git-svn-id: https://svn.fhem.de/fhem/trunk@17508 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
753440b287
commit
55ed9026fa
@ -28,6 +28,7 @@ package main;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use DevIo;
|
use DevIo;
|
||||||
|
use Math::Round qw/round/;
|
||||||
|
|
||||||
my @tankList = undef;
|
my @tankList = undef;
|
||||||
|
|
||||||
@ -192,8 +193,8 @@ sub HProtocolGateway_ParseMessage($$) {
|
|||||||
# convert to HEX
|
# convert to HEX
|
||||||
$check = sprintf '%02X', $check;
|
$check = sprintf '%02X', $check;
|
||||||
|
|
||||||
# Unitronics Vision130
|
# Unitronics
|
||||||
if ($water == 0 && $temperature == 0 && $probe_offset == 0 && $version == 0 && $error == 0 && $checksum == 0 ) {
|
if ($version == 0 && $error == 0 && $checksum == 0) {
|
||||||
$check = 0;
|
$check = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ sub HProtocolGateway_ParseMessage($$) {
|
|||||||
my $mode = AttrVal($tankHash->{NAME},"mode","");
|
my $mode = AttrVal($tankHash->{NAME},"mode","");
|
||||||
|
|
||||||
if ($mode eq "FillLevel") {
|
if ($mode eq "FillLevel") {
|
||||||
$filllevel = $tankdata;
|
$filllevel = $tankdata/100;
|
||||||
$volume = HProtocolGateway_Tank($hash,$tankHash,$filllevel);
|
$volume = HProtocolGateway_Tank($hash,$tankHash,$filllevel);
|
||||||
} elsif ($mode eq "Volume") {
|
} elsif ($mode eq "Volume") {
|
||||||
$volume = $tankdata;
|
$volume = $tankdata;
|
||||||
@ -363,14 +364,17 @@ sub HProtocolGateway_Tank($$$) {
|
|||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
my $messwert = $filllevel/100;
|
|
||||||
my $volume = 0;
|
my $volume = 0;
|
||||||
|
my $volume1 = 0;
|
||||||
|
my $level1 = 0;
|
||||||
foreach my $level (sort keys %TankChartHash) {
|
foreach my $level (sort keys %TankChartHash) {
|
||||||
if ($level ne "level" && $messwert <= $level) {
|
if ($level ne "level" && $filllevel <= $level) {
|
||||||
$volume = $TankChartHash{$level};
|
$volume = $volume1 + ($TankChartHash{$level} - $volume1) / ($level - $level1) * ($filllevel-$level1);
|
||||||
|
$volume = Math::Round::nearest('0.01',$volume);
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
$level1 = $level;
|
||||||
|
$volume1 = $TankChartHash{$level};
|
||||||
}
|
}
|
||||||
return $volume;
|
return $volume;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ sub HProtocolTank_Attr (@) {
|
|||||||
<li>waterlevel<br />
|
<li>waterlevel<br />
|
||||||
0..9999 Water level in mm</li>
|
0..9999 Water level in mm</li>
|
||||||
<li>probe_offset<br />
|
<li>probe_offset<br />
|
||||||
-9999 - +9999 Probe offset in mm)</li>
|
-9999 - +9999 Probe offset in mm</li>
|
||||||
<li>version<br />
|
<li>version<br />
|
||||||
00..999 Software version</li>
|
00..999 Software version</li>
|
||||||
<li>error<br />
|
<li>error<br />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user