SignalProcHelper.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace CheckServer
  8. {
  9. public static class SignalProcHelper
  10. {
  11. private const string dll = @"AddIns\SignalProc.dll";
  12. #region cpp dll Interop
  13. [DllImport(dll, EntryPoint = "SigalEst", CallingConvention = CallingConvention.Cdecl)]
  14. private extern static void SigalEst(string file, long fsHz, int[] smpStart, int[] smpCount, int[] modes, double[] rates, double[] ffcs, int len);
  15. #endregion
  16. static List<int> list1 = new List<int>();
  17. static List<int> list2 = new List<int>();
  18. public static List<SignalProcRes> SigalEst(string file, long fsHz, int[] smpStart, int[] smpCount)
  19. {
  20. for (int i = 0; i < smpStart.Length; i++)
  21. {
  22. if (!list1.Contains(smpStart[i]))
  23. list1.Add(smpStart[i]);
  24. if (!list2.Contains(smpCount[i]))
  25. list2.Add(smpCount[i]);
  26. }
  27. int sigCount = smpStart.Length;
  28. int[] modes = new int[sigCount];//信号模式
  29. double[] rates = new double[sigCount];//调制速率
  30. double[] ffcs = new double[sigCount];//信号频偏Hz
  31. SigalEst(file, fsHz, smpStart, smpCount, modes, rates, ffcs, sigCount);
  32. List<SignalProcRes> list = new List<SignalProcRes>();
  33. for (int i = 0; i < modes.Length; i++)
  34. {
  35. SignalProcRes item = new SignalProcRes()
  36. {
  37. SignalType = (EnumSignalType)modes[i],
  38. Ffc = Math.Round(ffcs[i], 2),
  39. Rate = Math.Round(rates[i], 2),
  40. };
  41. list.Add(item);
  42. }
  43. return list;
  44. }
  45. }
  46. public class SignalProcRes
  47. {
  48. /// <summary>
  49. /// 信号类型
  50. /// </summary>
  51. public EnumSignalType SignalType { get; set; }
  52. /// <summary>
  53. /// 调制速率(bps)
  54. /// </summary>
  55. public double Rate { get; set; }
  56. /// <summary>
  57. /// 频偏
  58. /// </summary>
  59. public double Ffc { get; set; }
  60. }
  61. public enum EnumSignalType
  62. {
  63. SUNKNOW = -1, //UNKNOW
  64. BPSK = 1, //BPSK 备注为界面显示字母
  65. OQPSK = 2, //OQPSK
  66. QPSK = 3, //QPSK
  67. P4QPSK = 4, //Pi/4QPSK
  68. _8PSK = 5, //8PSK
  69. _16APSK = 6, //16APSK
  70. _32APSK = 7 //32APSK
  71. }
  72. }