XdcUtil.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using CliWrap;
  8. using Ips.Library.Basic;
  9. using Ips.Library.Entity;
  10. namespace Ips.Library.LocLib
  11. {
  12. public static class XdcUtil
  13. {
  14. static readonly string CliFile = Path.Combine(IpsPath.CliRootDir, "xdc", "xdc.exe");
  15. public static async Task<CommandResult> ExecuteAsync(string fileIn, string fileOut, double fs, XdcItem[] items, int th = 6, CancellationToken token = default)
  16. {
  17. var len = items.Length;
  18. var ffcs = new double[len];
  19. var bws = new double[len];
  20. var mods = new ModuType[len];
  21. for (int i = 0; i < len; i++)
  22. {
  23. var item = items[i];
  24. ffcs[i] = item.Ffc;
  25. bws[i] = item.BandWidth;
  26. mods[i] = item.ModuType;
  27. }
  28. var cli = Cli.Wrap(CliFile)
  29. .WithArguments(args =>
  30. {
  31. args.Add(fileIn, true);
  32. args.Add(fileOut, true);
  33. args.Add(fs);
  34. args.Add("--ffcs").Add(ffcs.JoinAsString(" "), false);
  35. args.Add("--bws").Add(bws.JoinAsString(" "), false);
  36. args.Add("--mods").Add(mods.Select(m => m.ToString("d")).JoinAsString(" "), false);
  37. args.Add("--th").Add(th);
  38. });
  39. var resCmd = await cli.ExecuteAsync(token);
  40. return resCmd;
  41. }
  42. }
  43. public class XdcItem
  44. {
  45. public XdcItem()
  46. {
  47. }
  48. /// <summary>
  49. /// 同频对消参数
  50. /// </summary>
  51. /// <param name="ffc">频偏(MHz)</param>
  52. /// <param name="bandWidth">信号带宽(MHz)</param>
  53. /// <param name="moduType">调制方式</param>
  54. public XdcItem(double ffc, double bandWidth, ModuType moduType)
  55. {
  56. Ffc = ffc;
  57. BandWidth = bandWidth;
  58. ModuType = moduType;
  59. }
  60. /// <summary>
  61. /// 频偏(MHz)
  62. /// </summary>
  63. public double Ffc { get; set; }
  64. /// <summary>
  65. /// 信号带宽(MHz)
  66. /// </summary>
  67. public double BandWidth { get; set; }
  68. /// <summary>
  69. /// 调制方式
  70. /// </summary>
  71. public ModuType ModuType { get; set; }
  72. }
  73. }