2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

fhemweb.js: add bitmask to bitfield, fix ZWave bitfield help (Forum #102579);

git-svn-id: https://svn.fhem.de/fhem/trunk@19951 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-08-04 20:35:52 +00:00
parent 479c12b5a4
commit d4359483c6
2 changed files with 23 additions and 11 deletions

View File

@ -2707,6 +2707,7 @@ ZWave_configParseModel($;$)
$h{min} = $1 if($line =~ m/min="([^"]*)"/i); $h{min} = $1 if($line =~ m/min="([^"]*)"/i);
$h{max} = $1 if($line =~ m/max="([^"]*)"/i); $h{max} = $1 if($line =~ m/max="([^"]*)"/i);
$h{value} = $1 if($line =~ m/value="([^"]*)"/i); $h{value} = $1 if($line =~ m/value="([^"]*)"/i);
$h{bitmask}= $1 if($line =~ m/bitmask="([^"]*)"/i);
$h{index} = $1 if($line =~ m/index="([^"]*)"/i); # 1, 2, etc $h{index} = $1 if($line =~ m/index="([^"]*)"/i); # 1, 2, etc
$h{read_only} = $1 if($line =~ m/read_only="([^"]*)"/i); # true,false $h{read_only} = $1 if($line =~ m/read_only="([^"]*)"/i); # true,false
$h{write_only} = $1 if($line =~ m/write_only="([^"]*)"/i); # true,false $h{write_only} = $1 if($line =~ m/write_only="([^"]*)"/i); # true,false
@ -2724,7 +2725,7 @@ ZWave_configParseModel($;$)
$bsHelp = ""; $partial = ""; $bsHelp = ""; $partial = "";
} }
if($line =~ m,<BitSet\sid="(.*)">,) { if($line =~ m,<BitSet\s+id="(.*)">,) {
$bsHelp = "Bit $1: "; $bsHelp = "Bit $1: ";
next; next;
} }
@ -2734,15 +2735,15 @@ ZWave_configParseModel($;$)
} }
if($partial) { if($partial) {
if($line =~ m,</Help>,) { if($line =~ m,</Help>,) {
$line = $bsHelp.$partial.$line; $line = $partial.$line;
$line =~ s/[\r\n]//gs; $line =~ s/[\r\n]//gs;
$partial = ""; $partial = "";
$bsHelp="";
} else { } else {
$partial .= $line; $partial .= $line;
next; next;
} }
} }
if($line =~ m+<Help>(.*)</Help>+s) { if($line =~ m+<Help>(.*)</Help>+s) {
$hash{$cmdName}{Help} .= "$bsHelp$1<br>"; $hash{$cmdName}{Help} .= "$bsHelp$1<br>";
$bsHelp=""; $bsHelp="";
@ -2770,8 +2771,10 @@ ZWave_configParseModel($;$)
my $caName = "$cfg$cmd"; my $caName = "$cfg$cmd";
$zwave_cmdArgs{set}{$caName} = join(",", keys %{$h->{Item}}) if($h->{Item}); $zwave_cmdArgs{set}{$caName} = join(",", keys %{$h->{Item}}) if($h->{Item});
$zwave_cmdArgs{set}{$caName} = "noArg" if($h->{type} eq "button"); $zwave_cmdArgs{set}{$caName} = "noArg" if($h->{type} eq "button");
$zwave_cmdArgs{set}{$caName} = "bitfield,".$h->{size}*8 if($h->{type} eq "bitset") {
if($h->{type} eq "bitset"); $zwave_cmdArgs{set}{$caName} =
"bitfield,".($h->{size}*8).($h->{bitmask} ? ",$h->{bitmask}":"");
}
$zwave_cmdArgs{get}{$caName} = "noArg"; $zwave_cmdArgs{get}{$caName} = "noArg";
} }

View File

@ -1834,7 +1834,8 @@ FW_createBitfield(elName, devName, vArr, currVal, set, params, cmd)
if(vArr[0] != "bitfield") if(vArr[0] != "bitfield")
return undef; return undef;
elName = elName.replace(/[^A-Z0-9_]/ig, '_'); elName = elName.replace(/[^A-Z0-9_]/ig, '_');
var fieldSize = (vArr.length == 1 ? 8 : parseInt(vArr[1])); var fieldSize = (vArr.length > 1 ? parseInt(vArr[1]) : 8);
var bitMask = (vArr.length > 2 ? parseInt(vArr[2]) : 4294967295);
var html = '<div style="display:inline-block" tabindex="0">'+ var html = '<div style="display:inline-block" tabindex="0">'+
'<input type="hidden" name="'+elName+'">'+ '<input type="hidden" name="'+elName+'">'+
'<table id="'+elName+'_bitfield">'; '<table id="'+elName+'_bitfield">';
@ -1848,6 +1849,13 @@ FW_createBitfield(elName, devName, vArr, currVal, set, params, cmd)
var newEl = $(html).get(0); var newEl = $(html).get(0);
newEl.activateFn = function() { newEl.activateFn = function() {
var bm = bitMask;
for(var i1=1; i1<=fieldSize; i1++) {
$('#'+elName+'_bitfield input[value='+i1+']')
.prop("disabled", (bm%2 == 0));
bm = parseInt(bm/2);
}
$("#"+elName+"_bitfield input").change(function(){ $("#"+elName+"_bitfield input").change(function(){
var total = 0; var total = 0;
$("#"+elName+"_bitfield input").each(function(){ $("#"+elName+"_bitfield input").each(function(){
@ -2025,8 +2033,8 @@ FW_getSVG(emb)
exponent, e.g. 0.0625.</li> exponent, e.g. 0.0625.</li>
<li>select,&lt;val1&gt;,&lt;val2&gt;,... - show a dropdown with all values. <li>select,&lt;val1&gt;,&lt;val2&gt;,... - show a dropdown with all values.
<b>NOTE</b>: this is also the fallback, if no modifier is found.</li> <b>NOTE</b>: this is also the fallback, if no modifier is found.</li>
<li>bitfield,&lt;size&gt; - show a table of checkboxes (8 per line) <li>bitfield,&lt;size&gt;&lt;mask&gt; - show a table of checkboxes (8 per
to set single bits. Default for size is 8.</li> line) to set single bits. Default for size is 8 and for mask 2^32-1</li>
=end html =end html
@ -2057,9 +2065,10 @@ FW_getSVG(emb)
<li>select,&lt;val1&gt;,&lt;val2&gt;,... - zeigt ein HTML select mit allen <li>select,&lt;val1&gt;,&lt;val2&gt;,... - zeigt ein HTML select mit allen
Werten. <b>Achtung</b>: so ein Widget wird auch dann angezeigt, falls Werten. <b>Achtung</b>: so ein Widget wird auch dann angezeigt, falls
kein passender Modifier gefunden wurde.</li> kein passender Modifier gefunden wurde.</li>
<li>bitfield,&lt;size&gt; - zeigt eine Tabelle von Kontrollk&auml;stchen (8 <li>bitfield,&lt;size&gt;,&lt;mask&gt; - zeigt eine Tabelle von
pro Zeile), um einzelne Bits setzen zu koennen. Die Voreinstellung fuer Kontrollk&auml;stchen (8 pro Zeile), um einzelne Bits setzen zu koennen.
size ist 8.</li> Die Voreinstellung fuer size ist 8 und fuer mask 2^32-1.</li>
=end html_DE =end html_DE