-
Notifications
You must be signed in to change notification settings - Fork 1
/
logviewer.data.js
81 lines (63 loc) · 1.49 KB
/
logviewer.data.js
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
var LogTypeEnum = {
Unknown : 0,
MSDroid : 1,
Torque : 2,
WiPy : 3,
RealDash : 4
}
var dataStore={}
function ascertainLogType(data) {
if(data.length > 2) {
if (data[1].indexOf("Capture Date") == 1) {
return LogTypeEnum.MSDroid;
}
if(data[0].indexOf("GPS Time, Device Time, Longitude, Latitude")==0) {
return LogTypeEnum.Torque;
}
if(data[0].indexOf("Time,")==0) {
return LogTypeEnum.WiPy;
}
if(data[0].indexOf("Time\tEngine")==0) {
return LogTypeEnum.RealDash;
}
}
return LogTypeEnum.Unknown;
}
function createSeries(data) {
var series= {};
series.logType = ascertainLogType(data)
switch(series.logType) {
case LogTypeEnum.MSDroid:
processMSDroidLog(series,data)
break;
case LogTypeEnum.Torque:
processTorqueLog(series,data)
break;
case LogTypeEnum.WiPy:
processWiPyLog(series,data)
break;
case LogTypeEnum.RealDash:
processRealDashLog(series,data)
break;
}
return series;
}
function manageMaxMin(value,key,maxValues,minValues) {
if (!isNaN(value)) {
if(maxValues[key] == undefined || maxValues[key]<value) {
maxValues[key]=value
}
if(minValues[key] == undefined || minValues[key]>value) {
minValues[key]=value
}
}
}
function processData(data) {
var lines = data.split('\n');
var dataSeries = createSeries(lines)
var latitudes=dataSeries[dataSeries.latKey || "Latitude"]
var longitudes=dataSeries[dataSeries.lonKey || "Longitude"]
dataStore.lat=latitudes
dataStore.lon=longitudes
dataStore.dataSeries=dataSeries
}