|
3 | 3 | * Authors: Mark Jessop & Luke Prior |
4 | 4 | */ |
5 | 5 |
|
| 6 | +function parseOzonesonde(xdata) { |
| 7 | + // Attempt to parse an XDATA string from an ECC Ozonesonde |
| 8 | + // Returns an object with parameters to be added to the sondes telemetry. |
| 9 | + // |
| 10 | + // References: |
| 11 | + // https://gml.noaa.gov/aftp/user/jordan/iMet%20Radiosonde%20Protocol.pdf |
| 12 | + // |
| 13 | + // Sample data: 01010349FDC54296 (length = 16 characters) |
| 14 | + |
| 15 | + // Run some checks over the input |
| 16 | + if(xdata.length != 16){ |
| 17 | + // Invalid Ozonesonde dataset |
| 18 | + return {}; |
| 19 | + } |
| 20 | + |
| 21 | + if(xdata.substr(0,2) !== '01'){ |
| 22 | + // Not an Ozonesonde (shouldn't get here) |
| 23 | + return {}; |
| 24 | + } |
| 25 | + |
| 26 | + var _output = {}; |
| 27 | + |
| 28 | + // Instrument number is common to all XDATA types. |
| 29 | + _output['ozonesonde_instrument_number'] = parseInt(xdata.substr(2,2),16); |
| 30 | + |
| 31 | + // Cell Current |
| 32 | + _cell_current = parseInt(xdata.substr(4,4),16)*0.001; // micro-Amps |
| 33 | + _output['ozonesonde_cell_current'] = Math.round(_cell_current * 1000) / 1000; // 3 DP |
| 34 | + |
| 35 | + // Pump Temperature |
| 36 | + _pump_temperature = parseInt(xdata.substr(8,4),16); |
| 37 | + if ((_pump_temperature & 0x8000) > 0) { |
| 38 | + _pump_temperature = _pump_temperature - 0x10000; |
| 39 | + } |
| 40 | + _pump_temperature = _pump_temperature*0.01; // Degrees C |
| 41 | + _output['ozonesonde_pump_temperature'] = Math.round(_pump_temperature * 100) / 100; // 2 DP |
| 42 | + |
| 43 | + // Pump Current |
| 44 | + _pump_current = parseInt(xdata.substr(12,2),16); // mA |
| 45 | + _output['ozondesonde_pump_current'] = Math.round(_pump_current * 10) / 10; // 1 DP |
| 46 | + |
| 47 | + // Battery Voltage |
| 48 | + _battery_voltage = parseInt(xdata.substr(14,2),16)*0.1; // Volts |
| 49 | + _output['ozondesonde_battery_voltage'] = Math.round(_battery_voltage * 10) / 10; // 1 DP |
| 50 | + |
| 51 | + return _output |
| 52 | +} |
| 53 | + |
6 | 54 | // Pump Efficiency Correction Parameters for ECC-6A Ozone Sensor, with 3.0cm^3 volume. |
7 | 55 | // We are using these as a nominal correction value for pump efficiency vs pressure |
8 | 56 | // |
@@ -159,36 +207,36 @@ function parseCOBALD(xdata) { |
159 | 207 | // Internal temperature |
160 | 208 | _internal_temperature = parseInt(xdata.substr(7,3),16); |
161 | 209 | if ((_internal_temperature & 0x800) > 0) { |
162 | | - _internal_temperature = _internal_temperature - 0x1000; |
| 210 | + _internal_temperature = _internal_temperature - 0x1000; |
163 | 211 | } |
164 | 212 | _internal_temperature = _internal_temperature/8; // Degrees C (-40 - 50) |
165 | 213 | _output['cobald_internal_temperature'] = Math.round(_internal_temperature * 100) / 100; // 2 DP |
166 | 214 |
|
167 | 215 | // Blue backscatter |
168 | 216 | _blue_backscatter = parseInt(xdata.substr(10,6),16); |
169 | 217 | if ((_blue_backscatter & 0x800000) > 0) { |
170 | | - _blue_backscatter = _blue_backscatter - 0x1000000; |
| 218 | + _blue_backscatter = _blue_backscatter - 0x1000000; |
171 | 219 | } |
172 | 220 | _output['cobald_blue_backscatter'] = _blue_backscatter; // (0 - 1000000) |
173 | 221 |
|
174 | 222 | // Red backckatter |
175 | 223 | _red_backscatter = parseInt(xdata.substr(16,6),16); |
176 | 224 | if ((_red_backscatter & 0x800000) > 0) { |
177 | | - _red_backscatter = _red_backscatter - 0x1000000; |
| 225 | + _red_backscatter = _red_backscatter - 0x1000000; |
178 | 226 | } |
179 | 227 | _output['cobald_red_backscatter'] = _red_backscatter; // (0 - 1000000) |
180 | 228 |
|
181 | 229 | // Blue monitor |
182 | 230 | _blue_monitor = parseInt(xdata.substr(22,4),16); |
183 | 231 | if ((_blue_monitor & 0x8000) > 0) { |
184 | | - _blue_monitor = _blue_monitor - 0x10000; |
| 232 | + _blue_monitor = _blue_monitor - 0x10000; |
185 | 233 | } |
186 | 234 | _output['cobald_blue_monitor'] = _blue_monitor; // (-32768 - 32767) |
187 | 235 |
|
188 | 236 | // Red monitor |
189 | 237 | _red_monitor = parseInt(xdata.substr(26,4),16); |
190 | 238 | if ((_red_monitor & 0x8000) > 0) { |
191 | | - _red_monitor = _red_monitor - 0x10000; |
| 239 | + _red_monitor = _red_monitor - 0x10000; |
192 | 240 | } |
193 | 241 | _output['cobald_red_monitor'] = _red_monitor; // (-32768 - 32767) |
194 | 242 |
|
@@ -565,10 +613,12 @@ function parseXDATA(data, pressure, temperature){ |
565 | 613 | _instrument = _current_xdata.substr(0,2); |
566 | 614 |
|
567 | 615 | if (_instrument === '01') { |
568 | | - // V7 |
569 | | - // 0102 time=1001 cnt=0 rpm=0 |
570 | | - // 0102 time=1001 cnt=7 rpm=419 |
571 | | - if (!_instruments.includes("V7")) _instruments.push('V7'); |
| 616 | + if (_current_xdata.length = 16) { |
| 617 | + // Ozonesonde |
| 618 | + _xdata_temp = parseOzonesonde(_current_xdata); |
| 619 | + _output = Object.assign(_output,_xdata_temp); |
| 620 | + if (!_instruments.includes("Ozonesonde")) _instruments.push('Ozonesonde'); |
| 621 | + } |
572 | 622 | } else if (_instrument === '05'){ |
573 | 623 | // OIF411 |
574 | 624 | _xdata_temp = parseOIF411(_current_xdata, pressure); |
|
0 commit comments