2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

00_ZWDongle.pm: neighbor map fixes / enhancements (Forum #54574)

git-svn-id: https://svn.fhem.de/fhem/trunk@11788 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-07-12 12:43:37 +00:00
parent 8100a9ed43
commit 239d43ef60
8 changed files with 98 additions and 44 deletions

View File

@ -175,13 +175,23 @@ ZWDongle_nlData($)
for my $e (@a) {
next if($defs{$e}{ZWaveSubDevice} ne "no");
my $title = ReadingsVal($e, "timeToAck", "");
$title = "timeToAck: $title" if($title);
my $img = ZWave_getPic(ReadingsVal($e, "modelId", ""));
my $nl = ReadingsVal($e, "neighborList", "");
$nl =~ s/,/ /g; $nl =~ s/\bempty\b//g;
my $pos = AttrVal($e, "neighborListPos", "");
push @dn, $e if($nl =~ m/\b$d\b/);
$nl = '"'.join('","',split(" ", $nl)).'"' if($nl);
push @ret, "\"$e\":{\"txt\":\"$e\",\"pos\":[$pos],".
"\"class\":\"zwBox\",\"neighbors\":[$nl] }";
push @ret, "\"$e\":{\"txt\":\"$e\",\"pos\":[$pos],\"class\":\"zwBox\",".
"\"neighbors\":[$nl]".
($title ? ",\"title\" : \"$title\"" : "").
($img ? ",\"img\" : \"$img\"" : "").
"}";
$nb{$e} = $nl;
}
my $pos = AttrVal($d, "neighborListPos", "");

View File

@ -4246,6 +4246,24 @@ ZWave_helpFn($$)
return $ret;
}
sub
ZWave_getPic($)
{
my ($model) = @_;
my $img = $zwave_pepperImg{$model};
return "" if(!$img);
my $fn = $attr{global}{modpath}."/www/deviceimages/zwave/$img";
if(!-f $fn) { # Cache the picture
my $data = GetFileFromURL("http://fhem.de/deviceimages/zwave/$img");
if($data && open(FH,">$fn")) {
print FH $data;
close(FH)
}
}
return "$FW_ME/deviceimages/zwave/$img";
}
sub
ZWave_fhemwebFn($$$$)
{

View File

@ -108,9 +108,9 @@ div#svgmarker {
div.detLink { display:inline-block; margin-right:0.5em; }
.zwBox { stroke:#333333; stroke-width:2px; fill:#eeeeee; }
.zwDongle { stroke:red; stroke-width:2px; fill:#eeeeee; }
.zwMargin { stroke:#333333; stroke-width:1px; fill:none; }
.zwLine { stroke:#333333; stroke-width:1px; }
.zwArrowHead { fill:#333333; stroke-width:1px; }
svg.zw_nr .zwBox { stroke:#333333; stroke-width:2px; fill:#eeeeee; }
svg.zw_nr .zwDongle { stroke:red; stroke-width:2px; fill:#eeeeee; }
svg.zw_nr .zwMargin { stroke:#333333; stroke-width:1px; fill:none; }
svg.zw_nr .zwLine { stroke:#333333; stroke-width:1px; }
svg.zw_nr .zwArrowHead { fill:#333333; stroke-width:1px; }
svg.zw_nr { height:auto; width:auto; margin:0; }

View File

@ -14,9 +14,9 @@ div.detLink { display:inline-block; margin-right:0.5em; }
.fhemlog { color:#FFFFFF; }
.zwBox { stroke:#fff; stroke-width:2px; fill:#000; }
.zwDongle { stroke:red; stroke-width:2px; fill:#000; }
.zwMargin { stroke:#fff; stroke-width:1px; fill:none; }
.zwLine { stroke:#fff; stroke-width:1px; }
.zwArrowHead { fill:#fff; stroke-width:1px; }
svg.zw_nr .zwBox { stroke:#fff; stroke-width:2px; fill:#000; }
svg.zw_nr .zwDongle { stroke:red; stroke-width:2px; fill:#000; }
svg.zw_nr .zwMargin { stroke:#fff; stroke-width:1px; fill:none; }
svg.zw_nr .zwLine { stroke:#fff; stroke-width:1px; }
svg.zw_nr .zwArrowHead { fill:#fff; stroke-width:1px; }
svg.zw_nr { height:auto; width:auto; margin:0; }

View File

@ -133,9 +133,9 @@ select [value^=l6] { color: olive; }
select [value^=l7] { color: gray; }
select [value^=l8] { color: yellow; }
.zwBox { stroke:#278727; stroke-width:2px; fill:#F0F0D8; }
.zwDongle { stroke:red; stroke-width:2px; fill:#F0F0D8; }
.zwMargin { stroke:#278727; stroke-width:1px; fill:none; }
.zwLine { stroke:#278727; stroke-width:1px; }
.zwArrowHead { fill:#278727; stroke-width:1px; }
svg.zw_nr .zwBox { stroke:#278727; stroke-width:2px; fill:#F0F0D8; }
svg.zw_nr .zwDongle { stroke:red; stroke-width:2px; fill:#F0F0D8; }
svg.zw_nr .zwMargin { stroke:#278727; stroke-width:1px; fill:none; }
svg.zw_nr .zwLine { stroke:#278727; stroke-width:1px; }
svg.zw_nr .zwArrowHead { fill:#278727; stroke-width:1px; }
svg.zw_nr { height:auto; width:auto; margin:0; }

View File

@ -250,9 +250,9 @@ div#svgmarker {
border:1px solid #fff; border-radius:4px;
}
.zwBox { stroke:#c0c0c0; stroke-width:2px; fill:#f7f7f7; }
.zwDongle { stroke:red; stroke-width:2px; fill:#f7f7f7; }
.zwMargin { stroke:#c0c0c0; stroke-width:1px; fill:none; }
.zwLine { stroke:#c0c0c0; stroke-width:1px; }
.zwArrowHead { fill:#c0c0c0; stroke-width:1px; }
svg.zw_nr .zwBox { stroke:#c0c0c0; stroke-width:2px; fill:#f7f7f7; }
svg.zw_nr .zwDongle { stroke:red; stroke-width:2px; fill:#f7f7f7; }
svg.zw_nr .zwMargin { stroke:#c0c0c0; stroke-width:1px; fill:none; }
svg.zw_nr .zwLine { stroke:#c0c0c0; stroke-width:1px; }
svg.zw_nr .zwArrowHead { fill:#c0c0c0; stroke-width:1px; }
svg.zw_nr { height:auto; width:auto; margin:0; }

View File

@ -29,9 +29,9 @@ div#svgmarker {
color:black; background:#e5e5e5;
}
.zwBox { stroke:#c0c0c0; stroke-width:2px; fill:#f7f7f7; }
.zwDongle { stroke:red; stroke-width:2px; fill:#f7f7f7; }
.zwMargin { stroke:#c0c0c0; stroke-width:1px; fill:none; }
.zwLine { stroke:#c0c0c0; stroke-width:1px; }
.zwArrowHead { fill:#147bff; stroke-width:1px; }
svg.zw_nr .zwBox { stroke:#c0c0c0; stroke-width:2px; fill:#f7f7f7; }
svg.zw_nr .zwDongle { stroke:red; stroke-width:2px; fill:#f7f7f7; }
svg.zw_nr .zwMargin { stroke:#c0c0c0; stroke-width:1px; fill:none; }
svg.zw_nr .zwLine { stroke:#c0c0c0; stroke-width:1px; }
svg.zw_nr .zwArrowHead { fill:#147bff; stroke-width:1px; }
svg.zw_nr { height:auto; width:auto; margin:0; }

View File

@ -1,8 +1,6 @@
var zw_visible;
var svgns = 'xmlns="http://www.w3.org/2000/svg"';
log("HELLO");
function
zw_nl(fhemFn)
{
@ -34,7 +32,12 @@ zw_nl(fhemFn)
el.lines = [];
el.name = elName;
el.elHash = fnRet.el;
el.width = el.height = 30;
if(el.img) {
el.width = 64; el.height = 64+20;
} else {
el.width = el.height = 30;
}
if(!el.pos.length) {
el.pos = [xpos, ypos];
xpos += 150;
@ -102,17 +105,25 @@ zw_draw(fnRet, width, height)
.css({width:width, height:height})
.html(svg);
$("svg g").each(function(){
var name = $(this).attr("data-name");
var text = $(this).find("text");
var rect = $(this).find("rect");
var w = $(text)[0].getBBox().width;
$(rect).attr("width",w+10);
$(this).find("rect").attr("width",w+10);
$("svg.zw_nr g").each(function(){
$(this).css({cursor:"pointer", position:"absolute"}); // firefox is relative
h[name].width = w+10;
h[name].rect = rect;
h[name].text = text;
var name = $(this).attr("data-name");
var o = h[name];
o.text = $(this).find("text");
o.rect = $(this).find("rect");
if(o.img) {
o.image = $(this).find("image");
o.imgOffX = 0;
}
o.width = $(o.text)[0].getBBox().width+10;
if(o.img && o.width < 64)
o.width = 64;
if(o.image) {
o.imgOffX = (o.width-60)/2;
$(o.image).attr("x", o.x+o.imgOffX);
}
$(o.rect).attr("width",o.width);
zw_adjustLines(h, name);
})
.draggable()
@ -126,6 +137,10 @@ zw_draw(fnRet, width, height)
o.y = oy + (p.top -op.top);
$(o.rect).attr("x", o.x); $(o.rect).attr("y", o.y);
$(o.text).attr("x", o.x+5); $(o.text).attr("y", o.y+20);
if(o.image) {
$(o.image).attr("x", o.x+o.imgOffX);
$(o.image).attr("y", o.y+20);
}
zw_adjustLines(h, o.name);
});
}
@ -133,10 +148,17 @@ zw_draw(fnRet, width, height)
function
zw_drawbox(o)
{
var s = '<g data-name="'+o.txt+'">'+
'<rect x="'+o.x+'" y="'+o.y+'" rx="5" ry="5" '+
var s = '';
s += '<g data-name="'+o.txt+'">';
if(o.title)
s += '<title>'+o.title+'</title>';
s += '<rect x="'+o.x+'" y="'+o.y+'" rx="5" ry="5" '+
'width="'+o.width+'" height="'+o.height+'" class="'+o.class+'"/>';
s += '<text x="'+(o.x+5)+'" y="'+(o.y+20)+'">'+o.txt+'</text></g>';
if(o.img)
s += '<image x="'+(o.x+2)+'" y="'+(o.y+20)+'"/ width="60" height="60" '+
'xlink:href="'+o.img+'"/>';
s += '<text x="'+(o.x+5)+'" y="'+(o.y+20)+'">'+o.txt+'</text>'
s +='</g>';
return s;
}
@ -520,7 +542,11 @@ GM()
{
$(this.rect).attr("x", this.x); $(this.rect).attr("y", this.y);
$(this.text).attr("x", this.x+5); $(this.text).attr("y", this.y+20);
zw_adjustLines(this.elHash, this.name);
if(this.image) {
$(this.image).attr("x", this.x+this.imgOffX);
$(this.image).attr("y", this.y+20);
}
zw_adjustLines(this.elHash, this.name, 0);
this.x+=this.speedX/damper;
this.y+=this.speedY/damper;