|
LightHub 4.6.0
Open-source smart home controller firmware
|
Generic Modbus register channel driver, channel type CH_MBUS = 14. More...
#include <out_modbus.h>
Public Member Functions | |
| out_Modbus () | |
| Default constructor; binds nothing until link() is called. | |
| void | link (Item *_item) |
| Links the channel item and attaches persistent storage. | |
| int | Setup () override |
| Creates persistent storage, loads the template config and prepares the @S marks. | |
| int | Poll (short cause) override |
| Sends queued (MB_NEED_SEND) parameter values, then polls the configured register lists and executes mapped actions. | |
| int | Stop () override |
| Releases the persistent storage. | |
| int | getChanType () override |
| Returns CH_MBUS (14). | |
| int | Ctrl (itemCmd cmd, char *subItem=NULL, bool toExecute=true, bool authorized=false) override |
| Queues a command for a template parameter (by subitem name or by suffix id), see class doc. | |
| Public Member Functions inherited from abstractOut | |
| abstractOut () | |
| virtual int | isActive () |
| virtual bool | isAllowed (itemCmd cmd) |
| virtual itemCmd | getDefaultOnVal () |
| virtual int | Status () override |
| virtual void | setStatus (uint8_t status) override |
| Item * | getItem () |
| Public Member Functions inherited from abstractCh | |
| abstractCh () | |
| virtual | ~abstractCh () |
Protected Member Functions | |
| bool | getConfig () |
| Загружает и применяет конфигурацию Modbus. | |
| itemCmd | findRegister (uint16_t registerNum, uint16_t posInBuffer, uint8_t regType, uint16_t registerFrom, uint16_t registerTo, bool doExecution=true, bool *submitParam=NULL) |
| Находит и обрабатывает регистр Modbus, выполняет сопоставление и действия. | |
| void | pollModbus (aJsonObject *reg, int regType) |
| Опрос Modbus-устройства по списку регистров. | |
| void | initLine () |
| Инициализирует линию связи Modbus. | |
| int | sendModbus (char *paramName, aJsonObject *outValue) |
| Отправляет значение в Modbus-устройство. | |
| int | sendItemCmd (aJsonObject *templateParamObj, itemCmd cmd) |
| Отправляет команду itemCmd в Modbus по шаблону параметра. | |
| int | createLastMeasured (char *name) |
| Создаёт поле для хранения последнего измеренного значения по имени параметра. | |
| int | createLastMeasured (aJsonObject *execObj) |
| Создаёт поле для хранения последнего измеренного значения по JSON-объекту. | |
| aJsonObject * | getLastMeasured (char *name) |
| Получает объект последнего измеренного значения по имени параметра. | |
| aJsonObject * | getLastMeasured (aJsonObject *execObj) |
| Получает объект последнего измеренного значения по JSON-объекту. | |
| void | setLastMeasured (aJsonObject *execObj, int val) |
| Protected Member Functions inherited from abstractOut | |
| int | pubAction (bool state) |
| Protected Member Functions inherited from abstractCh | |
| int | publishTopic (const char *topic, long value, const char *subtopic=NULL) |
| int | publishTopic (const char *topic, float value, const char *subtopic=NULL) |
| int | publishTopic (const char *topic, const char *value, const char *subtopic=NULL, const char *suffix=NULL) |
Protected Attributes | |
| mbPersistent * | store |
| Protected Attributes inherited from abstractOut | |
| Item * | item |
| Item currently linked to this driver. | |
Generic Modbus register channel driver, channel type CH_MBUS = 14.
The channel is described by a template from the global Modbus template table: registers are polled periodically, mapped to item parameters and fired as execution actions, and control commands are written back to the registers. Last sent / last measured values are tracked per parameter in the "@V" / "@S" marks to suppress redundant writes and re-executions.
JSON config (itemArg): [addr, "template", {params}]
Register value types: i16, i32, u16, u32, i8h, i8l, u8h, u8l, x10, 100.
Ctrl: the subitem (template parameter name) takes priority, otherwise the suffix code is matched against the "id" of the template parameters (e.g. S_CMD / S_SET or a custom numeric id).
|
inline |
Default constructor; binds nothing until link() is called.
|
protected |
Создаёт поле для хранения последнего измеренного значения по JSON-объекту.
| execObj | JSON-объект параметра. |
|
protected |
Создаёт поле для хранения последнего измеренного значения по имени параметра.
| name | Имя параметра. |
|
overridevirtual |
Queues a command for a template parameter (by subitem name or by suffix id), see class doc.
Control unified Modbus item.
Унифицированное управление Modbus-каналом.
| cmd | Команда itemCmd. |
| subItem | Имя подэлемента. |
| toExecute | Выполнять ли команду. |
| authorized | Авторизовано ли выполнение. |
Implements abstractOut.
|
protected |
Находит и обрабатывает регистр Modbus, выполняет сопоставление и действия.
| registerNum | Номер регистра. |
| posInBuffer | Позиция в буфере ответа. |
| regType | Тип регистра. |
| registerFrom | Начальный регистр диапазона. |
| registerTo | Конечный регистр диапазона. |
| doExecution | Выполнять ли действие. |
| submitParam | Флаг для подавления повторных действий. |
|
overridevirtual |
|
protected |
Загружает и применяет конфигурацию Modbus.
|
protected |
Получает объект последнего измеренного значения по JSON-объекту.
| execObj | JSON-объект параметра. |
|
protected |
Получает объект последнего измеренного значения по имени параметра.
| name | Имя параметра. |
|
protected |
Инициализирует линию связи Modbus.
|
inlinevirtual |
Links the channel item and attaches persistent storage.
Reimplemented from abstractOut.
|
overridevirtual |
Sends queued (MB_NEED_SEND) parameter values, then polls the configured register lists and executes mapped actions.
Осуществляет опрос и отправку команд Modbus.
| cause | Причина вызова (например, медленный опрос). |
return 1; //relax
Reimplemented from abstractCh.
|
protected |
Опрос Modbus-устройства по списку регистров.
| reg | JSON-объект с регистрами. |
| regType | Тип регистра. |
|
protected |
|
protected |
Отправляет значение в Modbus-устройство.
| paramName | Имя параметра. |
| outValue | JSON-объект с отправляемым значением. |
to prevent CORRUPTIOIN if using same buffer
|
protected |
|
overridevirtual |
Creates persistent storage, loads the template config and prepares the @S marks.
Инициализирует канал Modbus и загружает конфигурацию.
Reimplemented from abstractOut.
|
overridevirtual |
Releases the persistent storage.
Останавливает работу канала Modbus и освобождает ресурсы.
Reimplemented from abstractCh.
|
protected |