Wb-mqtt-serial templates/en: различия между версиями

Новая страница: « Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift; Here stride — DeviceConfig()->Stride, a shift — DeviceConfig()-…»
(Новая страница: « Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift; Here stride — DeviceConfig()->Stride, a shift — DeviceConfig()-…»)
Строка 433: Строка 433:
Option ''' ''protocol'': ''modbus_io'' ''' indicates that the device connects to the extension module via special protocol. The parameters '''"stride": 1000''' and '''"shift":500''' set the shift of registers depending on the order in which the modules are connected to the extension module.  
Option ''' ''protocol'': ''modbus_io'' ''' indicates that the device connects to the extension module via special protocol. The parameters '''"stride": 1000''' and '''"shift":500''' set the shift of registers depending on the order in which the modules are connected to the extension module.  


Сдвиг регистров (число, которое нужно добавить к базовому номеру регистра) вычисляется по формуле: <syntaxhighlight lang="C++">Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift;</syntaxhighlight> Здесь stride — ''DeviceConfig()->Stride'', a shift — ''DeviceConfig()->Shift''. Каждое подключенное устройство имеет порядковый номер (''SlaveId.Secondary''), начинающийся с 1 для первого устройства. (Здесь знаком "%" обозначается деление по модулю.)
 
Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift;
Here stride — DeviceConfig()->Stride, a shift — DeviceConfig()->Shift.
 
Register shift (the number to be added to the base register number) is calculated by the formula:<syntaxhighlight lang="C++">Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift;</syntaxhighlight> Здесь stride — ''DeviceConfig()->Stride'', a shift — ''DeviceConfig()->Shift''. Each connected device has a serial number (''SlaveId.Secondary'') starting with 1 for the first device. (Here the sign "%" shows modulу division.)


Например, подставляя значения shift и stride в формулу, получаем: <syntaxhighlight lang="C++">Shift = ((( 1 - 1) % 4) + 1) * 500 + 1000 = (0 + 1) * 500 + 1000 = 1500</syntaxhighlight> То есть ко всем регистрам, указанным в шаблоне, надо добавить 1500.
Например, подставляя значения shift и stride в формулу, получаем: <syntaxhighlight lang="C++">Shift = ((( 1 - 1) % 4) + 1) * 500 + 1000 = (0 + 1) * 500 + 1000 = 1500</syntaxhighlight> То есть ко всем регистрам, указанным в шаблоне, надо добавить 1500.
12 063

правки