-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersonalize.js
52 lines (45 loc) · 1.43 KB
/
Personalize.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
/* calculateSumBPM()
* calculate the sum of the HR and count how many data has posted
* @param none
* @return none
`*/
function calculateSumBPM(msg, metadata, msgType) {
var newMsg = {};
if (metadata["sum_bpm"] == undefined) {
newMsg.sum_bpm = parseInt(msg.bpm)/100;
newMsg.bpm_count = 1;
} else {
newMsg.sum_bpm = parseInt(msg.bpm)/100 + parseInt(JSON.parse(metadata.sum_bpm));
newMsg.bpm_count = parseInt(JSON.parse(metadata.bpm_count))+1;
}
return {msg: newMsg, metadata: metadata, msgType: msgType};
}
/* calculateSumSpO2()
* calculate the sum of the SpO2 and count how many data has posted
* @param none
* @return none
`*/
function calculateSumSpO2(msg, metadata, msgType) {
var newMsg = {};
if (metadata["sum_spo2"] == undefined) {
newMsg.sum_spo2 = parseInt(msg.spo2) / 100
newMsg.spo2_count = 1;
} else {
newMsg.sum_spo2 = parseInt(msg.spo2) / 100 + parseFloat(JSON.parse(metadata.sum_spo2));
newMsg.spo2_count = parseInt(JSON.parse(metadata.spo2_count))+1;
}
return {msg: newMsg, metadata: metadata, msgType: msgType};
}
/* calculateSumSpO2()
* calculate the sum of the Response Time
* @param none
* @return none
`*/
function calculateSumTime(msg, metadata, msgType) {
var newMsg = {};
if (metadata["sum_time"] == undefined) {
newMsg.sum_time = parseFloat(msg.time)
} else {
newMsg.sum_time = (msg.time + parseInt(JSON.parse(metadata.sum_time)))
}
}