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;
72 while (m_it.hasNext()) {
73 quint16 address =
static_cast<quint16
>(m_it.next());
74 if ((address - startAddress) < maxRead) {
75 typename DataContainer::const_pointer data = derived().dataAt(address);
76 if (data && data->wakeful())
77 count = address - startAddress + 1;
84 derived().requestReadData(startAddress, count, m_requestId);
91 template<
class DERIVED,
class DATA>
97 template<
class DERIVED,
class DATA>
100 return static_cast<DERIVED &
>(*this);
103 template<
class DERIVED,
class DATA>
106 return static_cast<const DERIVED &
>(*this);