123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549 |
- 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;
- using System.Threading.Tasks;
- namespace Ips.LocAlgorithm
- {
- public class Loc32Util
- {
- static readonly string CliPath = Path.Combine(IpsPath.CliRootDir, "loc32", "loc32.exe");
- public static async Task<ExeResult<PosResult>> X3(
- double dtotar1,
- double dtotar2,
- double[] msant1,
- double[] nsant1,
- double[] msant2,
- double[] nsant2,
- double[] mseph1,
- double[] nseph1,
- double[] mseph2,
- double[] nseph2,
- int timeout = 60,
- CancellationToken token = default
- )
- {
- const string cmd = "x3";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(dtotar1), dtotar1);
- args.IpsAdd(nameof(dtotar2), dtotar2);
- args.IpsAdd(nameof(msant1), msant1);
- args.IpsAdd(nameof(nsant1), nsant1);
- args.IpsAdd(nameof(msant2), msant2);
- args.IpsAdd(nameof(nsant2), nsant2);
- 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 dwResult = PosResult.FromString(PosType.X3, false, res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
- }
- public static async Task<ExeResult<PosResult>> X3Ref(
- double dtotar1,
- double dtotar2,
- double dtoref1,
- double dtoref2,
- double[] refgeod1,
- double[] refgeod2,
- double[] msant1,
- double[] nsant1,
- double[] msant2,
- double[] nsant2,
- double[] mseph1,
- double[] nseph1,
- double[] mseph2,
- double[] nseph2,
- int timeout = 60,
- CancellationToken token = default
- )
- {
- const string cmd = "x3ref";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(dtotar1), dtotar1);
- args.IpsAdd(nameof(dtotar2), dtotar2);
- args.IpsAdd(nameof(dtoref1), dtoref1);
- args.IpsAdd(nameof(dtoref2), dtoref2);
- args.IpsAdd(nameof(refgeod1), refgeod1);
- args.IpsAdd(nameof(refgeod2), refgeod2);
- args.IpsAdd(nameof(msant1), msant1);
- args.IpsAdd(nameof(nsant1), nsant1);
- args.IpsAdd(nameof(msant2), msant2);
- args.IpsAdd(nameof(nsant2), nsant2);
- 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 dwResult = PosResult.FromString(PosType.X3Ref, true, res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
- }
- public static Task<ExeResult<PosResult>> X4(
- double dtotar1,
- double dtotar2,
- double dtotar3,
- double[] nsant1,
- double[] nsant2,
- double[] nsant3,
- double[] nseph1,
- double[] nseph2,
- double[] nseph3,
- int timeout = 60,
- CancellationToken token = default
- )
- {
- var dt1 = dtotar2 - dtotar1;
- var dt2 = dtotar3 - dtotar1;
- return X3(dt1, dt2, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token);
- }
- public static Task<ExeResult<PosResult>> X4Ref(
- double dtotar1,
- double dtotar2,
- double dtotar3,
- double dtoref1,
- double dtoref2,
- double dtoref3,
- double[] refgeod,
- double[] nsant1,
- double[] nsant2,
- double[] nsant3,
- double[] nseph1,
- double[] nseph2,
- double[] nseph3,
- int timeout = 60,
- CancellationToken token = default
- )
- {
- var dt1 = dtotar2 - dtotar1;
- var dt2 = dtotar3 - dtotar1;
- var refdt1 = dtoref2 - dtoref1;
- var refdt2 = dtoref3 - dtoref1;
- return X3Ref(dt1, dt2, refdt1, refdt2, refgeod, refgeod, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token);
- }
- public static async Task<ExeResult<List<GeoLine>>> DtoLineSx(double dtotar, double[] msant, double[] nsant, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "dtolinesx";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(dtotar), dtotar);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<List<GeoLine>>> DtoLineSxRef(double dtotar, double dtoref, double[] refgeod, double[] mseph, double[] nseph, double[] msant, double[] nsaant, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "dtolinesxref";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(dtotar), dtotar);
- args.IpsAdd(nameof(dtoref), dtoref);
- args.IpsAdd(nameof(refgeod), refgeod);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<List<GeoLine>>> DtoLineLoc(double[] pos, double[] msant, double[] nsant, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "dtolineloc";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(pos), pos);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<PosResult>> X2Ref(
- double[] msant,
- double[] nsant,
- double[] refgeod,
- double tarfreq,
- double reffreq,
- double msturn,
- double nsturn,
- double dtotar,
- double dtoref,
- double dfotar,
- double dforef,
- double[] mseph,
- double[] nseph,
- int timeout = 60,
- CancellationToken token = default
- )
- {
- const string cmd = "x2ref";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- args.IpsAdd(nameof(refgeod), refgeod);
- args.IpsAdd(nameof(tarfreq), tarfreq);
- args.IpsAdd(nameof(reffreq), reffreq);
- args.IpsAdd(nameof(msturn), msturn);
- args.IpsAdd(nameof(nsturn), nsturn);
- args.IpsAdd(nameof(dtotar), dtotar);
- args.IpsAdd(nameof(dtoref), dtoref);
- args.IpsAdd(nameof(dfotar), dfotar);
- args.IpsAdd(nameof(dforef), dforef);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = PosResult.FromString(PosType.X2Ref, true, res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
- }
- public static async Task<ExeResult<PosResult>> X3Df(
- double tarfreq,
- double reffreq,
- double msturn,
- double nsturn,
- double dfotar1,
- double dfotar2,
- double dforef1,
- double dforef2,
- double[] refgeod1,
- double[] refgeod2,
- double[] msant1,
- double[] nsant1,
- double[] msant2,
- double[] nsant2,
- double[] mseph1,
- double[] nseph1,
- double[] mseph2,
- double[] nseph2,
- int timeout = 60,
- CancellationToken token = default)
- {
- const string cmd = "x3df";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(tarfreq), tarfreq);
- args.IpsAdd(nameof(reffreq), reffreq);
- args.IpsAdd(nameof(msturn), msturn);
- args.IpsAdd(nameof(nsturn), nsturn);
- args.IpsAdd(nameof(dfotar1), dfotar1);
- args.IpsAdd(nameof(dfotar2), dfotar2);
- args.IpsAdd(nameof(dforef1), dforef1);
- args.IpsAdd(nameof(dforef2), dforef2);
- args.IpsAdd(nameof(refgeod1), refgeod1);
- args.IpsAdd(nameof(refgeod2), refgeod2);
- args.IpsAdd(nameof(msant1), msant1);
- args.IpsAdd(nameof(nsant1), nsant1);
- args.IpsAdd(nameof(msant2), msant2);
- args.IpsAdd(nameof(nsant2), nsant2);
- 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 dwResult = PosResult.FromString(PosType.X3Ref, true, res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
- }
- public static async Task<ExeResult<List<GeoLine>>> DtoLineLocRef(double[] pos, double[] refgeod, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "dtolinelocref";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(pos), pos);
- args.IpsAdd(nameof(refgeod), refgeod);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<List<GeoLine>>> DtoLineYiDi(double dtotar, double[] mseph, double[] nseph, double[] msant, double[] nsant, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "dtolineyidi";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(dtotar), dtotar);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<List<GeoLine>>> DfoLine(
- double[] msant,
- double[] nsant,
- double[] mseph,
- double[] nseph,
- double[] dfo,
- double frequp,
- double msturn,
- double nsturn,
- double? refdfo = null,
- double? reffrequp = null,
- double[] refgeod = null,
- double[] pos = null,
- int timeout = 60,
- CancellationToken token = default)
- {
- const string cmd = "dfoline";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- args.IpsAdd(nameof(dfo), dfo);
- args.IpsAdd(nameof(frequp), frequp);
- args.IpsAdd(nameof(msturn), msturn);
- args.IpsAdd(nameof(nsturn), nsturn);
- if (refdfo.HasValue)
- args.IpsAdd(nameof(refdfo), refdfo);
- if (reffrequp.HasValue)
- args.IpsAdd(nameof(reffrequp), reffrequp);
- if (refgeod != null && refgeod.Length > 1)
- args.IpsAdd(nameof(refgeod), refgeod);
- if (pos != null && pos.Length > 1)
- args.IpsAdd(nameof(pos), pos);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dwResult = GeoLine.FromListString(res.StandardOutput);
- return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<GdopResult>> Gdop(double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "gdop";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- 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 = new GdopResult(res.StandardOutput);
- return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<GdopResult>> GdopRef(double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "gdopref";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- 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 = new GdopResult(res.StandardOutput);
- return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<LocErrResult>> LocErr(double[] pos, double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "locerr";
- 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 = new LocErrResult(res.StandardOutput);
- return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<LocErrResult>> LocErrRef(double[] pos, double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "locerrref";
- 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 = new LocErrResult(res.StandardOutput);
- return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<double>> RefCalc(DateTime[] intimes, double[] inmsephs, double[] innsephs, double[] indtorefs, double[] refgeod, double[] recgeod, DateTime time, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
- {
- const string cmd = "refcalc";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(intimes), intimes);
- args.IpsAdd(nameof(inmsephs), inmsephs);
- args.IpsAdd(nameof(innsephs), innsephs);
- args.IpsAdd(nameof(indtorefs), indtorefs);
- args.IpsAdd(nameof(refgeod), refgeod);
- args.IpsAdd(nameof(recgeod), recgeod);
- args.IpsAdd(nameof(time), time);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dtoRefOut = double.Parse(res.StandardOutput);
- return ExeResult.Create(dtoRefOut, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- //[CommandOption("pos", 'p', Description = "定位点位置", IsRequired = true)]
- //public double[] Pos { get; set; }
- //[CommandOption("mseph", Description = "主星星历", IsRequired = true)]
- //public double[] MsEph { get; set; }
- //[CommandOption("nseph", Description = "邻星星历", IsRequired = true)]
- //public double[] NsEph { get; set; }
- //[CommandOption("msant", Description = "主星天线位置", IsRequired = true)]
- //public double[] MsAnt { get; set; }
- //[CommandOption("nsant", Description = "邻星天线位置", IsRequired = true)]
- //public double[] NsAnt { get; set; }
- //[CommandOption("refgeod", Description = "参考站位置")]
- //public double[] RefGeod { get; set; }
- public static async Task<ExeResult<double>> CalcDt(
- double[] pos,
- double[] mseph,
- double[] nseph,
- double[] msant,
- double[] nsant,
- double[] refgeod = null,
- int timeout = 60,
- CancellationToken token = default)
- {
- const string cmd = "calcdt";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(pos), pos);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- if (refgeod != null && refgeod.Length > 1)
- args.IpsAdd(nameof(refgeod), refgeod);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dtoRefOut = double.Parse(res.StandardOutput);
- return ExeResult.Create(dtoRefOut, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- public static async Task<ExeResult<double>> CalcDf(
- double frequp,
- double msturn,
- double nsturn,
- double[] pos,
- double[] mseph,
- double[] nseph,
- double[] msant,
- double[] nsant,
- double? reffrequp = null,
- double[] refgeod = null,
- int timeout = 60,
- CancellationToken token = default)
- {
- const string cmd = "calcdf";
- var cli = Cli.Wrap(CliPath)
- .WithArguments(args =>
- {
- args.Add(cmd);
- args.IpsAdd(nameof(frequp), frequp);
- args.IpsAdd(nameof(msturn), msturn);
- args.IpsAdd(nameof(nsturn), nsturn);
- args.IpsAdd(nameof(pos), pos);
- args.IpsAdd(nameof(mseph), mseph);
- args.IpsAdd(nameof(nseph), nseph);
- args.IpsAdd(nameof(msant), msant);
- args.IpsAdd(nameof(nsant), nsant);
- if (reffrequp.HasValue)
- args.IpsAdd(nameof(reffrequp), reffrequp);
- if (refgeod != null && refgeod.Length > 1)
- args.IpsAdd(nameof(refgeod), refgeod);
- });
- var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
- var dtoRefOut = double.Parse(res.StandardOutput);
- return ExeResult.Create(dtoRefOut, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
- }
- }
- }
|