private void ExecuteSaveAsCommand(object sender, ExecutedRoutedEventArgs eventArgs) { try { var sc = new SonarConfig(); sc.VelCmd = SurVelSrcIndex; if (AvgVelIndex == 1) { sc.VelCmd = sc.VelCmd | 0x04; } sc.SurVel = SurVel; sc.AvgVel = AvgVel; sc.FixedGain = FixedGain; sc.TVGCmd = TVGCmd; sc.FixedTVG = FixedTVG; sc.TVGSampling = TVGSampling; sc.TVGSamples = TVGSamples; sc.TVGA1 = TVGA1; sc.TVGA2 = TVGA2; sc.TVGA3 = TVGA3; sc.PingPeriod = PingPeriod; sc.ADSaved = ADSaved; sc.PoseSaved = PoseSaved; sc.PosSaved = PosSaved; sc.SonarDepth = SonarDepth; sc.SonarGPSx = SonarGPSx; sc.SonarGPSy = SonarGPSy; sc.SonarGPSz = SonarGPSz; sc.Pitchfixed = Pitchfixed; sc.Rollfixed = Rollfixed; sc.Headingfixed = Headingfixed; ///////////////////////////////////////////////////////////////////////////////////// SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "参数文件 (*.dat)|*.dat"; saveFileDialog.FilterIndex = 2; saveFileDialog.Title = "保存参数文件"; saveFileDialog.RestoreDirectory = true; saveFileDialog.OverwritePrompt = true; saveFileDialog.ValidateNames = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { if (saveFileDialog.FileName != "") { var bw = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate); bw.Write(sc.SavePackage(), 0, sc.SavePackage().Length); bw.Close(); } } } catch (Exception ex) { UnitCore.Instance.EventAggregator.PublishMessage(new ErrorEvent(ex, LogType.Both)); return; } }
public void SaveSonarSetting(SonarConfig scConfig) { if (SonarSetting == null) { var MyExecPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); MyExecPath += "SonarConfig"; SonarSetting = new FileStream(MyExecPath, FileMode.OpenOrCreate); } SonarSetting.Write(scConfig.SavePackage(), 0, 288); }
private void ExecuteLoadCommand(object sender, ExecutedRoutedEventArgs eventArgs) { try { var sc = new SonarConfig(); Microsoft.Win32.OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.Title = "选择参数文件"; openFileDialog.Filter = "参数文件 (*.dat)|*.dat"; if (openFileDialog.ShowDialog() == true) { if (!sc.Parse(File.ReadAllBytes(openFileDialog.FileName))) { throw new Exception("声纳参数读取失败"); } } else { return; } uint velcmd = sc.VelCmd; SurVelSrcIndex = velcmd & 0x03; AvgVelIndex = (velcmd >> 2) & 0x01; SurVel = sc.SurVel; AvgVel = sc.AvgVel; FixedGain = sc.FixedGain; TVGCmd = sc.TVGCmd; FixedTVG = sc.FixedTVG; TVGSampling = sc.TVGSampling; TVGSamples = sc.TVGSamples; TVGA1 = sc.TVGA1; TVGA2 = sc.TVGA2; TVGA3 = sc.TVGA3; PingPeriod = sc.PingPeriod; ADSaved = sc.ADSaved; PoseSaved = sc.PoseSaved; PosSaved = sc.PosSaved; SonarDepth = sc.SonarDepth; SonarGPSx = sc.SonarGPSx; SonarGPSy = sc.SonarGPSy; SonarGPSz = sc.SonarGPSz; Pitchfixed = sc.Pitchfixed; Rollfixed = sc.Rollfixed; Headingfixed = sc.Headingfixed; } catch (Exception ex) { UnitCore.Instance.EventAggregator.PublishMessage(new ErrorEvent(ex, LogType.Both)); return; } }
public void SaveSonarSetting(SonarConfig scConfig) { TraceFile.Instance.SaveSonarSetting(scConfig); }