mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
FileLog bug + CUR send
git-svn-id: https://svn.fhem.de/fhem/trunk@312 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
59f0955434
commit
a059bbbd74
@ -471,4 +471,6 @@
|
||||
- feature: getstate command from Martin (25.12)
|
||||
- bugfix: at drifts for relative timespecs
|
||||
- bugfix: Add IODev to CUL/EM/CUL_WS/HMS/KS300
|
||||
- bugfix: support for second correction factor for EMWZ in 15_CUL_EM added
|
||||
- bugfix: FileLog get (pgm2 plots) wont find the first row in the file
|
||||
- feature: 00_CUL: Answer CUR requests (status/time/fht)
|
||||
- bugfix: support for second correction factor for EMWZ in 15_CUL_EM added
|
||||
|
@ -1,8 +1,4 @@
|
||||
##############################################
|
||||
# TODO:
|
||||
# - FHT xmit
|
||||
# - HMS rcv
|
||||
|
||||
|
||||
package main;
|
||||
|
||||
@ -15,6 +11,7 @@ sub CUL_Write($$$);
|
||||
sub CUL_Read($);
|
||||
sub CUL_ReadAnswer($$);
|
||||
sub CUL_Ready($);
|
||||
sub CUL_HandleCurRequest($$);
|
||||
|
||||
my $initstr = "X01"; # Only translated messages, no RSSI
|
||||
my %msghist; # Used when more than one CUL is attached
|
||||
@ -50,7 +47,8 @@ CUL_Initialize($)
|
||||
$hash->{SetFn} = "CUL_Set";
|
||||
$hash->{StateFn} = "CUL_SetState";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " .
|
||||
"showtime:1,0 model:CUL,CUR loglevel:0,1,2,3,4,5,6";
|
||||
"showtime:1,0 model:CUL,CUR loglevel:0,1,2,3,4,5,6 " .
|
||||
"CUR_id_list";
|
||||
}
|
||||
|
||||
#####################################
|
||||
@ -201,7 +199,7 @@ GOTBW:
|
||||
if((length($arg)&1) == 1 && $type ne "raw");
|
||||
$initstr = "X$arg" if($type eq "verbose");
|
||||
Log GetLogLevel($name,4), "set $name $type $arg";
|
||||
CUL_Write($hash, $sets{$type}, $arg);
|
||||
CUL_SimpleWrite($hash, $sets{$type} . $arg);
|
||||
|
||||
}
|
||||
return undef;
|
||||
@ -239,7 +237,7 @@ CUL_Get($@)
|
||||
|
||||
} else {
|
||||
|
||||
CUL_Write($hash, $gets{$a[1]}, $arg) if(!IsDummy($hash->{NAME}));
|
||||
CUL_SimpleWrite($hash, $gets{$a[1]} . $arg) if(!IsDummy($hash->{NAME}));
|
||||
$msg = CUL_ReadAnswer($hash, $a[1]);
|
||||
$msg = "No answer" if(!defined($msg));
|
||||
$msg =~ s/[\r\n]//g;
|
||||
@ -519,7 +517,7 @@ CUL_Read($)
|
||||
goto NEXTMSG if($dmsg eq "");
|
||||
|
||||
# Debug message, X05
|
||||
if($dmsg =~ m/^p /) {
|
||||
if($dmsg =~ m/p /) {
|
||||
foreach my $m (split("p ", $dmsg)) {
|
||||
Log GetLogLevel($name,4), "CUL: p $m";
|
||||
}
|
||||
@ -553,7 +551,7 @@ CUL_Read($)
|
||||
$msghist{$msgcount}{MSG} = $dmsg;
|
||||
$msgcount++;
|
||||
|
||||
if($initstr =~ m/X2/) { # RSSI
|
||||
if($initstr =~ m/X2/ && $dmsg =~ m/[A-F0-9][A-F0-9]$/) { # RSSI
|
||||
my $l = length($dmsg);
|
||||
my $rssi = hex(substr($dmsg, $l-2, 2));
|
||||
$dmsg = substr($dmsg, 0, $l-2);
|
||||
@ -571,6 +569,14 @@ CUL_Read($)
|
||||
|
||||
if($fn eq "F") { # Reformat for 10_FS20.pm
|
||||
|
||||
if(defined($attr{$name}) && defined($attr{$name}{CUR_id_list})) {
|
||||
my $id= substr($dmsg,1,4);
|
||||
if($attr{$name}{CUR_id_list} =~ m/$id/) { # CUR Request
|
||||
CUL_HandleCurRequest($hash,$dmsg);
|
||||
goto NEXTMSG;
|
||||
}
|
||||
}
|
||||
|
||||
$dmsg = sprintf("81%02x04xx0101a001%s00%s",
|
||||
$len/2+5, substr($dmsg,1,6), substr($dmsg,7));
|
||||
$dmsg = lc($dmsg);
|
||||
@ -683,4 +689,56 @@ CUL_Ready($) # Windows - only
|
||||
return ($InBytes>0);
|
||||
}
|
||||
|
||||
sub
|
||||
CUL_SendCurMsg($$$)
|
||||
{
|
||||
my ($hash,$id,$msg) = @_;
|
||||
|
||||
$msg = substr($msg, 0, 12) if(length($msg) > 12);
|
||||
my $rmsg = "F" . $id . unpack('H*', $msg);
|
||||
Log 1, "CUL_SendCurMsg: $id:$msg / $rmsg";
|
||||
sleep(1); # Poor mans CSMA/CD
|
||||
CUL_SimpleWrite($hash, $rmsg);
|
||||
}
|
||||
|
||||
sub
|
||||
CUL_HandleCurRequest($$)
|
||||
{
|
||||
my ($hash,$msg) = @_;
|
||||
|
||||
|
||||
Log 1, "CUR Request: $msg";
|
||||
my $l = length($msg);
|
||||
return if($l < 9);
|
||||
|
||||
my $id = substr($msg,1,4);
|
||||
my $cm = substr($msg,5,2);
|
||||
my $a1 = substr($msg,7,2);
|
||||
my $a2 = pack('H*', substr($msg,9)) if($l > 9);
|
||||
|
||||
if($cm eq "00") { # Get status
|
||||
$msg = defined($defs{$a2}) ? $defs{$a2}{STATE} : "Undefined $a2";
|
||||
$msg =~ s/: /:/g;
|
||||
$msg =~ s/ / /g;
|
||||
$msg =~ s/.*[a-z]-//g; # FHT desired-temp, but keep T:-1
|
||||
$msg =~ s/\(.*//g; # FHT (Celsius)
|
||||
$msg =~ s/.*5MIN:/5MIN:/g; # EM
|
||||
$msg =~ s/\.$//;
|
||||
$msg =~ s/ *//; # One letter seldom makes sense
|
||||
CUL_SendCurMsg($hash,$id, "d" . $msg); # Display the message on the CUR
|
||||
}
|
||||
|
||||
if($cm eq "01") { # Send time
|
||||
my @a = localtime;
|
||||
$msg = sprintf("c%02d%02d%02d", $a[2],$a[1],$a[0]);
|
||||
CUL_SendCurMsg($hash,$id, $msg);
|
||||
}
|
||||
|
||||
if($cm eq "02") { # FHT desired temp
|
||||
$msg = sprintf("set %s desired-temp %.1f", $a2, $a1/2);
|
||||
fhem( $msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -228,6 +228,7 @@ FileLog_Get($@)
|
||||
my %lastdate;
|
||||
my $d; # Used by eval functions
|
||||
while(my $l = <$ifh>) {
|
||||
next if($l lt $from);
|
||||
last if($l gt $to);
|
||||
my @fld = split("[ \r\n]+", $l); # 40%
|
||||
|
||||
@ -341,16 +342,28 @@ seekTo($$$$)
|
||||
my $upper = $fh->tell;
|
||||
|
||||
my ($lower, $next, $last) = (0, $upper/2, 0);
|
||||
my $div = 2;
|
||||
while() { # Binary search
|
||||
$fh->seek($next, 0);
|
||||
my $data = <$fh>;
|
||||
if($data !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /) {
|
||||
if(!$data) {
|
||||
$last = $next;
|
||||
last;
|
||||
}
|
||||
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /) {
|
||||
$next = $fh->tell;
|
||||
$data = <$fh>;
|
||||
if(!$data) {
|
||||
$last = $next;
|
||||
last;
|
||||
}
|
||||
|
||||
# If the second line is longer then the first,
|
||||
# binary search will never get it:
|
||||
if($next eq $last && $data ge $ts && $div < 8192) {
|
||||
$last = 0;
|
||||
$div *= 2;
|
||||
}
|
||||
}
|
||||
if($next eq $last) {
|
||||
$fh->seek($next, 0);
|
||||
@ -359,9 +372,9 @@ seekTo($$$$)
|
||||
|
||||
$last = $next;
|
||||
if(!$data || $data lt $ts) {
|
||||
($lower, $next) = ($next, ($next+$upper)/2);
|
||||
($lower, $next) = ($next, int(($next+$upper)/$div));
|
||||
} else {
|
||||
($upper, $next) = ($next, ($lower+$next)/2);
|
||||
($upper, $next) = ($next, int(($lower+$next)/$div));
|
||||
}
|
||||
}
|
||||
$hash->{pos}{"$fname:$ts"} = $last;
|
||||
|
@ -359,3 +359,11 @@
|
||||
- Wed Dec 17 19:48 (Boris)
|
||||
- attribute rainadjustment for KS300 in 13_KS300.pm to account for random
|
||||
switches in the rain counter (see commandref.html)
|
||||
|
||||
- Fri Jan 2 10:29 2009 (Rudi)
|
||||
- 00_CUL responds to CUR request. These are sent as long FS20 messages, with
|
||||
a housecode stored in CUR_id_list attribute of the CUL device. If the ID
|
||||
matches, the message is analyzed, and an FS20 message to the same address
|
||||
is sent back. The CUR must have reception enabled.
|
||||
Right now status/set time/set FHT desired temp are implemented.
|
||||
|
||||
|
@ -27,8 +27,8 @@ set grid xtics y2tics
|
||||
set y2label "Temperature in C"
|
||||
set ylabel "Humidity (%)"
|
||||
|
||||
#FileLog 4:T:0:int
|
||||
#FileLog 6:T:0:int
|
||||
#FileLog 4:T:0:
|
||||
#FileLog 6:T:0:
|
||||
|
||||
plot \
|
||||
"< awk '/T:/ {print $1, $4}' <IN>"\
|
||||
|
@ -13,11 +13,11 @@ set y2tics
|
||||
set title '<TL>'
|
||||
set grid
|
||||
|
||||
set ylabel "Temperature in C"
|
||||
set y2label "Rain (l/m2)"
|
||||
set y2label "Temperature in C"
|
||||
set ylabel "Rain (l/m2)"
|
||||
|
||||
#FileLog 5:avg_day:0:
|
||||
#FileLog 11:avg_day:0:
|
||||
|
||||
plot "<grep avg_day <IN>" using 1:5 axes x1y1 title 'Temperature' with lines,\
|
||||
"<grep avg_day <IN>" using 1:11 axes x1y2 title 'Rain' with histeps
|
||||
plot "<grep avg_day <IN>" using 1:5 axes x1y2 title 'Temperature' with lines,\
|
||||
"<grep avg_day <IN>" using 1:11 axes x1y1 title 'Rain' with histeps
|
||||
|
@ -13,11 +13,11 @@ set y2tics
|
||||
set title '<TL>'
|
||||
set grid
|
||||
|
||||
set ylabel "Temperature in C"
|
||||
set y2label "Rain (l/m2)"
|
||||
set y2label "Temperature in C"
|
||||
set ylabel "Rain (l/m2)"
|
||||
|
||||
#FileLog 5:avg_month:0:
|
||||
#FileLog 11:avg_month:0:
|
||||
|
||||
plot "<grep avg_month <IN>" using 1:5 axes x1y1 title 'Temperature' with lines,\
|
||||
"<grep avg_month <IN>" using 1:11 axes x1y2 title 'Rain' with fsteps
|
||||
plot "<grep avg_month <IN>" using 1:5 axes x1y2 title 'Temperature' with lines,\
|
||||
"<grep avg_month <IN>" using 1:11 axes x1y1 title 'Rain' with fsteps
|
||||
|
@ -8,6 +8,9 @@ table.room tr.sel { background: #A0FFFF; }
|
||||
table.at { border:thin solid; width: 100%; background: #FFFFC0; }
|
||||
table.at tr.odd { background: #FFFFD7; }
|
||||
|
||||
table.watchdog { border:thin solid; width: 100%; background: #FFFFC0; }
|
||||
table.watchdog tr.odd { background: #FFFFD7; }
|
||||
|
||||
table.notify { border:thin solid; width: 100%; background: #D7D7A0; }
|
||||
table.notify tr.odd { background: #FFFFC0; }
|
||||
|
||||
@ -26,6 +29,9 @@ table.FHT tr.odd { background: #FFD7D7; }
|
||||
table.KS300 { border:thin solid; width: 100%; background: #C0FFC0; }
|
||||
table.KS300 tr.odd { background: #A7FFA7; }
|
||||
|
||||
table.HMS { border:thin solid; width: 100%; background: #C0FFC0; }
|
||||
table.HMS tr.odd { background: #A7FFA7; }
|
||||
|
||||
table.FHZ { border:thin solid; width: 100%; background: #C0C0C0; }
|
||||
table.FHZ tr.odd { background: #D7D7D7; }
|
||||
|
||||
@ -41,7 +47,6 @@ table.CUL_EM tr.odd { background: #F0F0F0; }
|
||||
table.CUL_WS { border:thin solid; width: 100%; background: #FFC0C0; }
|
||||
table.CUL_WS tr.odd { background: #FFD7D7; }
|
||||
|
||||
|
||||
table.FHEMWEB { border:thin solid; width: 100%; background: #E0E0E0; }
|
||||
table.FHEMWEB tr.odd { background: #F0F0F0; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user