2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

12_HProtocolGateway: moved strapping table csv file to attribute

git-svn-id: https://svn.fhem.de/fhem/trunk@18595 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
eisler 2019-02-14 13:10:19 +00:00
parent 0f4e37ab0b
commit a3004feefd
3 changed files with 35 additions and 37 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- change: 12_HProtocolGateway: moved strapping table csv file to attribute
- bugfix: 98_WeekdayTimer: restore old Revision; remove Twilight dependency
- bugfix: 88_HMCCU: Module HttpUtils included
- changed. 98_WOL: remove dependency on Twilight + German COmmandref

View File

@ -49,8 +49,7 @@ sub HProtocolGateway_Initialize($) {
"parityBit:N,E,O " .
"databitsLength:5,6,7,8 " .
"stopBit:0,1 " .
"pollIntervalMins " .
"path";
"pollIntervalMins";
}
sub HProtocolGateway_Define($$) {
@ -342,8 +341,6 @@ sub HProtocolGateway_Attr (@) {
} else {
RemoveInternalTimer($hash);
}
} elsif ($attr eq 'path') {
$attr{$name}{path} = $val;
} elsif ($attr eq 'baudrate') {
$attr{$name}{baudrate} = $val;
HProtocolGateway_DeviceConfig($hash);
@ -386,18 +383,18 @@ sub HProtocolGateway_Poll($) {
sub HProtocolGateway_Tank($$$) {
my ($hash,$tankHash,$filllevel) = @_;
my $name = $hash->{NAME};
my $path = AttrVal($name,"path","");
my $type = AttrVal($tankHash->{NAME},"type","");
my $type = AttrVal($tankHash->{NAME}, 'type','');
my %TankChartHash;
open my $fh, '<', $path.$type or die "Cannot open: $!";
while (my $line = <$fh>) {
my @array = split(" ", $type);
foreach my $line (@array) {
$line =~ s/\s*\z//;
my @array = split /,/, $line;
my $key = shift @array;
$TankChartHash{$key} = $array[0];
}
close $fh;
my $volume = 0;
my $volume1 = 0;
@ -433,7 +430,6 @@ sub HProtocolGateway_Tank($$$) {
<ul>
<code>define &lt;name&gt; HProtocolGateway /dev/tty???<br />
attr &lt;name&gt; pollIntervalMins 2<br />
attr &lt;name&gt; path /opt/fhem/<br />
attr &lt;name&gt; baudrate 1200<br />
attr &lt;name&gt; databitsLength 8<br />
attr &lt;name&gt; parityBit N<br />
@ -441,23 +437,6 @@ sub HProtocolGateway_Tank($$$) {
<br />
<br />
Defines an HProtocolGateway connected to RS232 serial standard interface.<br /><br />
path is the path for tank&lt;01&gt;.csv strapping table files.<br /><br />
<code>
level,volume<br />
10,16<br />
520,7781<br />
1330,29105<br />
1830,43403<br />
2070,49844<br />
2220,53580<br />
2370,57009<br />
2400,57650<br />
2430,58275<br />
2370,57009<br />
2400,57650<br />
2430,58275<br />
</code>
</ul><br />
@ -466,8 +445,6 @@ sub HProtocolGateway_Tank($$$) {
<ul>
<li>pollIntervalMins<br />
poll Interval in Mins</li>
<li>path<br />
Strapping Table csv file path</li>
<li>baudrate<br />
Baudrate / 300, 600, 1200, 2400, 4800, 9600</li>
<li>databitsLength<br />

View File

@ -34,10 +34,10 @@ sub HProtocolTank_Initialize($) {
$hash->{AttrFn} = "HProtocolGateway_Attr";
$hash->{Match} = "^[a-zA-Z0-9_]+ [a-zA-Z0-9_]+ [+-]*[0-9]+([.][0-9]+)?";
$hash->{AttrList} = "hID " .
"mode:FillLevel,Volume,Ullage " .
"type " .
"product:Diesel,FuelOil,Petrol " .
"sensorSystem:Hectronic,Unitronics,PMS-IB " .
"mode:FillLevel,Volume,Ullage " .
"product:Diesel,FuelOil,Petrol " .
"type " .
$readingFnAttributes;
}
@ -103,10 +103,14 @@ sub HProtocolTank_Attr (@) {
my $hash = $defs{$name};
my $msg = '';
if ($attr eq 'type') {
$attr{$name}{type} = $val;
if ($attr eq 'strappingTable') {
$attr{$name}{strappingTable} = $val;
} elsif ($attr eq 'mode') {
$attr{$name}{mode} = $val;
} elsif ($attr eq 'product') {
$attr{$name}{product} = $val;
} elsif ($attr eq 'sensorSystem') {
$attr{$name}{sensorSystem} = $val;
}
}
@ -172,11 +176,27 @@ sub HProtocolTank_Attr (@) {
<li>mode<br />
Mode / FillLevel, Volume, Ullage</li>
<li>type<br />
Strapping Table csv file / tank01.csv</li>
Type / Strapping Table csv</li>
<li>product<br />
Product / Diesel, FuelOil, Petrol</li>
</ul><br />
</ul><br /><br />
strapping table csv<br /><br />
<code>
level,volume<br />
10,16<br />
520,7781<br />
1330,29105<br />
1830,43403<br />
2070,49844<br />
2220,53580<br />
2370,57009<br />
2400,57650<br />
2430,58275<br />
2370,57009<br />
2400,57650<br />
2430,58275<br />
</code>
</ul><br />