-
Notifications
You must be signed in to change notification settings - Fork 0
/
Autosequence.cpp
77 lines (64 loc) · 2.17 KB
/
Autosequence.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "Autosequence.hpp"
Autosequence::Autosequence(QObject *parent, QList<QVariant> args)
: QObject{parent}, _name{args.at(0).toString()},
_id{static_cast<quint16>(args.at(1).toUInt(nullptr))},
_hostNodeID{static_cast<quint16>(args.at(2).toUInt(nullptr))}
{
}
void Autosequence::onAutosequenceReceivedFD(const QList<QByteArray> &data)
{
qInfo() << "Enter Autosequence::onAutosequenceReceivedFD() function with object ID: " << _id;
for (int i = 0; i < data.length(); i = i + 10) //Payload size is 10 per object
{
if (_id == data.at(0).toUInt(nullptr,16))
{
setState(data.at(1).toUInt(nullptr,16));
quint8 u_8x8[8] = { static_cast<quint8>(data.at(9).toUInt(nullptr,16)),
static_cast<quint8>(data.at(8).toUInt(nullptr,16)),
static_cast<quint8>(data.at(7).toUInt(nullptr,16)),
static_cast<quint8>(data.at(6).toUInt(nullptr,16)),
static_cast<quint8>(data.at(5).toUInt(nullptr,16)),
static_cast<quint8>(data.at(4).toUInt(nullptr,16)),
static_cast<quint8>(data.at(3).toUInt(nullptr,16)),
static_cast<quint8>(data.at(2).toUInt(nullptr,16))};
qint64 currentCountDown {0};
memcpy(¤tCountDown, u_8x8, 8);
setCurrentCountdown(currentCountDown);
break;
}
}
}
QString Autosequence::name() const
{
return _name;
}
quint16 Autosequence::id() const
{
return _id;
}
quint16 Autosequence::hostNodeID() const
{
return _hostNodeID;
}
qint64 Autosequence::currentCountdown() const
{
return _currentCountdown;
}
void Autosequence::setCurrentCountdown(qint64 newCurrentCountdown)
{
if (_currentCountdown == newCurrentCountdown)
return;
_currentCountdown = newCurrentCountdown;
emit currentCountdownChanged();
}
QVariant Autosequence::state() const
{
return _state;
}
void Autosequence::setState(QVariant newAutosequenceState)
{
if (_state == newAutosequenceState)
return;
_state = newAutosequenceState;
emit stateChanged();
}