1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DATACONTAINERPOLLING_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_DATACONTAINERPOLLING_HPP
4 #include "IterableTasks.hpp"
6 #include <cutehmi/modbus/AbstractDevice.hpp>
12 template <
class DERIVED,
class DATA>
26 void reset()
override;
30 const DERIVED &
derived()
const;
38 template<
class DERIVED,
class DATA>
41 m_requestId(requestId),
42 m_it(& derived().container())
46 template<
class DERIVED,
class DATA>
52 template<
class DERIVED,
class DATA>
55 int maxRead = derived().maxRead();
56 quint16 startAddress = 0;
60 while (m_it.hasNext()) {
61 quint16 address =
static_cast<quint16
>(m_it.next());
62 typename DataContainer::const_pointer data = derived().dataAt(address);
63 if (data && data->wakeful()) {
64 startAddress = address;
73 while (m_it.hasNext()) {
74 quint16 address =
static_cast<quint16
>(m_it.next());
75 if ((address - startAddress) < maxRead) {
76 typename DataContainer::const_pointer data = derived().dataAt(address);
77 if (data && data->wakeful())
78 count = address - startAddress + 1;
85 derived().requestReadData(startAddress, count, m_requestId);
92 template<
class DERIVED,
class DATA>
98 template<
class DERIVED,
class DATA>
101 return static_cast<DERIVED &
>(*this);
104 template<
class DERIVED,
class DATA>
107 return static_cast<const DERIVED &
>(*this);