-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincgraph.cpp
More file actions
39 lines (33 loc) · 848 Bytes
/
incgraph.cpp
File metadata and controls
39 lines (33 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "incgraph.h"
#include <QtMath>
IncGraph::IncGraph(TestSlaveData *pSlaveData, QObject *parent)
: QObject{parent}
{
_pSlaveData = pSlaveData;
_bIncEnabled = false;
_periodMs = 1000;
connect(&_tickTimer, &QTimer::timeout, this, QOverload<>::of(&IncGraph::timerTick));
_tickTimer.start(_periodMs);
}
void IncGraph::setState(bool bState)
{
_bIncEnabled = bState;
}
void IncGraph::setRegisters(uint32_t start, uint32_t count)
{
_start = start;
_count = count;
}
void IncGraph::timerTick()
{
if (_bIncEnabled)
{
for(uint32_t idx = 0; idx < _count; idx++)
{
quint32 regAddr = _start + idx;
quint16 value = _pSlaveData->registerValue(regAddr) + 1;
_pSlaveData->setRegisterValue(regAddr, value);
}
}
_tickTimer.start(_periodMs);
}