private static Output GetOutput(ConfigFile config) { string text = config.OutputFile.ToLower(); string a = Path.GetExtension(text).ToLowerInvariant(); if (a == ".bin") { return(new LabSat1Output(config.OutputFile)); } Quantization bitsPerSample = (Quantization)config.BitsPerSample; if (a == ".ls3w") { return(new LabSat3wOutput(config.OutputFile, config.SignalTypes, bitsPerSample)); } if (a == ".ls2") { return(new LabSat2Output(config.OutputFile, config.SignalTypes, bitsPerSample)); } if (text == "%labsat2%") { return(new LabSat2LiveOutput(config.SignalTypes, bitsPerSample, isLowLatency: true)); } if (text == "%labsat2rt%") { DateTime utcNow = DateTime.UtcNow; GnssTime value = GnssTime.FromUtc(new DateTime(utcNow.Ticks - utcNow.Ticks % 10000000) + TimeSpan.FromSeconds(10.0)); return(new LabSat2LiveOutput(config.SignalTypes, bitsPerSample, isLowLatency: true, value)); } if (a == ".ls3") { return(new LabSat3Output(config.OutputFile, config.SignalTypes, bitsPerSample)); } throw new ArgumentException("No supported output type for file \"" + config.OutputFile + "\""); }
private static Simulation GetSimulator(ConfigFile config, Output output, TrajectorySource trajectorySource) { if (!File.Exists(config.NmeaFile)) { throw new ArgumentException("NMEA file does not exist"); } GnssTime gnssTime = GnssTime.FromUtc(config.Date); ILiveOutput liveOutput = output as ILiveOutput; if (liveOutput != null && liveOutput.IsTrueTime) { gnssTime = liveOutput.StartTime - GnssTimeSpan.FromSeconds(1); GnssTime startTime = liveOutput.StartTime; } else { gnssTime = GnssTime.FromUtc(config.Date); } Trajectory trajectory = (trajectorySource != TrajectorySource.Joystick) ? new NmeaFileTrajectory(gnssTime, config.NmeaFile, config.GravitationalModel) : new JoystickTrajectory(throttleSlider: Key.Z.IsDownAsync() ? JoystickSlider.ZAxis : (Key.D2.IsDownAsync() ? JoystickSlider.Slider2 : JoystickSlider.Slider1), startTime: gnssTime, nmeaFileName: config.NmeaFile, gravitationalModel: config.GravitationalModel); Range <GnssTime, GnssTimeSpan> interval = trajectory.Interval; if (interval.Width.Seconds < 1.0) { string text = trajectory.ErrorMessage; if (string.IsNullOrWhiteSpace(text)) { text = "Trajectory is shorter than one second"; } RLLogger.GetLogger().LogMessage(text); MessageBox.Show(Application.Current.MainWindow, text, "SatGen error", MessageBoxButton.OK, MessageBoxImage.Hand); return(null); } IReadOnlyList <ConstellationBase> readOnlyList = ConstellationBase.Create(config.SignalTypes, output); foreach (ConstellationBase item in readOnlyList) { string almanacPath = GetAlmanacPath(item.ConstellationType, config); item.LoadAlmanac(almanacPath, gnssTime); AlmanacBase almanac = item.Almanac; if (almanac == null || !almanac.BaselineSatellites.Any()) { string text2 = "Invalid " + item.ConstellationType.ToLongName() + " almanac file \"" + Path.GetFileName(almanacPath) + "\""; RLLogger.GetLogger().LogMessage(text2); MessageBox.Show(Application.Current.MainWindow, text2, "SatGen error", MessageBoxButton.OK, MessageBoxImage.Hand); return(null); } AlmanacBase almanac2 = item.Almanac; GnssTime simulationTime = interval.Start; almanac2.UpdateAlmanacForTime(simulationTime); } return(new DoubleBufferSimulation(new SimulationParams((IReadOnlyList <SignalType>)config.SignalTypes, trajectory, interval, output, readOnlyList, config.Mask, (IDictionary <ConstellationType, double>)config.CN0s, SignalLevelMode.None))); }
public static void runoutside(string[] args) { Console.WriteLine("blah.exe profile.txt"); string[] commandLineArgs = Environment.GetCommandLineArgs(); ConfigFile config = ConfigFile.Read(commandLineArgs[1]); Console.WriteLine(config.ToJSON()); //Environment.NewLine = "\r\n"; using (NmeaFile nmeaFile = new NmeaFile(config.NmeaFile)) { //Console.WriteLine(nmeaFile.ToJSON()); } string text = config.OutputFile.ToLower(); string a = Path.GetExtension(text) !.ToLowerInvariant(); Quantization bitsPerSample = (Quantization)config.BitsPerSample; var output = new LabSat3wOutput(config.OutputFile, config.SignalTypes, bitsPerSample); Console.WriteLine(output.ChannelPlan.ToJSON()); GnssTime startTime = GnssTime.FromUtc(config.Date); Console.WriteLine(startTime.ToJSON()); Trajectory trajectory = new NmeaFileTrajectory(in startTime, config.NmeaFile, config.GravitationalModel); Range <GnssTime, GnssTimeSpan> interval = trajectory.Interval; Console.WriteLine(interval.ToJSON()); IReadOnlyList <ConstellationBase> readOnlyList = ConstellationBase.Create(config.SignalTypes); foreach (ConstellationBase item in readOnlyList) { string almanacPath = GetAlmanacPath(item.ConstellationType, config); if (!item.LoadAlmanac(almanacPath, in startTime)) { string text2 = "Invalid " + item.ConstellationType.ToLongName() + " almanac file \"" + Path.GetFileName(almanacPath) + "\""; RLLogger.GetLogger().LogMessage(text2); //MessageBox.Show(Application.Current.MainWindow, text2, "SatGen error", MessageBoxButton.OK, MessageBoxImage.Hand); return; } AlmanacBase?almanac = item.Almanac; GnssTime simulationTime = interval.Start; almanac !.UpdateAlmanacForTime(in simulationTime); } Console.WriteLine( (config.SignalTypes, trajectory, interval, output, /*readOnlyList*/ 0, config.Mask, config.Attenuation).ToJSON()); var simulation = Simulation.Create(new SimulationParams(config.SignalTypes, trajectory, in interval, output, readOnlyList, config.Mask, config.Attenuation)); DoPatch(); simulation.Start(); var progress = 0.0; simulation.ProgressChanged += (o, e) => { progress = e.Progress; }; while (simulation.SimulationState != SimulationState.Finished) { Thread.Sleep(1000); Console.WriteLine("{0} {1} ", progress, simulation.SimulationState); } }