Skip to content

Commit d8a2037

Browse files
authored
Merge pull request #218 from LukePrior/testing
XDATA fixes
2 parents ca6ccde + 2efd33a commit d8a2037

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

js/tracker.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,19 +3161,19 @@ function mapInfoBox_handle_path_new(data, vehicle, date) {
31613161
html += "<div><b>XDATA Instrument:&nbsp;</b>" + tempXDATA.xdata_instrument + "</div>";
31623162
}
31633163
if (tempXDATA.hasOwnProperty('oif411_ozone_battery_v')) {
3164-
html += "<div><b>OIF411 Battery:&nbsp;</b>" + tempXDATA.oif411_ozone_battery_v.toFixed(1) + " V</div>";
3164+
html += "<div><b>OIF411 Battery:&nbsp;</b>" + tempXDATA.oif411_ozone_battery_v + " V</div>";
31653165
}
31663166
if (tempXDATA.hasOwnProperty('oif411_ozone_current_uA')) {
3167-
html += "<div><b>Ozone Current:&nbsp;</b>" + tempXDATA.oif411_ozone_current_uA.toFixed(4) + " uA</div>";
3167+
html += "<div><b>Ozone Current:&nbsp;</b>" + tempXDATA.oif411_ozone_current_uA + " uA</div>";
31683168
}
31693169
if (tempXDATA.hasOwnProperty('oif411_O3_partial_pressure')) {
3170-
html += "<div><b>Ozone Partial Presure:&nbsp;</b>" + tempXDATA.oif411_O3_partial_pressure.toFixed(3) + " mPa (+/- 1)</div>";
3170+
html += "<div><b>Ozone Partial Presure:&nbsp;</b>" + tempXDATA.oif411_O3_partial_pressure + " mPa (+/- 1)</div>";
31713171
}
31723172
if (tempXDATA.hasOwnProperty('oif411_ozone_pump_curr_mA')) {
3173-
html += "<div><b>Ozone Pump Current:&nbsp;</b>" + tempXDATA.oif411_ozone_pump_curr_mA.toFixed(1) + " mA</div>";
3173+
html += "<div><b>Ozone Pump Current:&nbsp;</b>" + tempXDATA.oif411_ozone_pump_curr_mA + " mA</div>";
31743174
}
31753175
if (tempXDATA.hasOwnProperty('oif411_ozone_pump_temp')) {
3176-
html += "<div><b>Ozone Pump Temperature:&nbsp;</b>" + tempXDATA.oif411_ozone_pump_temp.toFixed(1) + "°C</div>";
3176+
html += "<div><b>Ozone Pump Temperature:&nbsp;</b>" + tempXDATA.oif411_ozone_pump_temp + "°C</div>";
31773177
}
31783178
if (tempXDATA.hasOwnProperty('oif411_serial')) {
31793179
html += "<div><b>OIF411 Serial Number:&nbsp;</b>" + tempXDATA.oif411_serial + "</div>";
@@ -4267,13 +4267,13 @@ function formatData(data, live) {
42674267
dataTempEntry.data.oif411_serial = tempXDATA.oif411_serial;
42684268
}
42694269
if (tempXDATA.hasOwnProperty('oif411_diagnostics')) {
4270-
dataTempEntry.oif411_diagnostics = tempXDATA.oif411_diagnostics;
4270+
dataTempEntry.data.oif411_diagnostics = tempXDATA.oif411_diagnostics;
42714271
}
42724272
if (tempXDATA.hasOwnProperty('oif411_version')) {
4273-
dataTempEntry.oif411_version = tempXDATA.oif411_version;
4273+
dataTempEntry.data.oif411_version = tempXDATA.oif411_version;
42744274
}
42754275
if (tempXDATA.hasOwnProperty('oif411_O3_partial_pressure')) {
4276-
dataTempEntry.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
4276+
dataTempEntry.data.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
42774277
}
42784278
}
42794279
if (data[entry].serial.toLowerCase() != "xxxxxxxx") {
@@ -4388,13 +4388,13 @@ function formatData(data, live) {
43884388
dataTempEntry.data.oif411_serial = tempXDATA.oif411_serial;
43894389
}
43904390
if (tempXDATA.hasOwnProperty('oif411_diagnostics')) {
4391-
dataTempEntry.oif411_diagnostics = tempXDATA.oif411_diagnostics;
4391+
dataTempEntry.data.oif411_diagnostics = tempXDATA.oif411_diagnostics;
43924392
}
43934393
if (tempXDATA.hasOwnProperty('oif411_version')) {
4394-
dataTempEntry.oif411_version = tempXDATA.oif411_version;
4394+
dataTempEntry.data.oif411_version = tempXDATA.oif411_version;
43954395
}
43964396
if (tempXDATA.hasOwnProperty('oif411_O3_partial_pressure')) {
4397-
dataTempEntry.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
4397+
dataTempEntry.data.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
43984398
}
43994399
}
44004400
if (data.serial.toLowerCase() != "xxxxxxxx") {
@@ -4492,13 +4492,13 @@ function formatData(data, live) {
44924492
dataTempEntry.data.oif411_serial = tempXDATA.oif411_serial;
44934493
}
44944494
if (tempXDATA.hasOwnProperty('oif411_diagnostics')) {
4495-
dataTempEntry.oif411_diagnostics = tempXDATA.oif411_diagnostics;
4495+
dataTempEntry.data.oif411_diagnostics = tempXDATA.oif411_diagnostics;
44964496
}
44974497
if (tempXDATA.hasOwnProperty('oif411_version')) {
4498-
dataTempEntry.oif411_version = tempXDATA.oif411_version;
4498+
dataTempEntry.data.oif411_version = tempXDATA.oif411_version;
44994499
}
45004500
if (tempXDATA.hasOwnProperty('oif411_O3_partial_pressure')) {
4501-
dataTempEntry.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
4501+
dataTempEntry.data.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
45024502
}
45034503
}
45044504
if (data[key][i].serial.toLowerCase() != "xxxxxxxx") {
@@ -4627,13 +4627,13 @@ function formatData(data, live) {
46274627
dataTempEntry.data.oif411_serial = tempXDATA.oif411_serial;
46284628
}
46294629
if (tempXDATA.hasOwnProperty('oif411_diagnostics')) {
4630-
dataTempEntry.oif411_diagnostics = tempXDATA.oif411_diagnostics;
4630+
dataTempEntry.data.oif411_diagnostics = tempXDATA.oif411_diagnostics;
46314631
}
46324632
if (tempXDATA.hasOwnProperty('oif411_version')) {
4633-
dataTempEntry.oif411_version = tempXDATA.oif411_version;
4633+
dataTempEntry.data.oif411_version = tempXDATA.oif411_version;
46344634
}
46354635
if (tempXDATA.hasOwnProperty('oif411_O3_partial_pressure')) {
4636-
dataTempEntry.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
4636+
dataTempEntry.data.oif411_O3_partial_pressure = tempXDATA.oif411_O3_partial_pressure;
46374637
}
46384638
}
46394639
dataTemp.push(dataTempEntry);

js/xdata.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function parseOIF411(xdata, pressure){
8080
if(_diagnostics_word == '0000'){
8181
_output['oif411_diagnostics'] = "All OK";
8282
}else if(_diagnostics_word == '0004'){
83-
_output['oif411_diagnostics'] = 'Ozone pump temperature below 5 °C.';
83+
_output['oif411_diagnostics'] = 'Ozone pump temperature below -5 °C.';
8484
}else if(_diagnostics_word == '0400'){
8585
_output['oif411_diagnostics'] = 'Ozone pump battery voltage (+VBatt) is not connected to OIF411';
8686
}else if (_diagnostics_word == '0404'){
@@ -100,19 +100,24 @@ function parseOIF411(xdata, pressure){
100100
if ((_ozone_pump_temp & 0x8000) > 0) {
101101
_ozone_pump_temp = _ozone_pump_temp - 0x10000;
102102
}
103-
_output['oif411_ozone_pump_temp'] = _ozone_pump_temp*0.01; // Degrees C
103+
_ozone_pump_temp = _ozone_pump_temp*0.01; // Degrees C
104+
_output['oif411_ozone_pump_temp'] = Math.round(_ozone_pump_temp * 10) / 10; // 1 DP
104105

105-
// Ozone Pump Current
106-
_output['oif411_ozone_current_uA'] = parseInt(xdata.substr(8,5),16)*0.0001; // micro-Amps
106+
// Ozone Current
107+
_ozone_current_uA = parseInt(xdata.substr(8,5),16)*0.0001; // micro-Amps
108+
_output['oif411_ozone_current_uA'] = Math.round(_ozone_current_uA * 10000) / 10000; // 4 DP
107109

108110
// Battery Voltage
109-
_output['oif411_ozone_battery_v'] = parseInt(xdata.substr(13,2),16)*0.1; // Volts
111+
_ozone_battery_v = parseInt(xdata.substr(13,2),16)*0.1; // Volts
112+
_output['oif411_ozone_battery_v'] = Math.round(_ozone_battery_v * 10) / 10; // 1 DP
110113

111114
// Ozone Pump Current
112-
_output['oif411_ozone_pump_curr_mA'] = parseInt(xdata.substr(15,3),16); // mA
115+
_ozone_pump_curr_mA = parseInt(xdata.substr(15,3),16); // mA
116+
_output['oif411_ozone_pump_curr_mA'] = Math.round(_ozone_pump_curr_mA * 10) / 10; // 1 DP
113117

114118
// External Voltage
115-
_output['oif411_ext_voltage'] = parseInt(xdata.substr(18,2),16)*0.1; // Volts
119+
_ext_voltage = parseInt(xdata.substr(18,2),16)*0.1; // Volts
120+
_output['oif411_ext_voltage'] = Math.round(_ext_voltage * 10) / 10; // 1 DP
116121

117122
// Now attempt to calculate the O3 partial pressure
118123

@@ -121,7 +126,8 @@ function parseOIF411(xdata, pressure){
121126
Cef = get_oif411_Cef(pressure); // Calculate the pump efficiency correction.
122127
FlowRate = 28.5; // Use a 'nominal' value for Flow Rate (seconds per 100mL).
123128

124-
_output['oif411_O3_partial_pressure'] = (4.30851e-4)*(_output['oif411_ozone_current_uA'] - Ibg)*(_output['oif411_ozone_pump_temp']+273.15)*FlowRate*Cef;
129+
_O3_partial_pressure = (4.30851e-4)*(_output['oif411_ozone_current_uA'] - Ibg)*(_output['oif411_ozone_pump_temp']+273.15)*FlowRate*Cef; // mPa
130+
_output['oif411_O3_partial_pressure'] = Math.round(_O3_partial_pressure * 1000) / 1000; // 3 DP
125131

126132
return _output
127133

0 commit comments

Comments
 (0)