-
Notifications
You must be signed in to change notification settings - Fork 1
/
datainterpreter.cpp
161 lines (146 loc) · 3.32 KB
/
datainterpreter.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "datainterpreter.h"
#include <QString>
#include <float.h>
QString DataInterpreter::getString()
{
return QString::asprintf("%d, %d, %f, %f, %f, %f, %f, %f, %d",
(*rd).bi.time,
(*rd).bi.totalRevolutions,
(*rd).bi.ECT,
(*rd).bi.IAT,
(*rd).bi.MAP,
(*rd).bi.TPS,
(*rd).bi.OIN,
(*rd).bi.totalPulseTime,
(*rd).bi.RPM
);
}
double DataInterpreter::getValue(int index)
{
switch(index)
{
case 0:
return (*rd).bi.time;
break; //breaks are not needed, just in case
case 1:
return (*rd).bi.totalRevolutions;
break;
case 2:
return (*rd).bi.ECT;
break;
case 3:
return (*rd).bi.IAT;
break;
case 4:
return (*rd).bi.MAP;
break;
case 5:
return (*rd).bi.TPS;
break;
case 6:
return (*rd).bi.OIN;
break;
case 7:
return (*rd).bi.totalPulseTime;
break;
case 8:
return (*rd).bi.RPM;
break;
default:
return -FLT_MAX;
break;
}
}
void DataInterpreter::setBytes(void* rawBytesAddress)
{
rd = (RawData*)rawBytesAddress;
return;
}
void* DataInterpreter::getBytes()
{
return rd;
}
int DataInterpreter::getNumBytes()
{
return RAW_DATA_LENGTH;
}
int DataInterpreter::getNumFields()
{
return RAW_DATA_LENGTH/4 - NUM_PAD_WORDS;
}
uint32_t DataInterpreter::getEnd()
{
return (*rd).bi.end;
}
uint32_t DataInterpreter::getStart()
{
return (*rd).bi.start;
}
////////////////////////////////
QString WriteInterpreter::getString()
{
return QString::asprintf("%d, %d, %f, %f, %f, %f, %f, %f, %d",
(*rd).bi.time,
(*rd).bi.totalRevolutions,
(*rd).bi.ECT,
(*rd).bi.IAT,
(*rd).bi.MAP,
(*rd).bi.TPS,
(*rd).bi.OIN,
(*rd).bi.totalPulseTime,
(*rd).bi.RPM
);
}
double WriteInterpreter::getValue(int index)
{
switch(index)
{
case 0:
return (*rd).bi.time;
break; //breaks are not needed, just in case
case 1:
return (*rd).bi.totalRevolutions;
break;
case 2:
return (*rd).bi.ECT;
break;
case 3:
return (*rd).bi.IAT;
break;
case 4:
return (*rd).bi.MAP;
break;
case 5:
return (*rd).bi.TPS;
break;
case 6:
return (*rd).bi.OIN;
break;
case 7:
return (*rd).bi.totalPulseTime;
break;
case 8:
return (*rd).bi.RPM;
break;
default:
return -FLT_MAX;
break;
}
}
void WriteInterpreter::setBytes(void* rawBytesAddress)
{
rd = (RawData*)rawBytesAddress;
return;
}
void* WriteInterpreter::getBytes()
{
return rd;
}
int WriteInterpreter::getNumBytes()
{
return DATA_LENGTH;
}
int WriteInterpreter::getNumFields()
{
return DATA_LENGTH/4;
}