Ejemplo n.º 1
0
        /// <summary>
        /// 更新声纳配置,true从文件中读出,false更新到文件
        /// </summary>
        /// <param name="bRead"></param>
        /// <returns></returns>
        public bool UpdateSonarConfig(bool bRead = true, string configfile = null)
        {
            string conf = configfile;

            if (conf == null)
            {
                conf = BasicConf.MyExecPath + "\\" + "DefConf.dat";
            }

            if (bRead)
            {
                return(SonarConfiguration.Parse(File.ReadAllBytes(conf)));
            }
            else
            {
                try
                {
                    var bw = new FileStream(conf, FileMode.OpenOrCreate);
                    bw.Write(SonarConfiguration.SavePackage(), 0, SonarConfiguration.SavePackage().Length);
                    bw.Close();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 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);
 }