mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-23 20:52:13 +00:00
12_HProtocolGateway / 12_HProtocolTank: mode,type added to tank
git-svn-id: https://svn.fhem.de/fhem/trunk@17336 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c7a34fa91e
commit
392d03de82
@ -48,9 +48,8 @@ sub HProtocolGateway_Initialize($) {
|
||||
"baudrate:300,600,1200,2400,4800,9600 " .
|
||||
"parityBit:N,E,O " .
|
||||
"databitsLength:5,6,7,8 " .
|
||||
"stopBit " .
|
||||
"stopBit:0,1" .
|
||||
"pollIntervalMins " .
|
||||
"mode:Filllevel,Volume,Ullage " .
|
||||
"path";
|
||||
}
|
||||
|
||||
@ -108,10 +107,11 @@ sub HProtocolGateway_GetUpdate($) {
|
||||
|
||||
foreach (@tankList) {
|
||||
my $tankHash = $_;
|
||||
my $mode = AttrVal($tankHash->{NAME},"mode","");
|
||||
my $command = "\$A";
|
||||
if ($attr{$name}{mode} eq "Volume") {
|
||||
if ($mode eq "Volume") {
|
||||
$command = "\$B";
|
||||
} elsif ($attr{$name}{mode} eq "Ullage") {
|
||||
} elsif ($mode eq "Ullage") {
|
||||
$command = "\$C";
|
||||
}
|
||||
|
||||
@ -200,13 +200,14 @@ sub HProtocolGateway_ParseMessage($$) {
|
||||
return if($check ne $checksum);
|
||||
|
||||
my ($filllevel,$volume,$ullage) = (0,0,0);
|
||||
my $mode = AttrVal($tankHash->{NAME},"mode","");
|
||||
|
||||
if ($attr{$name}{mode} eq "Filllevel") {
|
||||
if ($mode eq "Filllevel") {
|
||||
$filllevel = $tankdata;
|
||||
$volume = HProtocolGateway_Tank($hash,$tankHash,$filllevel);
|
||||
} elsif ($attr{$name}{mode} eq "Volume") {
|
||||
} elsif ($mode eq "Volume") {
|
||||
$volume = $tankdata;
|
||||
} elsif ($attr{$name}{mode} eq "Ullage") {
|
||||
} elsif ($mode eq "Ullage") {
|
||||
$ullage = $tankdata;
|
||||
}
|
||||
|
||||
@ -305,8 +306,6 @@ sub HProtocolGateway_Attr (@) {
|
||||
} else {
|
||||
RemoveInternalTimer($hash);
|
||||
}
|
||||
} elsif ($attr eq 'mode') {
|
||||
$attr{$name}{mode} = $val;
|
||||
} elsif ($attr eq 'path') {
|
||||
$attr{$name}{path} = $val;
|
||||
} elsif ($attr eq 'baudrate') {
|
||||
@ -351,9 +350,11 @@ 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 %TankChartHash;
|
||||
open my $fh, '<', $attr{$name}{path}.'tank'.$tankHash->{READINGS}{hID}{VAL}.'.csv' or die "Cannot open: $!";
|
||||
open my $fh, '<', $path.$type or die "Cannot open: $!";
|
||||
while (my $line = <$fh>) {
|
||||
$line =~ s/\s*\z//;
|
||||
my @array = split /,/, $line;
|
||||
@ -393,7 +394,6 @@ sub HProtocolGateway_Tank($$$) {
|
||||
<ul>
|
||||
<code>define <name> HProtocolGateway /dev/tty???<br />
|
||||
attr <name> pollIntervalMins 2<br />
|
||||
attr <name> mode Filllevel<br />
|
||||
attr <name> path /opt/fhem/<br />
|
||||
attr <name> baudrate 1200<br />
|
||||
attr <name> databitsLength 8<br />
|
||||
@ -420,8 +420,26 @@ sub HProtocolGateway_Tank($$$) {
|
||||
2430,58275<br />
|
||||
</code>
|
||||
|
||||
|
||||
<br /><br />
|
||||
|
||||
<a name="HProtocolGateway"></a>
|
||||
<b>Attributes</b>
|
||||
<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 />
|
||||
Databits Length / 5, 6, 7, 8</li>
|
||||
<li>parityBit<br />
|
||||
Parity Bit / N, E, O</li>
|
||||
<li>stopBit<br />
|
||||
Stop Bit / 0, 1</li>
|
||||
</ul><br />
|
||||
|
||||
</ul><br />
|
||||
|
||||
</ul><br />
|
||||
|
@ -31,8 +31,11 @@ sub HProtocolTank_Initialize($) {
|
||||
$hash->{DefFn} = "HProtocolTank_Define";
|
||||
$hash->{ParseFn} = "HProtocolTank_Parse";
|
||||
$hash->{FingerprintFn} = "HProtocolTank_Fingerprint";
|
||||
$hash->{AttrFn} = "HProtocolGateway_Attr";
|
||||
$hash->{Match} = "^[a-zA-Z0-9_]+ [a-zA-Z0-9_]+ [+-]*[0-9]+([.][0-9]+)?";
|
||||
$hash->{AttrList} = $readingFnAttributes;
|
||||
$hash->{AttrList} = "mode:Filllevel,Volume,Ullage " .
|
||||
"type " .
|
||||
$readingFnAttributes;
|
||||
}
|
||||
|
||||
sub HProtocolTank_Define($$) {
|
||||
@ -92,6 +95,18 @@ sub HProtocolTank_Fingerprint($$) {
|
||||
# this message is a duplicate message. Refer to FHEM Wiki.
|
||||
}
|
||||
|
||||
sub HProtocolTank_Attr (@) {
|
||||
my ($command, $name, $attr, $val) = @_;
|
||||
my $hash = $defs{$name};
|
||||
my $msg = '';
|
||||
|
||||
if ($attr eq 'type') {
|
||||
$attr{$name}{type} = $val;
|
||||
} elsif ($attr eq 'mode') {
|
||||
$attr{$name}{mode} = $val;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@ -122,7 +137,7 @@ sub HProtocolTank_Fingerprint($$) {
|
||||
<b>Readings</b>
|
||||
<ul>
|
||||
<li>hID<br />
|
||||
01 - 99 Tank Number / Tank Address</li>
|
||||
01 - 32 Tank Number / Tank Address (99 for testing only)</li>
|
||||
<li>ullage<br />
|
||||
0..999999 Ullage in litres</li>
|
||||
<li>filllevel<br />
|
||||
@ -143,6 +158,15 @@ sub HProtocolTank_Fingerprint($$) {
|
||||
0..9 00.. Probe error</li>
|
||||
</ul><br />
|
||||
|
||||
<a name="HProtocolTank"></a>
|
||||
<b>Attributes</b>
|
||||
<ul>
|
||||
<li>mode<br />
|
||||
Filllevel, Volume, Ullage</li>
|
||||
<li>type<br />
|
||||
Strapping Table csv file / tank01.csv</li>
|
||||
</ul><br />
|
||||
|
||||
|
||||
</ul><br />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user