-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathciecsignal.cpp
More file actions
108 lines (99 loc) · 2.34 KB
/
Copy pathciecsignal.cpp
File metadata and controls
108 lines (99 loc) · 2.34 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "ciecsignal.h"
#include "ctools.h"
#include <QDebug>
CIECSignal::CIECSignal()
{
description = "new tag";
}
CIECSignal::CIECSignal(uint16_t addr, uchar type, QString descr)
{
SetAddress(addr);
SetType(type);
this->quality = 0;
this->description = descr;
//this->descr = "";
}
/*CIECSignal::CIECSignal(uint16_t addr, uchar type, QString description)
{
SetAddress(addr);
SetType(type);
this->descr = description;
}*/
void CIECSignal::SetKey(uint key)
{
this->key = key;
address = key & 0x00FFFFFFu;
typeID = (key &0xFF000000u)>>24;
}
void CIECSignal::SetAddress(quint32 ioa)
{
address = ioa;
key &= 0xFF000000;
key |= ioa;
}
void CIECSignal::SetType(uchar type)
{
typeID = type;
// Keep 24-bit IOA; previous mask 0x00FFFF truncated high address byte
key &= 0x00FFFFFFu;
key |= (uint(type) << 24);
}
QString CIECSignal::GetValueString()
{
QString result;
result = "addr: " + QString::number(this->address) +
" value: ";
switch (typeID)
{
case 1:
case 30:
result += (value.toUInt() == 1) ? "true" : "false";
break;
case 3:
case 31:
result += QString::number(value.toUInt());
break;
case 5:
case 32:
result += QString::number(value.toUInt());
break;
case 7:
case 33:
result += QString::number(value.toUInt());
break;
case 9:
case 34:
result += QString::number(value.toUInt());
break;
case 11:
case 35:
result += QString::number(value.toInt());
break;
case 13:
case 36:
result += QString::number(value.toFloat());
break;
case 15:
case 37:
result += QString::number(value.toUInt());
break;
case 20:
result += QStringLiteral("0x") + QString::number(value.toUInt(), 16).toUpper();
break;
case 21:
result += QString::number(value.toUInt());
break;
case 38:
case 39:
case 40:
result += QStringLiteral("0x") + QString::number(value.toUInt(), 16).toUpper();
break;
default:
result += value.toString();
break;
}
result += " type: " + QString::number(this->typeID)+
" quality: " + QString::number(this->quality) +
" Time: " + this->timestamp.GetTimeString();
return result;
}