using CliWrap; using CliWrap.Buffered; using Ips.Library.Basic; using Ips.Library.CliLib; using Ips.Library.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Ips.LocAlgorithm { public static class LocRhUtil { static readonly string CliPath = Path.Combine(IpsPath.CliRootDir, "locrh", "locrh.exe"); public static async Task> GdopErr(double[] pos, double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default) { const string cmd = "gdoperr"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(pos), pos); args.IpsAdd(nameof(recgeod), recgeod); args.IpsAdd(nameof(mseph1), mseph1); args.IpsAdd(nameof(nseph1), nseph1); args.IpsAdd(nameof(mseph2), mseph2); args.IpsAdd(nameof(nseph2), nseph2); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var result = GdopErrResult.FromString(res.StandardOutput); return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode); } public static async Task> GdopErrRef(double[] pos, double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default) { const string cmd = "gdoperrref"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(pos), pos); args.IpsAdd(nameof(refgeod), refgeod); args.IpsAdd(nameof(mseph1), mseph1); args.IpsAdd(nameof(nseph1), nseph1); args.IpsAdd(nameof(mseph2), mseph2); args.IpsAdd(nameof(nseph2), nseph2); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var result = GdopErrResult.FromString(res.StandardOutput); return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode); } } }