mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 01:09:47 +00:00
98_SVG.pm/98_autocreate.pm: Renaming the gplotFile is not done in the SVG:WriteGplotFile, but in autocreate (Forum #41246)
git-svn-id: https://svn.fhem.de/fhem/trunk@9414 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9cb802c0a5
commit
6b47145f08
@ -116,6 +116,7 @@ SVG_Set($@)
|
||||
if($cmd ne "copyGplotFile");
|
||||
|
||||
my $srcName = "$FW_gplotdir/$hash->{GPLOTFILE}.gplot";
|
||||
my ($og,$od) = ($hash->{GPLOTFILE}, $hash->{DEF});
|
||||
$hash->{GPLOTFILE} = $hash->{NAME};
|
||||
my $dstName = "$FW_gplotdir/$hash->{GPLOTFILE}.gplot";
|
||||
return "this is already a unique gplot file" if($srcName eq $dstName);
|
||||
@ -126,6 +127,12 @@ SVG_Set($@)
|
||||
my ($err,@rows) = FileRead($srcName);
|
||||
return $err if($err);
|
||||
$err = FileWrite($dstName, @rows);
|
||||
|
||||
if($err) {
|
||||
$hash->{DEF} = $od; $hash->{GPLOTFILE} = $og;
|
||||
} else {
|
||||
addStructChange("modify", $me, "$me $hash->{DEF}")
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
@ -469,6 +476,21 @@ SVG_PEdit($$$$)
|
||||
$ret .= "<tr class=\"".(($r++&1)?"odd":"even")."\"><td colspan=\"3\">";
|
||||
$ret .= "Example lines for input:<br>$example</td></tr>";
|
||||
|
||||
my %gpf;
|
||||
map {
|
||||
$gpf{$defs{$_}{GPLOTFILE}}{$_} = 1 if($defs{$_}{TYPE} eq "SVG");
|
||||
} sort keys %defs;
|
||||
|
||||
if(int(keys %{$gpf{$defs{$d}{GPLOTFILE}}}) > 1) {
|
||||
$ret .= "<tr class='".(($r++&1)?"odd":"even")."'><td colspan='3'>".
|
||||
"<b>Note:</b>".
|
||||
"The .gplot file ($defs{$d}{GPLOTFILE}) is used by multiple SVG ".
|
||||
"devices (".join(",", sort keys %{$gpf{$defs{$d}{GPLOTFILE}}})."), ".
|
||||
"writing probably will corrupt the other SVGs. ".
|
||||
"Remedy: execute set $d copyGplotFile".
|
||||
"</td></tr>";
|
||||
}
|
||||
|
||||
$ret .= "<tr class=\"".(($r++&1)?"odd":"even")."\"><td colspan=\"3\">";
|
||||
$ret .= FW_submit("submit", "Write .gplot file")." ".
|
||||
FW_submit("showFileLogData", "Show preprocessed input").
|
||||
@ -609,13 +631,6 @@ SVG_WriteGplot($)
|
||||
$maxLines = $1 if($1 > $maxLines);
|
||||
}
|
||||
|
||||
my $wlName = $FW_webArgs{detail};
|
||||
my $hash = $defs{$wlName};
|
||||
if($hash->{GPLOTFILE} ne $wlName) {
|
||||
Log 1, "WriteGplot: calling set $wlName copyGplotFile";
|
||||
SVG_Set($hash, $wlName, "copyGplotFile");
|
||||
}
|
||||
|
||||
my @rows;
|
||||
push @rows, "# Created by FHEM/98_SVG.pm, ".TimeNow();
|
||||
push @rows, "set terminal png transparent size <SIZE> crop";
|
||||
@ -665,6 +680,7 @@ SVG_WriteGplot($)
|
||||
push @rows, $r;
|
||||
}
|
||||
|
||||
my $hash = $defs{$FW_webArgs{detail}};
|
||||
my $err = FileWrite("$FW_gplotdir/$hash->{GPLOTFILE}.gplot", @rows);
|
||||
$FW_RET .= "<div id='errmsg'>SVG_WriteGplot: $err</div>" if($err);
|
||||
|
||||
|
@ -121,7 +121,8 @@ autocreate_Notify($$)
|
||||
my $temporary;
|
||||
|
||||
################
|
||||
if($s =~ m/^UNDEFINED -temporary/) { # Special for EnOcean. DO NOT use it elsewhere
|
||||
# Special for EnOcean. DO NOT use it elsewhere
|
||||
if($s =~ m/^UNDEFINED -temporary/) {
|
||||
$temporary = 1;
|
||||
$s =~ s/ -temporary//;
|
||||
}
|
||||
@ -135,7 +136,7 @@ autocreate_Notify($$)
|
||||
|
||||
my $at = AttrVal($me, "autocreateThreshold", undef);
|
||||
LoadModule($type) if( !$at );
|
||||
if( $at || $modules{$type}{AutoCreate} ) {
|
||||
if($at) {
|
||||
my @at = split( '[, ]', $at?$at:"" );
|
||||
|
||||
my $hash = $defs{$me};
|
||||
@ -227,6 +228,7 @@ autocreate_Notify($$)
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$hash = $defs{$name};
|
||||
$nrcreated++;
|
||||
my $room = replace_wildcards($hash, AttrVal($me, "device_room", "%TYPE"));
|
||||
@ -288,12 +290,18 @@ autocreate_Notify($$)
|
||||
Log3 $me, 2, "autocreate: define $cmd";
|
||||
$ret = CommandDefine(undef, $cmd);
|
||||
if($ret) {
|
||||
Log3 $me, 1, "ERROR: $ret";
|
||||
Log3 $me, 1, "ERROR: define $cmd: $ret";
|
||||
last;
|
||||
}
|
||||
$attr{$wlname}{room} = $room if($room);
|
||||
$attr{$wlname}{label} = '"' . $name .
|
||||
' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
|
||||
|
||||
$ret = CommandSet(undef, "$wlname copyGplotFile");
|
||||
if($ret) {
|
||||
Log3 $me, 1, "ERROR: set $wlname copyGplotFile: $ret";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user