EtherCATFrame.cpp
Go to the documentation of this file.
1#include "EtherCATFrame.h"
2
4{
6 size_t startIndex,
7 size_t count) :
8 list(list), nextIndex(startIndex), remaining(count)
9 {
10 }
11
12 std::pair<EtherCATFrame*, EtherCATFrameMetaData*>
14 {
15 return {&list->list[nextIndex].first, &list->list[nextIndex].second};
16 }
17
18 bool
20 {
21 return nextIndex == 0;
22 }
23
26 {
27 if (remaining > 0)
28 {
29 nextIndex = (nextIndex + 1) % list->list.size();
30 --remaining;
31 }
32 return *this;
33 }
34
35 bool
37 {
38 return remaining == 0;
39 }
40
41 size_t
43 {
44 if (not hasCompletedLoop())
45 {
46 return nextIndex - 1;
47 }
48 return 0;
49 }
50} // namespace armarx::control::ethercat
The EtherCATFrameIterator class iterates over a set range of EtherCAT frames once.
EtherCATFrameIterator & operator++()
Move this iterator to the next EtherCAT frame.
bool atEnd() const
Check if this iterator has stepped over its range.
bool hasCompletedLoop() const
Check if this iterator points to the first available register frame.
EtherCATFrameIterator(EtherCATFrameList *list, size_t startIndex, size_t count)
Construct a new EtherCATFrameIterator that iterates over the given range of EtherCAT frames.
std::pair< EtherCATFrame *, EtherCATFrameMetaData * > operator*() const
Get the EtherCAT frame this iterator is on with metadata.
The EtherCATFrameList struct holds a list of EtherCAT frames that can be scheduled in round-robin-sty...