improvements to the scope

This commit is contained in:
core 2023-11-04 22:38:49 -04:00
parent f07264a138
commit 8dacc8a9ba
Signed by: core
GPG Key ID: FDBF740DADDCEECF
4 changed files with 277 additions and 108 deletions

326
log.txt
View File

@ -1,140 +1,264 @@
2023-11-04T21:35:01.793Z TRACE [nexrad2] Loaded - VolumeHeaderRecord { 2023-11-04T22:10:43.640Z TRACE [nexrad2] Loaded - VolumeHeaderRecord {
tape_filename: "AR2V0006.", tape_filename: "AR2V0006.",
extension_number: "037", extension_number: "267",
date: 19665, date: 19664,
time: 44018888, time: 52330099,
icao: "KGRB", icao: "KOTX",
} }
2023-11-04T21:35:01.794Z TRACE [nexrad2] Reading LDM record - 2195 bytes compressed 2023-11-04T22:10:43.640Z TRACE [nexrad2] Reading LDM record - 2262 bytes compressed
2023-11-04T21:35:01.795Z TRACE [nexrad2] LDM record decompressed to 325888 bytes 2023-11-04T22:10:43.642Z TRACE [nexrad2] LDM record decompressed to 325888 bytes
2023-11-04T21:35:01.795Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1208, message_size: 1208,
rda_redundant_channel: 8, rda_redundant_channel: 8,
message_type: 15, message_type: 15,
message_sequence_number: 12786, message_sequence_number: 58510,
julian_date: 19663, julian_date: 19664,
millis_after_midnight: 11268749, millis_after_midnight: 7630137,
num_of_message_segments: 5, num_of_message_segments: 5,
message_segment_num: 1, message_segment_num: 1,
} }
2023-11-04T21:35:01.795Z TRACE [nexrad2] unrecognized message type 15 2023-11-04T22:10:43.642Z TRACE [nexrad2] unrecognized message type 15
2023-11-04T21:35:01.795Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1208, message_size: 1208,
rda_redundant_channel: 8, rda_redundant_channel: 8,
message_type: 15, message_type: 15,
message_sequence_number: 12786, message_sequence_number: 58510,
julian_date: 19663, julian_date: 19664,
millis_after_midnight: 11268749, millis_after_midnight: 7630137,
num_of_message_segments: 5, num_of_message_segments: 5,
message_segment_num: 2, message_segment_num: 2,
} }
2023-11-04T21:35:01.795Z TRACE [nexrad2] unrecognized message type 15 2023-11-04T22:10:43.642Z TRACE [nexrad2] unrecognized message type 15
2023-11-04T21:35:01.795Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1208, message_size: 1208,
rda_redundant_channel: 8, rda_redundant_channel: 8,
message_type: 15, message_type: 15,
message_sequence_number: 12786, message_sequence_number: 58510,
julian_date: 19663, julian_date: 19664,
millis_after_midnight: 11268749, millis_after_midnight: 7630137,
num_of_message_segments: 5, num_of_message_segments: 5,
message_segment_num: 3, message_segment_num: 3,
} }
2023-11-04T21:35:01.795Z TRACE [nexrad2] unrecognized message type 15 2023-11-04T22:10:43.642Z TRACE [nexrad2] unrecognized message type 15
2023-11-04T21:35:01.795Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1208, message_size: 1208,
rda_redundant_channel: 8, rda_redundant_channel: 8,
message_type: 15, message_type: 15,
message_sequence_number: 12786, message_sequence_number: 58510,
julian_date: 19663, julian_date: 19664,
millis_after_midnight: 11268749, millis_after_midnight: 7630137,
num_of_message_segments: 5, num_of_message_segments: 5,
message_segment_num: 4, message_segment_num: 4,
} }
2023-11-04T21:35:01.795Z TRACE [nexrad2] unrecognized message type 15 2023-11-04T22:10:43.642Z TRACE [nexrad2] unrecognized message type 15
2023-11-04T21:35:01.795Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] Message: MessageHeader {
message_size: 611, message_size: 611,
rda_redundant_channel: 8, rda_redundant_channel: 8,
message_type: 15, message_type: 15,
message_sequence_number: 12786, message_sequence_number: 58510,
julian_date: 19663, julian_date: 19664,
millis_after_midnight: 11268749, millis_after_midnight: 7630137,
num_of_message_segments: 5, num_of_message_segments: 5,
message_segment_num: 5, message_segment_num: 5,
} }
2023-11-04T21:35:01.795Z TRACE [nexrad2] unrecognized message type 15 2023-11-04T22:10:43.642Z TRACE [nexrad2] unrecognized message type 15
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
message_size: 769, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
rda_redundant_channel: 85, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
message_type: 121, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
message_sequence_number: 4, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
julian_date: 1, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
millis_after_midnight: 1668641394, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
num_of_message_segments: 25966, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
message_segment_num: 29696, 2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.642Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1208,
rda_redundant_channel: 8,
message_type: 18,
message_sequence_number: 11,
julian_date: 19664,
millis_after_midnight: 3959931,
num_of_message_segments: 4,
message_segment_num: 1,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 121 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 18
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 769, message_size: 1208,
rda_redundant_channel: 85, rda_redundant_channel: 8,
message_type: 121, message_type: 18,
message_sequence_number: 4, message_sequence_number: 11,
julian_date: 2, julian_date: 19664,
millis_after_midnight: 0, millis_after_midnight: 3959931,
num_of_message_segments: 0, num_of_message_segments: 4,
message_segment_num: 0, message_segment_num: 2,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 121 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 18
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 769, message_size: 1208,
rda_redundant_channel: 85, rda_redundant_channel: 8,
message_type: 121, message_type: 18,
message_sequence_number: 4, message_sequence_number: 11,
julian_date: 3, julian_date: 19664,
millis_after_midnight: 0, millis_after_midnight: 3959931,
num_of_message_segments: 0, num_of_message_segments: 4,
message_segment_num: 0, message_segment_num: 3,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 121 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 18
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 769, message_size: 1142,
rda_redundant_channel: 85, rda_redundant_channel: 8,
message_type: 121, message_type: 18,
message_sequence_number: 4, message_sequence_number: 11,
julian_date: 4, julian_date: 19664,
millis_after_midnight: 0, millis_after_midnight: 3959931,
num_of_message_segments: 0, num_of_message_segments: 4,
message_segment_num: 0, message_segment_num: 4,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 121 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 18
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] extra segment message
message_size: 1, 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
rda_redundant_channel: 0, message_size: 488,
message_type: 1, rda_redundant_channel: 8,
message_sequence_number: 0, message_type: 3,
julian_date: 0, message_sequence_number: 10307,
millis_after_midnight: 906635245, julian_date: 19664,
num_of_message_segments: 63506, millis_after_midnight: 52331198,
message_segment_num: 53479, num_of_message_segments: 1,
message_segment_num: 1,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 1 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 3
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1, message_size: 433,
rda_redundant_channel: 0, rda_redundant_channel: 8,
message_type: 1, message_type: 5,
message_sequence_number: 287, message_sequence_number: 10308,
julian_date: 2, julian_date: 19664,
millis_after_midnight: 2293772, millis_after_midnight: 52331198,
num_of_message_segments: 257, num_of_message_segments: 1,
message_segment_num: 514, message_segment_num: 1,
} }
2023-11-04T21:35:01.799Z TRACE [nexrad2] unrecognized message type 1 2023-11-04T22:10:43.643Z TRACE [nexrad2] unrecognized message type 5
2023-11-04T21:35:01.799Z TRACE [nexrad2] Message: MessageHeader { 2023-11-04T22:10:43.643Z TRACE [nexrad2] Message: MessageHeader {
message_size: 1, message_size: 68,
rda_redundant_channel: 0, rda_redundant_channel: 8,
message_type: 1, message_type: 2,
message_sequence_number: 16, message_sequence_number: 10306,
julian_date: 4, julian_date: 19664,
millis_after_midnight: 262146, millis_after_midnight: 52331198,
num_of_message_segments: 896, num_of_message_segments: 1,
message_segment_num: 10, message_segment_num: 1,
} }
2023-11-04T22:10:43.643Z TRACE [nexrad2] 1 messages loaded from chunk
2023-11-04T22:10:43.643Z INFO [nexrad2] File loaded successfully! 1 messages loaded in 1 chunks

View File

@ -102,6 +102,15 @@ function zulu() {
return `${date.getUTCHours().toString().padStart(2, '0')}:${date.getUTCMinutes().toString().padStart(2, '0')}:${date.getUTCSeconds().toString().padStart(2, '0')}Z`; return `${date.getUTCHours().toString().padStart(2, '0')}:${date.getUTCMinutes().toString().padStart(2, '0')}:${date.getUTCSeconds().toString().padStart(2, '0')}Z`;
} }
function vcp(vc) {
if (vc === 31) { return "CLEAR AIR MODE LONG PULSE"; }
else if (vc === 35) { return "CLEAR AIR MODE"; }
else if (vc === 12) { return "PRECIP MODE"; }
else if (vc === 112) { return "PRECIP MODE SZ-2 PRF"; }
else if (vc === 212) { return "PRECIP MODE SZ-2"; }
else if (vc === 215) { return "PRECIP MODE VERT"; }
}
let command_buf = ""; let command_buf = "";
let buf_response_mode = false; let buf_response_mode = false;
@ -133,9 +142,16 @@ function cmd_err(err) {
} }
let ar2 = undefined; let ar2 = undefined;
let new_file_available = false;
document.getElementById("file").onchange = () => {
new_file_available = true;
}
async function load() { async function load() {
new_file_available = false;
const file = document.getElementById("file").files[0]; const file = document.getElementById("file").files[0];
document.getElementById("file").value = null;
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', (event) => { reader.addEventListener('load', (event) => {
let data = event.target.result; let data = event.target.result;
@ -217,7 +233,7 @@ function reRender() {
if (ar2 !== undefined) { if (ar2 !== undefined) {
radar_inoperative = false; radar_inoperative = false;
icao = ar2.volume_header_record.icao; icao = ar2.volume_header_record.icao;
site_string = `${icao} VCP INFORMATION UNAVAILABLE`; site_string = `${icao} VCP ${ar2.meta_rda_status_data.vcp} ${vcp(ar2.meta_rda_status_data.vcp)}`;
selected_mode = "REF"; selected_mode = "REF";
} else { } else {
radar_inoperative = true; radar_inoperative = true;
@ -258,6 +274,11 @@ function reRender() {
ctx.fillText("RADR INOP NO DATA LOADED", x0 + 50, y0 + 50 + preferences.FCS); ctx.fillText("RADR INOP NO DATA LOADED", x0 + 50, y0 + 50 + preferences.FCS);
ctx.fillStyle = green; ctx.fillStyle = green;
} }
if (new_file_available) {
ctx.fillStyle = blinkyColor;
ctx.fillText("NEW DATA AVAIL RLD RQD", x0 + 50, y0 + 50 + preferences.FCS * 2);
ctx.fillStyle = green;
}
ctx.textAlign = "right"; ctx.textAlign = "right";
ctx.fillText("RADAR SITE", xfull - 75, y0 + 50); ctx.fillText("RADAR SITE", xfull - 75, y0 + 50);

View File

@ -19,7 +19,8 @@ pub mod message2;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Nexrad2Chunk { pub struct Nexrad2Chunk {
pub volume_header_record: VolumeHeaderRecord, pub volume_header_record: VolumeHeaderRecord,
pub chunks: Vec<Vec<Message>> pub chunks: Vec<Vec<Message>>,
pub meta_rda_status_data: Msg02RDAStatusData
} }
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
@ -59,7 +60,8 @@ pub enum NexradParseError {
TcmHeaderReadFailed(io::Error), TcmHeaderReadFailed(io::Error),
TcmChunkReadFailed(io::Error), TcmChunkReadFailed(io::Error),
FailedToReadFile(io::Error), FailedToReadFile(io::Error),
LdmReadFailed(io::Error) LdmReadFailed(io::Error),
MissingMsg02
} }
impl Display for NexradParseError { impl Display for NexradParseError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@ -75,7 +77,8 @@ impl Display for NexradParseError {
Self::TcmHeaderReadFailed(e) => write!(f, "tcm message header read failed: {}", e), Self::TcmHeaderReadFailed(e) => write!(f, "tcm message header read failed: {}", e),
Self::TcmChunkReadFailed(e) => write!(f, "tcm chunk read failed: {}", e), Self::TcmChunkReadFailed(e) => write!(f, "tcm chunk read failed: {}", e),
Self::FailedToReadFile(e) => write!(f, "failed to read file: {}", e), Self::FailedToReadFile(e) => write!(f, "failed to read file: {}", e),
Self::LdmReadFailed(e) => write!(f, "ldm read failed: {}", e) Self::LdmReadFailed(e) => write!(f, "ldm read failed: {}", e),
Self::MissingMsg02 => write!(f, "missing RDA status data (message type 02) in metadata header")
} }
} }
} }
@ -170,7 +173,9 @@ pub fn parse_nx2_chunk(cursor: &mut (impl Read + Seek)) -> Result<Nexrad2Chunk,
message_segment_num: u16::from_be_bytes(message_header[14..].try_into().unwrap()), message_segment_num: u16::from_be_bytes(message_header[14..].try_into().unwrap()),
}; };
let mut body_buf = vec![0u8; MESSAGE_BODY_SIZE]; let body_size = MESSAGE_BODY_SIZE.max(message_header.message_size as usize);
let mut body_buf = vec![0u8; body_size];
decompressed.read_exact(&mut body_buf).map_err(|e| NexradParseError::TcmChunkReadFailed(e))?; decompressed.read_exact(&mut body_buf).map_err(|e| NexradParseError::TcmChunkReadFailed(e))?;
@ -194,18 +199,37 @@ pub fn parse_nx2_chunk(cursor: &mut (impl Read + Seek)) -> Result<Nexrad2Chunk,
trace!("{} messages loaded from chunk", messages.len()); trace!("{} messages loaded from chunk", messages.len());
records.push(messages); records.push(messages);
break;
} }
info!("Extracting meta records");
let mut msg2: Option<Msg02RDAStatusData> = None;
let mut messages = 0; let mut messages = 0;
for chunk in &records { for chunk in &records {
messages += chunk.len(); messages += chunk.len();
for message in chunk {
match message {
Message::Msg02(m) if msg2.is_none() => { msg2 = Some(m.clone()); },
_ => ()
}
}
} }
let msg2 = match msg2 {
Some(m) => m,
None => return Err(NexradParseError::MissingMsg02)
};
info!("File loaded successfully! {} messages loaded in {} chunks", messages, records.len()); info!("File loaded successfully! {} messages loaded in {} chunks", messages, records.len());
Ok(Nexrad2Chunk { Ok(Nexrad2Chunk {
volume_header_record: header, volume_header_record: header,
chunks: records chunks: records,
meta_rda_status_data: msg2
}) })
} }

View File

@ -3,7 +3,7 @@ use crate::NexradParseError;
pub const MSG_RDA_STATUS_DATA: u8 = 2; pub const MSG_RDA_STATUS_DATA: u8 = 2;
#[derive(Debug)] #[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Msg02RDAStatusData { pub struct Msg02RDAStatusData {
rda_status: u16, rda_status: u16,