public RadialData ParseRadialData(byte[] fileData, int offset, int dbp) { _byteReader.Seek(offset + dbp + 28); var radialData = new RadialData() { BlockType = _byteReader.ReadString(fileData, 1), Name = _byteReader.ReadString(fileData, 3), Size = _byteReader.ReadShort(fileData), UmambiguousRange = _byteReader.ReadShort(fileData), HorizontalNoiseLevel = _byteReader.ReadFloat(fileData), VerticalNoiseLevel = _byteReader.ReadFloat(fileData), NyquistVelocity = _byteReader.ReadShort(fileData), }; _byteReader.Skip(2); _dataLogger.Log("Location 6 - End of Radial Data - at byte location - " + _byteReader.Offset); _dataLogger.Log(JsonConvert.SerializeObject(radialData)); return(radialData); }
public void Compute(object sender, DoWorkEventArgs e) { ImprovedBackgroundWorker bw; TLProcess BellhopProcess; string ErrorOutput, WorkingDirectory; IsComputing = true; CalculationStarted = DateTime.Now; if ((sender == null)) return; bw = (ImprovedBackgroundWorker)sender; //System.Diagnostics.Debug.WriteLine("Worker: Beginning computation of " + bw.TaskName); bw.WorkerReportsProgress = true; bw.WorkerSupportsCancellation = true; WorkingDirectory = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetRandomFileName())); Directory.CreateDirectory(WorkingDirectory); // Write the bottom profile file that will be read by BELLHOP using (StreamWriter writer = new StreamWriter(Path.Combine(WorkingDirectory, "BTYFIL"))) writer.Write(BottomProfile); // Create a process, run BELLHOP, and exit BellhopProcess = new TLProcess(bw); BellhopProcess.StartInfo = new ProcessStartInfo( Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location), "Bellhop.exe")); BellhopProcess.StartInfo.CreateNoWindow = true; BellhopProcess.StartInfo.UseShellExecute = false; BellhopProcess.StartInfo.RedirectStandardInput = true; BellhopProcess.StartInfo.RedirectStandardOutput = true; BellhopProcess.StartInfo.RedirectStandardError = true; BellhopProcess.StartInfo.WorkingDirectory = WorkingDirectory; BellhopProcess.OutputDataReceived += new DataReceivedEventHandler(OutputDataRecieved); mBellhopOutputData = new StringBuilder(); BellhopProcess.Start(); BellhopProcess.PriorityClass = ProcessPriorityClass.BelowNormal; BellhopProcess.StandardInput.WriteLine(BellhopConfiguration); BellhopProcess.BeginOutputReadLine(); while (!BellhopProcess.HasExited) { Thread.Sleep(100); if (bw.CancellationPending) { BellhopProcess.Kill(); ErrorOutput = BellhopProcess.StandardError.ReadToEnd(); while (!BellhopProcess.HasExited) Thread.Sleep(100); if (File.Exists(Path.Combine(WorkingDirectory, "BYTFIL"))) File.Delete(Path.Combine(WorkingDirectory, "BTYFIL")); if (File.Exists(Path.Combine(WorkingDirectory, "SHDFIL"))) File.Delete(Path.Combine(WorkingDirectory, "SHDFIL")); if (File.Exists(Path.Combine(WorkingDirectory, "ARRFIL"))) File.Delete(Path.Combine(WorkingDirectory, "ARRFIL")); if (Directory.Exists(WorkingDirectory)) Directory.Delete(WorkingDirectory, true); return; } mProgress_percent = BellhopProcess.ProgressPercent; } mProgress_percent = BellhopProcess.ProgressPercent; ErrorOutput = BellhopProcess.StandardError.ReadToEnd(); //if (BellhopOutputData.ToString() != "") // MessageBox.Show(BellhopOutputData.ToString()); //System.Diagnostics.Debug.WriteLine("BELLHOP Exit Code: " + BellhopProcess.ExitCode); // We don't need to keep the results files around anymore, we're finished with them File.Delete(Path.Combine(WorkingDirectory, "BTYFIL")); foreach (string s in Directory.GetFiles(WorkingDirectory, "ARRFIL_*")) File.Delete(s); //if (File.Exists(Path.Combine(WorkingDirectory, "ARRFIL"))) // File.Move(Path.Combine(WorkingDirectory, "ARRFIL"), "ARRFIL_" + TLParams.RadialNumber.ToString("00")); // TODO: Convert the Bellhop output file into a Radial binary file RadialData = new RadialData(BearingFromSource_degrees, new BellhopOutput(Path.Combine(WorkingDirectory, "SHDFIL"))); #if false TLParams.SoundSource.TransmissionLossVertical[TLParams.RadialNumber] = new TransmissionLossVertical( ReaderBellhopOutput.ReadBellhop( Path.Combine(WorkingDirectory, "SHDFIL")), TLParams.BottomProfile, TLParams.Experiment, TLParams.SoundSource, TLParams.SSPLocation, TLParams.RadialNumber); #endif File.Delete(Path.Combine(WorkingDirectory, "SHDFIL")); bw.ReportProgress(100); Directory.Delete(WorkingDirectory, true); //System.Diagnostics.Debug.WriteLine("Worker: Completed computation of " + bw.TaskName); }
public void AddRadialData(RadialData RadialData) { if (RadialData == null) return; if (((Depths_meters == null) || (Ranges_meters == null)) && ((RadialData.Depths_meters != null) && (RadialData.Ranges_meters != null))) { Depths_meters = RadialData.Depths_meters; Ranges_meters = RadialData.Ranges_meters; } else { if ((Depths_meters != null) && (RadialData.Depths_meters != null)) ValidateDepths(RadialData.Depths_meters); if ((Ranges_meters != null) && (RadialData.Ranges_meters != null)) ValidateRanges(RadialData.Ranges_meters); } if (FieldData == null) { FieldData = new FieldData(this); FieldData.Filename = Path.Combine(DataDirectoryPath, BinaryFileName); } RadialData.ClearAxisData(); lock (FieldData) { FieldData.AddRadial(RadialData); FieldData.Save(true); } }