SVG-Dashboards/en: различия между версиями

Новая страница: «The option '''Stretch to full screen''' will fit the panel to the free space.»
(Новая страница: «=== MQTT topic value === The value from the MQTT topic specified in the '''Channel''' field is placed into the '''val''' variable.»)
Метки: правка с мобильного устройства правка из мобильной версии
(Новая страница: «The option '''Stretch to full screen''' will fit the panel to the free space.»)
Строка 93: Строка 93:
</syntaxhighlight>
</syntaxhighlight>


<div lang="ru" dir="ltr" class="mw-content-ltr">
For example, if the value of the MQTT topic is equal to <code>1</code> , then print the value <code>ВКЛ</code> , otherwise — <code>ОТКЛ</code> :
Например, если значение MQTT-топика будет равно <code>1</code>, то вывести значение <code>ВКЛ</code>, иначе — <code>ОТКЛ</code>:
<syntaxhighlight lang="javascript">  
<syntaxhighlight lang="javascript">
(val == 1) ? 'ON' : 'OFF'
(val == 1) ? 'ВКЛ' : 'ОТКЛ'
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Arithmetic operations ===
=== Арифметические операции ===
Simple arithmetic operations can be performed on a topic received from an MQTT topic:
Над полученным из MQTT-топика можно совершать простые арифметические операции:
* <code>+</code> — addition
* <code>+</code> — сложение
* <code>-</code> — subtraction
* <code>-</code> — вычитание
* <code>*</code> — multiplication
* <code>*</code> — умножение
* <code>/</code> — division
* <code>/</code> — деление
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
For example, output the value <code>АВАРИЯ</code> if the value in the MQTT topic multiplied by 0.1 is greater than 20 and <code>НОРМА</code> otherwise:
Например, выведем значение <code>АВАРИЯ</code>, если значение в MQTT-топике, умноженное на 0.1 больше 20 и <code>НОРМА</code> в остальных случаях:
<syntaxhighlight lang="javascript">  
<syntaxhighlight lang="javascript">
(val*0.1>20) ? 'ALARM' : 'NORMAL'
(val*0.1>20) ? 'АВАРИЯ' : 'НОРМА'
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Rounding values ===
=== Округление значений ===
Often, values from sensors come with several decimal places, if you do not need such accuracy in the svg panel, then they can be rounded:
Часто с датчиков поступают значения с несколькими знаками после запятой, если вам не нужна такая точность в svg-панели, то их можно округлить:
<syntaxhighlight lang="javascript">  
<syntaxhighlight lang="javascript">
val.toFixed(n) //round the value of the variable val to n decimal places
val.toFixed(n) //округлить значение переменной val до n знаков после запятой
val.toFixed(2) //round the value of the variable val to two decimal places 220.238 → 220.24
val.toFixed(2) //округлить значение переменной val до двух знаков после запятой 220.238 → 220.24
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
<div lang="ru" dir="ltr" class="mw-content-ltr">