1#ifndef H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DATACONTAINERPOLLING_HPP
2#define H_EXTENSIONS_CUTEHMI_MODBUS_4_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DATACONTAINERPOLLING_HPP
4#include "IterableTasks.hpp"
5#include "../AbstractDevice.hpp"
11template <
class DERIVED,
class DATA>
37template<
class DERIVED,
class DATA>
40 m_requestId(requestId),
41 m_it(& derived().container())
45template<
class DERIVED,
class DATA>
51template<
class DERIVED,
class DATA>
54 int maxRead = derived().maxRead();
55 quint16 startAddress = 0;
59 while (m_it.hasNext()) {
60 quint16 address =
static_cast<quint16
>(m_it.next());
62 if (data && data->wakeful()) {
63 startAddress = address;
71 while (m_it.hasNext()) {
72 quint16 address =
static_cast<quint16
>(m_it.next());
73 if ((address - startAddress) < maxRead) {
75 if (data && data->wakeful())
76 count = address - startAddress + 1;
83 derived().requestReadData(startAddress, count, m_requestId);
90template<
class DERIVED,
class DATA>
96template<
class DERIVED,
class DATA>
99 return static_cast<DERIVED &
>(*this);
102template<
class DERIVED,
class DATA>
105 return static_cast<const DERIVED &
>(*this);
Abstract Modbus device.
Definition: AbstractDevice.hpp:38
Keys iterator.
Definition: DataContainer.hpp:43
const T * const_pointer
Definition: DataContainer.hpp:29
friend class KeysIterator
Definition: DataContainer.hpp:22
Definition: DataContainerPolling.hpp:14
bool runNext() override
Run next task.
Definition: DataContainerPolling.hpp:52
void reset() override
Reset tasks iterator.
Definition: DataContainerPolling.hpp:91
DATA Data
Definition: DataContainerPolling.hpp:16
RegisterTraits< Data >::Container DataContainer
Definition: DataContainerPolling.hpp:17
DataContainerPolling(AbstractDevice *device, QUuid *requestId)
Definition: DataContainerPolling.hpp:38
AbstractDevice * device() const
Definition: DataContainerPolling.hpp:46
const DERIVED & derived() const
Definition: DataContainerPolling.hpp:103
DERIVED & derived()
Definition: DataContainerPolling.hpp:97
Definition: IterableTasks.hpp:18
Definition: RegisterTraits.hpp:16