Difference between revisions of "Virtual"

From Larnitech wiki page
Jump to navigation Jump to search
(Marked this version for translation)
 
Line 54: Line 54:
 
The script  processing of stroke
 
The script  processing of stroke
 
<syntaxhighlight lang="cpp" line>
 
<syntaxhighlight lang="cpp" line>
u8 state[2] = {0,0};
+
u8 dim = 0;
V-ID/142:99
+
 
{
+
V-ID/Dimmer{
    if (opt(0)==0xff){
+
  if (opt(0)==0xff)
        if (state[0]==0) state[0] = 1;
+
    setStatus(Dimmer,{1,dim});
        else state[0] = 0;
+
  else if (opt(0)==0xfe){
    }else (opt(0)==0xfe){
+
     dim=opt(1);
    state[0]=state[0];
+
     setStatus(Dimmer,{1,dim});
     }else {
+
  }
    state[0]=opt(0);
 
     }
 
 
    if(opt(1)==0xfe){
 
    state[1]=state[1];
 
    }else {
 
  state[1]=opt(1);
 
    }
 
    setStatus(142:99,state); 
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
</translate>
 
</translate>

Latest revision as of 14:29, 7 November 2025

Other languages:
English • ‎русский

Example of description in XML

1<item addr="333:132" name="sensor" type="virtual" sub-type="sensor" dim="%" length="2"/>
2<item addr="333:145" name="Text" type="virtual" sub-type="text" length="0"/>

Parameters

Name type and variety description
sub-type enum sensor – virtual sensor

text – virtual sensor of text type (UTF8), length is to be equal to 0
long-text – virtual field of text type (UTF8), length is to be equal to 0
Devices that need script to track the status (see the example below the table):
lamp, dimer-lamp, rgb-lamp, jalousie, gate, gate120, jalousie120
prf – with formatted set of status, the description isbelow
length* number status size, bytes
0 – dynamic size (obvious for the elements of "sub-type=text" type)
dim symbol Symbol added to the end of virtual sensor value (for example, % or С)

* – required fields

Example of virtual device "lamp"

1<item addr="142:99" length="1" name="Lamp" sub-type="lamp" type="virtual"/>

The processing of pressing in the script

1u8 state = 0;
2V-ID/142:99 {
3    if (opt(0)==0xff){//pressing the element in the interface
4        if (state==0) state = 1;
5        else state = 0;
6        setStatus(142:99,state);//for correct displaying in the interface
7    }
8}

Example of virtual device "dimmable lamp"

1<item addr="142:99" length="2" name="Lamp" sub-type="dimer-lamp" type="virtual"/>

The script processing of stroke

 1u8 dim = 0;
 2
 3V-ID/Dimmer{
 4  if (opt(0)==0xff)
 5    setStatus(Dimmer,{1,dim});
 6  else if (opt(0)==0xfe){
 7    dim=opt(1);
 8    setStatus(Dimmer,{1,dim});
 9  }
10}