MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / addRegisterGroup

Method addRegisterGroup

app/src/IO/Drivers/Modbus.cpp:749–771  ·  view source on GitHub ↗

* @brief Adds a register group to poll */

Source from the content-addressed store, hash-verified

747 * @brief Adds a register group to poll
748 */
749void IO::Drivers::Modbus::addRegisterGroup(const quint8 type,
750 const quint16 start,
751 const quint16 count)
752{
753 if (count > 0 && count <= 125) {
754 for (const auto& group : std::as_const(m_registerGroups))
755 if (group.registerType == type && group.startAddress == start && group.count == count)
756 return;
757
758 m_registerGroups.append(ModbusRegisterGroup(type, start, count));
759
760 m_settings.beginWriteArray("ModbusDriver/registerGroups");
761 for (int i = 0; i < m_registerGroups.size(); ++i) {
762 m_settings.setArrayIndex(i);
763 m_settings.setValue("type", m_registerGroups[i].registerType);
764 m_settings.setValue("start", m_registerGroups[i].startAddress);
765 m_settings.setValue("count", m_registerGroups[i].count);
766 }
767 m_settings.endArray();
768
769 Q_EMIT registerGroupsChanged();
770 }
771}
772
773/**
774 * @brief Removes a register group at the specified index

Callers 2

applyModbusRegisterFunction · 0.45
loadRegisterGroupsMethod · 0.45

Calls 3

ModbusRegisterGroupClass · 0.85
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected