wb_editors
42
правки
Brainroot (обсуждение | вклад) |
Sikmir (обсуждение | вклад) |
||
Строка 3: | Строка 3: | ||
You can write rules for the controller, for example: "If the sensor temperature is less than 18°C, turn on the heater." Rules are created via [[Веб-интерфейс Wiren Board/en|web interface]] and written in a simple language similar to Javascript. | You can write rules for the controller, for example: "If the sensor temperature is less than 18°C, turn on the heater." Rules are created via [[Веб-интерфейс Wiren Board/en|web interface]] and written in a simple language similar to Javascript. | ||
The complete description of the rules engine: https://github.com/ | The complete description of the rules engine: https://github.com/wirenboard/wb-rules | ||
Строка 15: | Строка 15: | ||
Notes: | Notes: | ||
#The rules files are stored on the controller as plain text files in the <code>/etc/wb-rules/</code> folder, so they [[Просмотр файлов контроллера с компьютера/en|can be edited and downloaded]] directly from your computer. | #The rules files are stored on the controller as plain text files in the <code>/etc/wb-rules/</code> folder, so they [[Просмотр файлов контроллера с компьютера/en|can be edited and downloaded]] directly from your computer. | ||
#The rules are executed by the ''wb-rules'' service, see the service's [https://github.com/ | #The rules are executed by the ''wb-rules'' service, see the service's [https://github.com/wirenboard/wb-rules documentation on Github]. | ||
== Writing the first rule== | == Writing the first rule == | ||
[[File:Web-scripts-rule1.png|400px|thumb|The rule for the heater control, written via the web interface]] | [[File:Web-scripts-rule1.png|400px|thumb|The rule for the heater control, written via the web interface]] | ||
Строка 86: | Строка 86: | ||
#* on the same page below; | #* on the same page below; | ||
#* in [http://forums.contactless.ru/t/dvizhok-pravil-primery-koda/483 a special topic on our forum(ru)]. | #* in [http://forums.contactless.ru/t/dvizhok-pravil-primery-koda/483 a special topic on our forum(ru)]. | ||
#[https://github.com/ | #[https://github.com/wirenboard/wb-rules Full description of the rules engine]. | ||
Строка 386: | Строка 386: | ||
Some rules come with the default rule system in the wb-rules-system package. | Some rules come with the default rule system in the wb-rules-system package. | ||
Full list of rules is[https://github.com/ | Full list of rules is [https://github.com/wirenboard/wb-rules-system/tree/master/rules in the repository.]. | ||
Some examples: | Some examples: | ||
Строка 394: | Строка 394: | ||
==== The rule for the buzzer==== | ==== The rule for the buzzer==== | ||
The [https://github.com/ | The [https://github.com/wirenboard/wb-rules-system/blob/master/rules/buzzer.js rule] creates a virtual buzzer device with sliders to adjust the volume and frequency, as well as a button to turn on the sound. | ||
Строка 469: | Строка 469: | ||
==== Power status rule ==== | ==== Power status rule ==== | ||
[https://github.com/ | [https://github.com/wirenboard/wb-rules-system/blob/master/rules/power_status.js The rule] creates a virtual device that reports the current power status. Two ADC channels are used as input data: battery voltage measurement and input voltage measurement. | ||
The following logic is implemented: | The following logic is implemented: | ||
Строка 537: | Строка 537: | ||
=== Sending commands | === Sending commands via RS-485 === | ||
For example, send a command to the device on the port /dev/ttys0 (corresponds to the hardware port RS-485-ISO on the [[Special:MyLanguage/Wiren Board 4|Wiren Board 4]]). To do this, we will use the rules engine and the ability to execute arbitrary shell commands. See [https://github.com/ | For example, send a command to the device on the port /dev/ttys0 (corresponds to the hardware port RS-485-ISO on the [[Special:MyLanguage/Wiren Board 4|Wiren Board 4]]). To do this, we will use the rules engine and the ability to execute arbitrary shell commands. See [https://github.com/wirenboard/wb-rules#%D0%94%D1%80%D1%83%D0%B3%D0%B8%D0%B5-%D0%BF%D1%80%D0%B5%D0%B4%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D1%91%D0%BD%D0%BD%D1%8B%D0%B5-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8-%D0%B8-%D0%BF%D0%B5%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D1%8B%D0%B5 documentation] for details. | ||
Create a virtual device with switch type control via rules engine. | Create a virtual device with switch type control via rules engine. | ||
Строка 1104: | Строка 1104: | ||
== A full description of the capabilities of the rules engine == | == A full description of the capabilities of the rules engine == | ||
The most complete description of the rules engine: https://github.com/ | The most complete description of the rules engine: https://github.com/wirenboard/wb-rules/blob/master/README.md | ||