private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (progressBar != null && progressBarGrid != null) { progressBarGrid.Visibility = Visibility.Hidden; progressBar.IsIndeterminate = true; } if (!processingError) { var inputFile = new DriverlessInputFile(InputFileManager.LastID + 1, FileNameWithoutPath, channels); //TODO: ha lesz standard input file is, akkor azt még előbb kell eldönteni vagy utána rögtön válassza ki és utána nézzem meg hogy ezek benne vannak e. var yChannel = inputFile.GetChannel("y"); if (yChannel == null) { ShowError.ShowErrorMessage("Can't find 'y' channel, so the track will not shown"); } var c0refChannel = inputFile.GetChannel("c0ref"); if (c0refChannel == null) { ShowError.ShowErrorMessage("Can't find 'c0ref' channel, so the track will not shown"); } InputFileManager.AddInputFile(inputFile); InputFileManager.ActiveInputFileName = FileNameWithoutPath; ((InputFilesSettings)((SettingsMenu)MenuManager.GetTab(TextManager.SettingsMenuName).Content).GetTab(TextManager.FilesSettingsName).Content).AddInputFileSettingsItem(inputFile); ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).UpdateAfterReadFile(); ((GroupSettings)((SettingsMenu)MenuManager.GetTab(TextManager.SettingsMenuName).Content).GetTab(TextManager.GroupsSettingsName).Content).UpdateAfterReadFile(FileNameWithoutPath); } }
private void Channel_Checked(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; string content = ((CheckBox)sender).Content.ToString(); if ((bool)((CheckBox)sender).IsChecked) { GroupManager.GetGroup(ActiveGroupID).AddAttribute(InputFileManager.GetInputFile(activeInputFileID).GetChannel(content)); ActiveAttributeID = GroupManager.GetGroup(ActiveGroupID).GetAttribute(content).ID; } else { GroupManager.GetGroup(ActiveGroupID).RemoveAttribute(content); var group = GroupManager.GetGroup(ActiveGroupID); if (group.Attributes.Count > 0) { ActiveAttributeID = group.Attributes.Last().ID; } else { ActiveAttributeID = -1; } } GroupManager.SaveGroups(); InitGroups(); SelectInputFile(); ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).BuildCharts(); Mouse.OverrideCursor = null; }
/// <summary> /// 构造函数 /// </summary> public DoubleDiffer() { ProcessCount = 4; this.InputFileExtension = "*.??O;*.??d.Z"; FileExtension = Setting.RinexOFileFilter; InputFileManager = new InputFileManager(); BaseLineSelector = new BaseLineSelector(BaseLineSelectionType.中心站法, "", ""); }
/// <summary> /// Finds a <see cref="Channel"/> based on <paramref name="channelName"/>. /// </summary> /// <param name="channelName">The name of the <see cref="Channel"/> to find.</param> /// <returns>A single <see cref="Channel"/></returns> public Channel GetChannel(int inputFileID, string channelName) { if (InputFileManager.DriverlessInputFilesCount == 0) { return(null); } return(InputFileManager.GetDriverlessInputFile(inputFileID).GetChannel(channelName)); }
public static IncarnationParams ProcessInputFiles(/* ref */ PackageEngineState engineState, out TimeSpan inputFilesTime) { var engine = new PackageEngine(engineState.CompiledDef, engineState.EngineContext); var incarnation = new IncarnationParams(); var fileManager = new InputFileManager(engineState.StoragePathBase); inputFilesTime = TimeSpanExt.Measure(() => { TimeSpan timeLimit = PB_PROCESS_TIME_LIMIT; try { Tools.ProcessWithTimeLimit(timeLimit, () => { engine.PrepareInputs(fileManager); CheckEngineResult(engine); }); } catch (TimeLimitException tle) { throw new PackageBaseException("Inputs processing in Package base exceeded time limit (" + timeLimit.TotalSeconds + " seconds).", tle); } finally { incarnation.FilesToCopy = incarnation.FilesToCopy.Concat(fileManager.GetInputFiles()).ToArray(); fileManager.Cleanup(); } }); object cmdLine = engine.Ctx.Memory[CmdLineDef.DefName].Value; //if (cmdLine == null) //throw new PackageBaseException("CommandLine generated by PackageBase is empty"); incarnation.CommandLine = cmdLine.ToString(); Log.Debug(String.Format( "Command line for pack {0}.{1} is '{2}' (task {3}). Cmdline object from PB is {4}", engine.CompiledMode.ModeQName.PackageName ?? "''", engine.CompiledMode.ModeQName.ModeName ?? "''", incarnation.CommandLine ?? "", engineState._taskDescription.TaskId, cmdLine == null ? "null" : "not null" )); if (String.IsNullOrWhiteSpace(incarnation.CommandLine)) { throw new PackageBaseException("CommandLine generated by PackageBase is empty"); } if (!engine.IsReadyToRun()) { Log.Warn("PackageBase: task is not ready to run after PrepareInputs"); Log.Error("PackageBase: task is not ready to run after PrepareInputs"); throw new PackageBaseException("PackageBase: task is not ready to run after processing inputs"); } return(incarnation); }
public void UpdateAfterFileRename(string newName) { foreach (CheckBox item in InputFilesStackPanel.Children) { if (InputFileManager.GetInputFile(item.Content.ToString()) == null) { item.Content = newName; } } }
/// <summary> /// 数据源加载 /// </summary> /// <returns></returns> protected virtual MultiSiteObsStream BuildDataSource() { var oPathes = InputFileManager.GetLocalFilePathes(Pathes, RunnerFileExtension, "*.*"); var DataSource = new MultiSiteObsStream(oPathes, Option.BaseSiteSelectType, Option.IsSameSatRequired, this.Option.IndicatedBaseSiteName); DataSource.IsAllowMissingEpochSite = Option.IsAllowMissingEpochSite; return(DataSource); }
/// <summary> /// 具体的执行 /// </summary> /// <param name="inPath"></param> /// <param name="outPath"></param> protected override void Execute(string inPath, string outPath) { if (this.IsCancel) { return; } var Solver = new SingleSiteGnssSolveStreamer(); if (PathUtil.IsValidPath(CurrentParam.EphemerisPath)) { if (this.EphemerisDataSource == null || this.EphemerisDataSource.Name != Path.GetFileName(CurrentParam.EphemerisPath)) { var sp3 = InputFileManager.GetLocalFilePath(CurrentParam.EphemerisPath, "*.sp3"); if (PathUtil.IsValidPath(sp3)) { this.EphemerisDataSource = EphemerisDataSourceFactory.Create(sp3); Solver.EphemerisDataSource = this.EphemerisDataSource; } } } if (PathUtil.IsValidPath(CurrentParam.ClockPath)) { if (this.ClockFile == null || this.ClockFile.Name != Path.GetFileName(CurrentParam.ClockPath)) { var clk = InputFileManager.GetLocalFilePath(CurrentParam.ClockPath, "*.clk"); if (PathUtil.IsValidPath(clk)) { this.ClockFile = new Data.SimpleClockService(clk); Solver.ClockFile = this.ClockFile; } } } if (Option == null) { Option = GnssProcessOptionManager.Instance[GnssSolverType.无电离层组合PPP]; } //Solver.InfoProduced += Solver_InfoProduced; //Solver.ResultProduced += Solver_ResultProduced; //Solver.EpochEntityProduced += Solver_EpochEntityProduced; Solver.Completed += Solver_Completed; Solver.Option = Option; Solver.Option.IsOutputEpochResult = false; Solver.Init(inPath); var count = Solver.DataSource.ObsInfo.Count; //串行进度条初始化,阶段计算的第一个 //if (!ParallelConfig.EnableParallel) { this.ProgressBar.InitFirstProcessCount(count); } log.Info(Solver.Name + " 初始化完毕,开始计算。"); Solver.Run(); log.Info(Solver.Name + " 计算完成。"); }
public static IncarnationParams ProcessInputFiles(/* ref */ PackageEngineState engineState, out TimeSpan inputFilesTime) { var engine = new PackageEngine(engineState.CompiledDef, engineState.EngineContext); var incarnation = new IncarnationParams(); var fileManager = new InputFileManager(engineState.StoragePathBase); inputFilesTime = TimeSpanExt.Measure(() => { TimeSpan timeLimit = PB_PROCESS_TIME_LIMIT; try { Tools.ProcessWithTimeLimit(timeLimit, () => { engine.PrepareInputs(fileManager); CheckEngineResult(engine); }); } catch (TimeLimitException tle) { throw new PackageBaseException("Inputs processing in Package base exceeded time limit (" + timeLimit.TotalSeconds + " seconds).", tle); } finally { incarnation.FilesToCopy = incarnation.FilesToCopy.Concat(fileManager.GetInputFiles()).ToArray(); fileManager.Cleanup(); } }); object cmdLine = engine.Ctx.Memory[CmdLineDef.DefName].Value; //if (cmdLine == null) //throw new PackageBaseException("CommandLine generated by PackageBase is empty"); incarnation.CommandLine = cmdLine.ToString(); Log.Debug(String.Format( "Command line for pack {0}.{1} is '{2}' (task {3}). Cmdline object from PB is {4}", engine.CompiledMode.ModeQName.PackageName ?? "''", engine.CompiledMode.ModeQName.ModeName ?? "''", incarnation.CommandLine ?? "", engineState._taskDescription.TaskId, cmdLine == null ? "null" : "not null" )); if (String.IsNullOrWhiteSpace(incarnation.CommandLine)) throw new PackageBaseException("CommandLine generated by PackageBase is empty"); if (!engine.IsReadyToRun()) { Log.Warn("PackageBase: task is not ready to run after PrepareInputs"); Log.Error("PackageBase: task is not ready to run after PrepareInputs"); throw new PackageBaseException("PackageBase: task is not ready to run after processing inputs"); } return incarnation; }
/// <summary> /// 构造函数,观测文件在配置对象中 /// </summary> /// <param name="Option"></param> /// <param name="nFilePath">星历路径,如果不设置,则自动匹配</param> /// <param name="clkPath">路径,如果不设置,则自动匹配</param> public AbstractGnssStreamBackGroundRunner(GnssProcessOption Option, string nFilePath = null, string clkPath = null) { this.ClkFilePath = clkPath; InputFileManager inputFileManager = new InputFileManager(); List <string> obsFiles = inputFileManager.GetLocalFilePathes(Option.ObsFiles.ToArray(), "*.*o;*.rnx", "*.*"); this.ClkFilePath = clkPath; this.OFilePathes = obsFiles.ToArray(); this.EphFilePath = nFilePath; this.Option = Option; this.IsOutputResult = this.Option.IsOutputResult; this.ParallelConfig = new ParallelConfig(); }
/// <summary> /// 下载IGS产品。并返回成功后的本地路径。 /// </summary> /// <param name="gpsTime"></param> /// <param name="satType"></param> /// <returns></returns> protected List <string> DownloadProduct(Time gpsTime, SatelliteType satType = SatelliteType.G) { var urls = IgsProductUrlPathBuilder.SetSatelliteType(satType).Build(gpsTime).ToList(); if (Option.IsUniqueSource) { urls = urls.FindAll(m => Path.GetFileName(m).StartsWith(Option.IndicatedSourceCode)); } var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); return(InputFileManager.GetLocalFilePathes(urls.ToArray(), TargetExtention, TargetExtention + ";" + TargetExtention + ".Z", this.Option.IsDownloadingSurplurseIgsProducts)); }
/// <summary> /// 根据类型和历元,按照给定的文件命名规则,读取本地文件 /// </summary> /// <param name="satType">卫星类型</param> /// <param name="gpsTime">时间</param> /// <returns></returns> protected virtual List <string> GetFiles(SatelliteType satType, Time gpsTime) { List <string> pathes = GetIgsProductLocalPathes(satType, gpsTime); List <string> services = new List <string>(); foreach (var path in pathes)//便利所有生产的路径,选择一个可用的 { if (!System.IO.File.Exists(path)) { log.Debug("不存在预期产品 " + this.IgsProductSourceType + ", " + path); continue; } try { var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); var filePath = InputFileManager.GetLocalFilePath(path, TargetExtention, "*.*"); if (filePath == null) { continue; } FileInfo info = new FileInfo(path); if (info.Length == 0) { info.Delete(); continue; } //包含则添加 services.Add(path); } catch (Exception ex) { log.Error("文件解析错误," + path + ", " + ex.Message); } break; } return(services); }
public void BuildCharts() { ChartsGrid.Children.Clear(); ChartsGrid.RowDefinitions.Clear(); int rowIndex = 0; foreach (var channelName in ChannelNames) { if (selectedChannels.Contains(channelName.Item1)) { var group = new Group(GroupManager.LastGroupID++, channelName.Item1); foreach (var inputFile in channelName.Item2) { group.AddAttribute(InputFileManager.GetDriverlessInputFile(inputFile.Item1).GetChannel(channelName.Item1)); } BuildChartGrid(group, ref rowIndex); } } foreach (var group in GroupManager.Groups) { if (selectedGroups.Contains(group.Name)) { BuildChartGrid(group, ref rowIndex); } } RowDefinition chartRow = new RowDefinition() { Height = new GridLength() }; ChartsGrid.RowDefinitions.Add(chartRow); Grid.SetRow(new Grid(), rowIndex++); UpdateCharts(); }
public void SelectInputFile(string fileName = "") { InputFile inputFile; if (fileName.Equals(string.Empty)) { inputFile = InputFileManager.GetInputFile(activeInputFileID); } else { inputFile = InputFileManager.GetInputFile(fileName); } if (inputFile != null) { activeInputFileID = inputFile.ID; } else { if (InputFileManager.InputFiles.Count > 0) { activeInputFileID = InputFileManager.InputFiles.Last().ID; } else { activeInputFileID = -1; } } inputFile = InputFileManager.GetInputFile(activeInputFileID); if (inputFile != null) { foreach (RadioButton item in InputFilesStackPanel.Children) { item.IsChecked = item.Content.Equals(inputFile.Name); } } UpdateChannels(); }
private void UpdateChannels() { ChannelsStackPanel.Children.Clear(); var inputFile = InputFileManager.GetInputFile(activeInputFileID); if (inputFile != null) { var group = GroupManager.GetGroup(ActiveGroupID); foreach (var channel in inputFile.Channels) { var channelCheckbox = new CheckBox() { Content = channel.Name }; channelCheckbox.IsChecked = group.GetAttribute(channel.Name) != null; channelCheckbox.Checked += Channel_Checked; channelCheckbox.Unchecked += Channel_Checked; ChannelsStackPanel.Children.Add(channelCheckbox); } } }
/// <summary> /// Updates selected channels after a <see cref="CheckBox"/>-es state is changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChannelCheckBox_Click(object sender, RoutedEventArgs e) { var checkBox = (CheckBox)sender; string attributeName = checkBox.Content.ToString(); if ((bool)checkBox.IsChecked) { var inputFile = InputFileManager.GetInputFile(SelectedInputFileName); GroupManager.GetGroup(ActiveGroupID).AddAttribute(inputFile.GetChannel(attributeName)); ActiveAttributeID = GroupManager.GetGroup(ActiveGroupID).Attributes.Last().ID; } else { GroupManager.GetGroup(ActiveGroupID).RemoveAttribute(checkBox.Content.ToString()); if (GroupManager.Groups.Count > 0) { ActiveAttributeID = GroupManager.Groups[0].Attributes.Last().ID; } } InitGroups(); GroupManager.SaveGroups(); ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).BuildCharts(); }
private void InputFile_Checked(object sender, RoutedEventArgs e) { activeInputFileID = InputFileManager.GetInputFile(((RadioButton)sender).Content.ToString()).ID; UpdateChannels(); }
/// <summary> /// 具体的执行 /// </summary> /// <param name="baseline"></param> /// <param name="outPath"></param> protected void Execute(Baseline baseline, string outPath) { if (PathUtil.IsValidPath(CurrentParam.EphemerisPath)) { if (this.EphemerisDataSource == null || this.EphemerisDataSource.Name != Path.GetFileName(CurrentParam.EphemerisPath)) { var sp3 = InputFileManager.GetLocalFilePath(CurrentParam.EphemerisPath, "*.sp3"); if (PathUtil.IsValidPath(sp3)) { this.EphemerisDataSource = EphemerisDataSourceFactory.Create(sp3); } } } if (PathUtil.IsValidPath(CurrentParam.ClockPath)) { if (this.ClockFile == null || this.ClockFile.Name != Path.GetFileName(CurrentParam.ClockPath)) { var clk = InputFileManager.GetLocalFilePath(CurrentParam.ClockPath, "*.clk"); if (PathUtil.IsValidPath(clk)) { this.ClockFile = new Data.SimpleClockService(clk); } } } var refPath = ObsFiles.Find(m => m.ToLower().Contains(baseline.StartName.ToLower())); var rovPath = ObsFiles.Find(m => m.ToLower().Contains(baseline.EndName.ToLower())); if (refPath == null || rovPath == null) { throw new ArgumentException("没有找到基线对应的文件!" + baseline.ToString()); return; } var inputPathes = new string[] { refPath, rovPath }; RinexFileObsDataSource refObsDataSource = new RinexFileObsDataSource(refPath, true); RinexFileObsDataSource rovObsDataSource = new RinexFileObsDataSource(rovPath, true); if (SiteInfoDics != null) { var siteName = baseline.StartName.ToUpper(); if (SiteInfoDics.ContainsKey(siteName)) { refObsDataSource.SiteInfo.SetApproxXyz(SiteInfoDics[siteName].EstimatedXyz); } siteName = baseline.EndName.ToUpper(); if (SiteInfoDics.ContainsKey(siteName)) { rovObsDataSource.SiteInfo.SetApproxXyz(SiteInfoDics[siteName].EstimatedXyz); } } GnssProcessOption option = GnssProcessOption.GetDefault(GnsserConfig, refObsDataSource.ObsInfo); option.GnssSolverType = GnssSolverType.无电离层双差; var source = new MultiSiteObsStream(inputPathes, BaseSiteSelectType.GeoCenter, true, ""); DataSourceContext context = DataSourceContext.LoadDefault(option, source, EphemerisDataSource, ClockFile); IntegralGnssFileSolver Solver = new IntegralGnssFileSolver(); Solver.Completed += Solver_Completed; Solver.Option = option; Solver.IsCancel = false; Solver.Solver = GnssSolverFactory.Create(context, option);; Solver.Init(inputPathes); Solver.Run(); var last = Solver.CurrentGnssResult; lock (locker) { Geo.Utils.FileUtil.CheckOrCreateDirectory(Path.GetDirectoryName(outPath)); SaveLastResult(last); } }
/// <summary> /// 根据类型和历元,按照给定的文件命名规则,读取本地文件 /// </summary> /// <param name="satType">卫星类型</param> /// <param name="gpsTime">时间</param> /// <returns></returns> protected virtual List <TIgsProductFile> GetFiles(SatelliteType satType, Time gpsTime) { List <string> pathes = GetIgsProductLocalPathes(satType, gpsTime); List <TIgsProductFile> services = new List <TIgsProductFile>(); foreach (var path in pathes)//便利所有生产的路径,选择一个可用的 { if (!System.IO.File.Exists(path)) { log.Debug("不存在预期产品 " + this.IgsProductSourceType + ", " + path); continue; } try { var TargetExtention = "*" + IgsProductNameBuilder.GetFileExtension(IgsProductSourceType, gpsTime).TrimEnd('Z', '.'); var filePath = InputFileManager.GetLocalFilePath(path, TargetExtention, "*.*"); if (filePath == null) { continue; } string fileBufferKey = BuildFileBufferKey(filePath); TIgsProductFile service = default(TIgsProductFile); if (LoadedIgsProductFiles.Contains(fileBufferKey)) { log.Info("缓存已经加载同名文件,直接从缓存返回: " + filePath); service = LoadedIgsProductFiles[fileBufferKey]; } else { service = LoadFile(filePath); if (service == null || service.TimePeriod.Span == 0) { log.Info("数据源" + service + "不可用 " + this.IgsProductSourceType + "," + filePath); continue; } log.Info("成功载入 " + this.IgsProductSourceType + "," + filePath); if (LoadedIgsProductFiles.Count > Option.MaxIgsProductCacheCount) { LoadedIgsProductFiles.RemoveFirst(); //LoadedIgsProductFiles.Clear(); //log.Info("IGS 缓存产品超过最大数量 " + Option.MaxIgsProductCacheCount + ", 清空缓存重新来过。"); } LoadedIgsProductFiles[fileBufferKey] = service; } //包含则添加 services.Add(service); } catch (Exception ex) { log.Error("文件解析错误," + path + ", " + ex.Message); } break; } return(services); }