| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using CliWrap;
- using CliWrap.Buffered;
- using Ips.Library.Basic;
- using Ips.Library.Entity;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ips.CorAlgorithm
- {
- public static class CorGpuUtil
- {
- static readonly string CliFile = Path.Combine(IpsPath.CliRootDir, "corg", "corg.exe");
- public static async Task<ExeResult<CorResult[]>> Calc(string file1, string file2, CorOptions options, int timeout = 0, CancellationToken token = default)
- {
- if (options == null)
- {
- throw new ArgumentNullException(nameof(options));
- }
- if (options.Timeslots != null && options.Timeslots.Length == 0)
- {
- throw new Exception("没有需要计算的时隙!");
- }
- var cli = Cli.Wrap(CliFile)
- .WithArguments(args =>
- {
- args.Add(file1);
- args.Add(file2);
- args.Add(options.DtoCenter, false);
- args.Add(options.DtoRange, false);
- args.Add(options.Snr, false);
- args.Add(options.DfoRange, false);
- args.Add(options.DtoCorr, false);
- args.Add(options.DfoCorr, false);
- args.Add(options.Fs, false);
- args.Add("-l").Add(options.DataLen, false);
- args.Add("-z").Add(options.AddZero, false);
- args.Add("-o").Add(options.TimeOffset, false);
- args.Add("-f").Add((int)options.OffsetType, false);
- if (options.Timeslots != null)
- {
- args.Add("-d").Add(options.Timeslots.JoinAsString(" "), false);
- args.Add("-m").Add(options.MergeType.ToString("d"), false);
- }
- }).WithValidation(CommandResultValidation.None);
- var res = await cli.ExecuteBufferedAsync(timeout == 0 ? token : token.LinkTimeout(timeout));
- var result = CorResult.FromLines(res.StandardOutput, options.Snr);
- return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
- }
- }
- }
|