Rule Examples/en: различия между версиями

Новая страница: «<syntaxhighlight lang="ecmascript"> function makeMotionDetector(name, timeout_ms, detector_control, relay_control) { var motion_timer_id = null; defineRule(name, { whenChanged: "wb-gpio/" + detector_control, then: function(newValue, devName, cellName) { if (!newValue) { dev["wb-gpio"][relay_control] = true; if (motion_timer_id) { clearTimeout(motion_timer_id); }»
(Новая страница: «<syntaxhighlight lang="ecmascript"> var motion_timer_1_timeout_ms = 30 * 1000; var motion_timer_1_id = null;»)
(Новая страница: «<syntaxhighlight lang="ecmascript"> function makeMotionDetector(name, timeout_ms, detector_control, relay_control) { var motion_timer_id = null; defineRule(name, { whenChanged: "wb-gpio/" + detector_control, then: function(newValue, devName, cellName) { if (!newValue) { dev["wb-gpio"][relay_control] = true; if (motion_timer_id) { clearTimeout(motion_timer_id); }»)
Строка 82: Строка 82:
If you need several such motion detectors, then in order not to copy the code, you can wrap the creation of the rule and variables in a function:
If you need several such motion detectors, then in order not to copy the code, you can wrap the creation of the rule and variables in a function:


<div lang="ru" dir="ltr" class="mw-content-ltr">
<syntaxhighlight lang="ecmascript">
<syntaxhighlight lang="ecmascript">
  function makeMotionDetector(name, timeout_ms, detector_control, relay_control) {
  function makeMotionDetector(name, timeout_ms, detector_control, relay_control) {
Строка 94: Строка 93:
                   clearTimeout(motion_timer_id);
                   clearTimeout(motion_timer_id);
               }
               }
</div>


               <div lang="ru" dir="ltr" class="mw-content-ltr">
               <div lang="ru" dir="ltr" class="mw-content-ltr">
translator, wb_editors
4344

правки