Движок правил wb-rules/en: различия между версиями

Нет описания правки
(Новая страница: «== under development ==»)
 
(не показано 6 промежуточных версий 2 участников)
Строка 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/contactless/wb-ruleshttps://github.com/contactless/wb-rules
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/contactless/wb-rules documentation on Github].
#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/contactless/wb-rules Full description of the rules engine].
#[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/contactless/wb-rules-system/tree/master/rules in the repository.].
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====


[https://github.com/contactless/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.
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/contactless/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.
[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 viaRS-485 ===
=== 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/contactless/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.
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.  
Строка 701: Строка 701:
To enable the user to enter exact parameter values (setpoints) from the interface, you can use the [https://wirenboard.com/wiki/index.php/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5_%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D1%83%D0%B5%D0%BC%D1%8B%D1%85_%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D0%BA%D0%B8%D1%85_%D0%BF%D0%BE%D0%BB%D0%B5%D0%B9_%D0%B2_%D0%B2%D0%B5%D0%B1-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81%D0%B5 instruction].
To enable the user to enter exact parameter values (setpoints) from the interface, you can use the [https://wirenboard.com/wiki/index.php/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5_%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D1%83%D0%B5%D0%BC%D1%8B%D1%85_%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D0%BA%D0%B8%D1%85_%D0%BF%D0%BE%D0%BB%D0%B5%D0%B9_%D0%B2_%D0%B2%D0%B5%D0%B1-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81%D0%B5 instruction].


More detailed and with example - in the topic on the technical support [https://support.wirenboard.com/t/kak-na-wb5-wb6-sozdat-pole-dlya-vvoda-ustavok-i-peredat-znachenie-v-pravila/2180 portal].
More detailed and with example - in the topic on the technical support [https://support.wirenboard.com/t/kak-na-wb5-wb6-sozdat-pole-dlya-vvoda-ustavok-i-peredat-znachenie-v-pravila/2180 forum].




Строка 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/contactless/wb-rules/blob/master/README.md
The most complete description of the rules engine: https://github.com/wirenboard/wb-rules/blob/master/README.md




Строка 1110: Строка 1110:
== What's new in the latest versions ==
== What's new in the latest versions ==


* [[Special:MyLanguage/Движок_правил_wb-rules_1.7|wb-rules 1.7 rules engine]]
* [[Special:MyLanguage/Движок_правил_wb-rules_1.7/en|wb-rules 1.7 rules engine]]




Строка 1116: Строка 1116:
== under development ==
== under development ==


Описание возможностей будущих версий движка правил можно прочесть здесь:
A description of the features of future versions of the rules engine can be found here:
* [[Special:MyLanguage/Движок_правил_wb-rules_2.0|Движок правил wb-rules 2.0]]
* [[Special:MyLanguage/Движок_правил_wb-rules_2.0/en|Rules engine wb-rules 2.0]]
wb_editors
33

правки