2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

Enable selectlist again. Thanks to sweetie-pie

git-svn-id: https://svn.fhem.de/fhem/trunk@360 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2009-04-10 09:54:37 +00:00
parent 1b2a972f8a
commit 526dd5f2c4
4 changed files with 57 additions and 22 deletions

View File

@ -236,7 +236,7 @@ GOTBW:
} else { } else {
return "Expecting a 0-padded hex number" return "Expecting a 0-padded hex number"
if((length($arg)&1) == 0 && $type ne "raw"); if((length($arg)&1) == 1 && $type ne "raw");
$initstr = "X$arg" if($type eq "verbose"); $initstr = "X$arg" if($type eq "verbose");
Log GetLogLevel($name,4), "set $name $type $arg"; Log GetLogLevel($name,4), "set $name $type $arg";
CUL_SimpleWrite($hash, $sets{$type} . $arg); CUL_SimpleWrite($hash, $sets{$type} . $arg);

View File

@ -4,7 +4,7 @@ package main;
# Modul for FHEM # Modul for FHEM
# #
# contributed by thomas dressler 2008 # contributed by thomas dressler 2008
# $Id: 87_WS2000.pm,v 1.5 2008-09-21 17:55:28 rudolfkoenig Exp $ # $Id: 87_WS2000.pm,v 1.6 2009-04-10 09:54:37 rudolfkoenig Exp $
# corr. negativ temps / peterp # corr. negativ temps / peterp
########################### ###########################
use strict; use strict;
@ -82,7 +82,7 @@ WS2000_Define($$)
return "Can't open Device $PortName: $^E\n"; return "Can't open Device $PortName: $^E\n";
} }
#$hash->{FD}=$PortObj->{_HANDLE}; #$hash->{FD}=$PortObj->{_HANDLE};
# $readyfnlist{"$a[0].$a[2]"} = $hash; $readyfnlist{"$a[0].$a[2]"} = $hash;
} else { } else {
eval ("use Device::SerialPort;"); eval ("use Device::SerialPort;");
if ($@) { if ($@) {
@ -97,7 +97,7 @@ WS2000_Define($$)
return "Can't open Device $PortName: $^E\n"; return "Can't open Device $PortName: $^E\n";
} }
$hash->{FD}=$PortObj->FILENO; $hash->{FD}=$PortObj->FILENO;
# $selectlist{"$a[0].$a[2]"} = $hash; $selectlist{"$a[0].$a[2]"} = $hash;
} }
#Parameter 19200,8,2,Odd,None #Parameter 19200,8,2,Odd,None
$PortObj->baudrate(19200); $PortObj->baudrate(19200);
@ -128,7 +128,7 @@ WS2000_Define($$)
} }
$xport->autoflush(1); $xport->autoflush(1);
$hash->{FD}=$xport->fileno; $hash->{FD}=$xport->fileno;
# $selectlist{"$a[0].$a[2]"} = $hash; $selectlist{"$a[0].$a[2]"} = $hash;
$hash->{socket}=$xport; $hash->{socket}=$xport;

View File

@ -151,6 +151,10 @@ FileLog_Set($@)
# Up till now following functions are impemented: # Up till now following functions are impemented:
# - int (to cut off % from a number, as for the actuator) # - int (to cut off % from a number, as for the actuator)
# - delta-h / delta-d to get rain/h and rain/d values from continuous data. # - delta-h / delta-d to get rain/h and rain/d values from continuous data.
#
# It will set the %data values
# min<x>, max<x>, avg<x>, cnt<x>, lastd<x>, lastv<x>
# for each requested column, beggining with <x> = 1
sub sub
FileLog_Get($@) FileLog_Get($@)
@ -194,6 +198,8 @@ FileLog_Get($@)
# last2: last delta value recorded (for the very last entry) # last2: last delta value recorded (for the very last entry)
# last3: last delta timestamp (d or h) # last3: last delta timestamp (d or h)
my (@d, @fname); my (@d, @fname);
my (@min, @max, @sum, @cnt, @lastv, @lastd);
for(my $i = 0; $i < int(@a); $i++) { for(my $i = 0; $i < int(@a); $i++) {
my @fld = split(":", $a[$i], 4); my @fld = split(":", $a[$i], 4);
@ -202,11 +208,10 @@ FileLog_Get($@)
$fname[$i] = "$outf.$i"; $fname[$i] = "$outf.$i";
$h{fh} = new IO::File "> $fname[$i]"; $h{fh} = new IO::File "> $fname[$i]";
} }
$h{re} = $fld[1]; $h{re} = $fld[1]; # Filter: regexp
$h{df} = defined($fld[2]) ? $fld[2] : ""; # default value
$h{df} = defined($fld[2]) ? $fld[2] : ""; $h{fn} = $fld[3]; # function
$h{fn} = $fld[3]; $h{didx} = 10 if($fld[3] && $fld[3] eq "delta-d"); # delta idx, substr len
$h{didx} = 10 if($fld[3] && $fld[3] eq "delta-d");
$h{didx} = 13 if($fld[3] && $fld[3] eq "delta-h"); $h{didx} = 13 if($fld[3] && $fld[3] eq "delta-h");
if($fld[0] =~ m/"(.*)"/) { if($fld[0] =~ m/"(.*)"/) {
@ -223,6 +228,12 @@ FileLog_Get($@)
} }
$h{ret} = ""; $h{ret} = "";
$d[$i] = \%h; $d[$i] = \%h;
$min[$i] = 999999;
$max[$i] = -999999;
$sum[$i] = 0;
$cnt[$i] = 0;
$lastv[$i] = 0;
$lastd[$i] = "undef";
} }
my %lastdate; my %lastdate;
@ -238,14 +249,16 @@ FileLog_Get($@)
my $col = $h->{col}; my $col = $h->{col};
my $t = $h->{type}; my $t = $h->{type};
my $line;
my $val = undef;
my $dte = $fld[0];
if($t == 0) { # Fixed text if($t == 0) { # Fixed text
$line = "$fld[0] $col\n"; $val = $col;
} elsif($t == 1) { # The column } elsif($t == 1) { # The column
$line = "$fld[0] $fld[$col]\n" if(defined($fld[$col])); $val = $fld[$col] if(defined($fld[$col]));
} elsif($t == 2) { # delta-h or delta-d } elsif($t == 2) { # delta-h or delta-d
@ -258,7 +271,8 @@ FileLog_Get($@)
$ts = "$lda[1]:30:00" if($hd == 13); $ts = "$lda[1]:30:00" if($hd == 13);
my $v = $fld[$col]-$h->{last1}; my $v = $fld[$col]-$h->{last1};
$v = 0 if($v < 0); # Skip negative delta $v = 0 if($v < 0); # Skip negative delta
$line = sprintf("%s_%s %0.1f\n", $lda[0],$ts, $v); $dte = "$lda[0]_$ts";
$val = sprintf("%0.1f", $v);
} }
$h->{last1} = $fld[$col]; $h->{last1} = $fld[$col];
$h->{last3} = $ld; $h->{last3} = $ld;
@ -267,19 +281,26 @@ FileLog_Get($@)
$lastdate{$hd} = $fld[0]; $lastdate{$hd} = $fld[0];
} elsif($t == 3) { # int function } elsif($t == 3) { # int function
my $val = $fld[$col]; $val = $1 if($fld[$col] =~ m/^([0-9]+).*/);
$line = "$fld[0] $1\n" if($val =~ m/^([0-9]+).*/);
} else { # evaluate } else { # evaluate
$line = "$fld[0] " . eval($h->{fn}) . "\n"; $val = eval($h->{fn});
} }
next if(!$line);
next if(!defined($val));
$min[$i] = $val if($val < $min[$i]);
$max[$i] = $val if($val > $max[$i]);
$sum[$i] += $val;
$cnt[$i]++;
$lastv[$i] = $val;
$lastd[$i] = $dte;
if($outf eq "-") { if($outf eq "-") {
$h->{ret} .= $line; $h->{ret} .= "$dte $val\n";
} else { } else {
my $fh = $h->{fh}; my $fh = $h->{fh}; # cannot use $h->{fh} in print directly
print $fh $line; print $fh "$dte $val\n";
$h->{count}++; $h->{count}++;
} }
} }
@ -317,6 +338,15 @@ FileLog_Get($@)
} }
$fh->close(); $fh->close();
} }
my $j = $i+1;
$data{"min$j"} = $min[$i] == 999999 ? "undef" : $min[$i];
$data{"max$j"} = $max[$i] == -999999 ? "undef" : $max[$i];
$data{"avg$j"} = $cnt[$i] ? sprintf("%0.1f", $sum[$i]/$cnt[$i]) : "undef";
$data{"cnt$j"} = $cnt[$i] ? $cnt[$i] : "undef";
$data{"currval$j"} = $lastv[$i];
$data{"currdate$j"} = $lastd[$i];
} }
if($internal) { if($internal) {
$internal_data = \$ret; $internal_data = \$ret;

View File

@ -138,7 +138,12 @@ structure_Set($@)
Log 1, "ERROR: endless loop detected for $d in " . $hash->{NAME}; Log 1, "ERROR: endless loop detected for $d in " . $hash->{NAME};
next; next;
} }
next if($attr{$d} && $attr{$d}{structexclude});
if($attr{$d} && $attr{$d}{structexclude}) {
my $se = $attr{$d}{structexclude};
next if($hash->{NAME} =~ m/$se/);
}
$list[0] = $d; $list[0] = $d;
my $sret .= CommandSet(undef, join(" ", @list)); my $sret .= CommandSet(undef, join(" ", @list));
if($sret) { if($sret) {