Форматирование виртуального устройства

From Larnitech wiki page
Revision as of 14:37, 26 January 2022 by Rusanov (talk | contribs) (Created page with "===описание атрибута prf===")
Jump to navigation Jump to search
Other languages:
English • ‎русский

Пример описания в XML

1<item addr="100:245" back-rgba="0xff7100ff" iw-="1" length="5" name="aa" prf="prf('A: %d\10B: %ds dhjhfg hdfj dfhdfh', device(100, 247).status(0) $ 7, status(1))" sub-type="prf" text-rgb="0xffffff" title-rgb="0xff00" type="virtual"/>

Параметры

Название Тип и диапазон Описание
iw число;
1, 2, 3..
Ширина текстового поля
back-rgba число;
0xRRGGBBAA
Настройка фона текстового поля. RR – насыщенность красного, 0..0хFF; GG – насыщенность зеленого, 0..0xFF; BB – насыщенность синего, 0..0xFF; AA – насыщенность фона, 0..0xFF
text-rgb число;
0xRRGGBB
Настройка цвета текста. RR – насыщенность красного, 0..0хFF; GG – насыщенность зеленого, 0..0xFF; BB – насыщенность синего, 0..0xFF.
title-rgb число;
0xRRGGBB
RR – насыщенность красного, 0..0хFF; GG – насыщенность зеленого, 0..0xFF; BB – насыщенность синего, 0..0xFF
prf строка; Описание статуса устройства.
Статус имеет формат sprintf.
Размер статуса не должен превышать 256 байт.
В устройстве хранятся только указанные данные, текст не сохраняется в статус. Подробное описание ниже.

описание атрибута prf

prf="prf('TEXT %[flags][wigth][.precision]type', STATUS)"

  • TEXT – unchangeable text to be displayed;
  • flags, wigth, precision, type – status formatting description, see sprintf.
  • STATUS – status description
    • id() – device id, u16
    • subId() – device subId, u8
    • addr() – device address, u32
    • addrString() – device address textually
    • statusStringHex() – device status string as hexadecimal notation
    • statusString() – string with the device status
    • statusString(u32 byteOffset = 0) – string with the device status with byteOffset offset
    • statusString(u32 byteOffset=0, u32 len=0) – string with the device status with byteOffset offset and length len
    • status() – device status, i8
    • status(u32 byteOffset = 0) – device status with byteOffset offset, i8
    • statusU() – device status, u8
    • statusBit1Count() – number of status bit(?)
    • statusRgb() – RGB status, 0xRRGGBB
    • statusU16(u32 byteOffset=0) – device status, u16
    • statusU32(u32 byteOffset=0) – device status, u32
    • statusBit(u32 byteOffset=0, u32 bitOffset=0) – state of status bit with bitOffset offset, with byteOffset byte offset,
    • statusBit(u32 bitOffset=0) – state of status bit with bitOffset offset
    • statusBits(u32 byteOffset=0, u32 bitOffset=0, u32 len=0) – len bit status starting from bitOffset of byteOffset byte
    • statusBits(u32 bitOffset=0, u32 len=0) – len bit status starting from bitOffset
    • statusFloat() – status fractional (status/250)
    • statusFloat() – status unsigned fractional (status/250)
    • statusFloat2(u32 byteOffset=0) – status fractional (status/256)
    • statusFloat2U(u32 byteOffset=0) – status unsigned fractional (status/256) with byteOffset offset
    • statusFloat(u32 byteOffset=0) – status fractional (status/250) with byteOffset offset
    • statusLevel() – level (for example, dimmer)
    • statusFloatString() – string with status fractional (status/250)
    • statusFloatString(u32 byteOffset = 0) – string with status fractional (status/250) with byteOffset offset
    • statusFloatString2() – string with status fractional (status/256)
    • statusFloatString2(u32 byteOffset=0) – string with status fractional (status/256) with byteOffset offset


It is also possible to specify the conditions, for example:

prf=" prf('Text%s', status(0)?'Yes':'No')

if status(0) is true "Text Yes" will be displayed, otherwise "Text No" appears

Or receive the devices status. For example, there is a curtain 343:22 and a lamp 299:1:

1prf="string a[] ={'Closed', 'Open', 'Is closing', 'Is opening'};  prf('Curtain%s\10Data %d \10Status: %s\10 String%s',a[device(343:22)->status(0)], status(0), (device(299:21)->status(0) $7)?'On':'Off',statusString(1))"

Status setting for such an element is the following: setStatus(299:201,{134,"Text"});

After status setting in the text field the following will be displayed:

"Curtain is opening Data 134 Status On String Text"

"Curtain" will depend on curtain status,

"Status" will be "Off" if 0 byte with mask of 7 status 299:21 equals to zero, otherwise "Status" will be "On"