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

Новая страница: «== 1 Examples of work via the MQTT queue == ===Getting the value from the temperature sensor and displaying it in the web interface=== File:Web-devices-1-wire.p…»
(Новая страница: «If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device.»)
(Новая страница: «== 1 Examples of work via the MQTT queue == ===Getting the value from the temperature sensor and displaying it in the web interface=== File:Web-devices-1-wire.p…»)
Строка 6: Строка 6:
If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device.
If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device.


== Примеры работы через очередь MQTT ==
== 1 Examples of work via the MQTT queue ==
===Получение значения от датчика температуры и вывод его в веб-интерфейс===
===Getting the value from the temperature sensor and displaying it in the web interface===
[[File:Web-devices-1-wire.png|400px|thumb|Показания датчика и его уникальный идентификатор на странице ''Devices'' веб-интерфейса]]
[[File:Web-devices-1-wire.png|400px|thumb|Sensor readings and its unique identifier on the '''Devices''' page of the web interface]]
Предположим, что к [[Wiren Board]] подключён датчик температуры по шине [[1-Wire]]. Проследим, как данные с него через очередь сообщений попадают в веб-интерфейс:
Assume that a [[1-Wire/en]] bus temperature sensor is connected to the Wiren Board. Let's see how the  sensor data comes into the web interface via the message queue:
#Драйвер, отвечающий за данную аппаратную функцию ([https://github.com/contactless/wb-homa-drivers/tree/master/wb-homa-w1 wb-homa-w1]) опрашивает подключённые к контролеру датчики 1-Wire.
#The driver that is responsible for this hardware function  ([https://github.com/contactless/wb-homa-drivers/tree/master/wb-homa-w1 wb-homa-w1]) polls the 1-Wire sensors connected to the controller.
#При получении значения драйвер размещает в очереди сообщение следующего вида: <pre>/devices/wb-w1/controls/28-0115a48fcfff 23.25</pre>Оно значит, что на устройстве 1-Wire с идентификатором ''28-0115a48fcfff'' получено значение 23.25°C.
#When a value is received, the driver queues a message that resembles the following: <pre>/devices/wb-w1/controls/28-0115a48fcfff 23.25</pre>It means that the 1-Wire device (ID 28-0115a48fcfff)registers a value of 23.25°C.
#Веб-интерфейс, который получает все сообщения из очереди (он ''подписан'' на все сообщения), получает это сообщение и выводит значение датчика на страницу.
#The web interface that receives all messages from the queue (it is subscribed to all messages) receives this message and displays the sensor value to the page.
===Нажатие кнопки в веб-интерфейсе и переключение реле на внешнем модуле===
===Pressing a button in the web interface and switching the relay on the external module===
[[File:Web-devices-serial.png|400px|thumb|Веб-интерфейс после нажатия кнопки включения Реле 1 на подключённом по RS-485 релейном модуле [[WB-MRM2]]]]
[[File:Web-devices-serial.png|400px|thumb|Web interface after pressing relay 1 on the relay module [[WB-MRM2/en| MRM2]] CONNECTED via RS-485]]
Предположим, что к контроллеру по шине [[RS-485]] подключён релейный модуль [[WB-MRM2]]. Пользователь в веб-интерфейсе нажимает кнопку включения реле. Проследим, как команда из веб-интерфейса попадает на внешний модуль:
Suppose that the relay module WB-MRM2 is connected to the controller via the [[RS-485/en| RS-485]] bus. The user presses the relay button in the web interface and switches it on. Let's see how the command from the web interface gets to the external module: <pre>/devices/wb-mrm2_130/controls/Relay 1/on 1</pre>It means that the device WB-MRM2 with the address ''130'' must transfer Relay 1 to the state of the logical unit - "on".
#После нажатия кнопки веб-интерфейс размещает в очереди сообщение следующего вида: <pre>/devices/wb-mrm2_130/controls/Relay 1/on 1</pre>Оно значит, что устройство WB-MRM2 с адресом ''130'' должно перевести Реле 1 в состояние логической единицы - "включено".
#[[Драйвер wb-mqtt-serial/en|The wb-mqtt-serial driver]] responsible for this hardware function receives this message (it is subscribed to all messages related to RS-485 devices) and sends a command to turn on the first relay via the RS-485 bus to the relay module.
#[[Драйвер wb-mqtt-serial]], отвечающий за данную аппаратную функцию, получает это сообщение (он ''подписан'' на все сообщения, относящиеся к подключённым по RS-485 устройствам) и посылает по шине RS-485 релейному модулю команду на включение первого реле.
#The WB-MRM2 relay module receives a command from the controller, switches the relay and sends back a notification ("Relay 1 is on").
#Релейный модуль WB-MRM2 получает команду от контроллера, переключает реле и посылает обратно уведомление ("Реле 1 включено").
#The wb-mqtt-serial driver receives this notification over RS-485 and sends the message to the queue:<pre>/devices/wb-mrm2_130/controls/Relay 1 1</pre>It means that the first relay on the WB-MRM2 device with address ''130'' is in the logical 1 state (is "on").
#Драйвер wb-mqtt-serial получает это уведомление по RS-485 и публикует в очереди сообщение:<pre>/devices/wb-mrm2_130/controls/Relay 1 1</pre>Оно значит, что первое реле на устройстве WB-MRM2 с адресом ''130'' находится (уже переведено) в состоянии логической единицы ("включено").


== Принцип работы очереди сообщений ==
== Принцип работы очереди сообщений ==
12 063

правки