SignalProcHelper.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. public static List<SignalProcRes> SigalEst(string file, long fsHz, int[] smpStart, int[] smpCount)
  17. {
  18. int sigCount = smpStart.Length;
  19. int[] modes = new int[sigCount];//信号模式
  20. double[] rates = new double[sigCount];//调制速率
  21. double[] ffcs = new double[sigCount];//信号频偏Hz
  22. SigalEst(file, fsHz, smpStart, smpCount, modes, rates, ffcs, sigCount);
  23. List<SignalProcRes> list = new List<SignalProcRes>();
  24. for (int i = 0; i < modes.Length; i++)
  25. {
  26. SignalProcRes item = new SignalProcRes()
  27. {
  28. SignalType = (EnumSignalType)modes[i],
  29. Ffc = Math.Round(ffcs[i], 2),
  30. Rate = Math.Round(rates[i], 2),
  31. };
  32. list.Add(item);
  33. }
  34. return list;
  35. }
  36. }
  37. public class SignalProcRes
  38. {
  39. /// <summary>
  40. /// 信号类型
  41. /// </summary>
  42. public EnumSignalType SignalType { get; set; }
  43. /// <summary>
  44. /// 调制速率(bps)
  45. /// </summary>
  46. public double Rate { get; set; }
  47. /// <summary>
  48. /// 频偏
  49. /// </summary>
  50. public double Ffc { get; set; }
  51. }
  52. public enum EnumSignalType
  53. {
  54. SUNKNOW = -1, //UNKNOW
  55. BPSK = 1, //BPSK 备注为界面显示字母
  56. OQPSK = 2, //OQPSK
  57. QPSK = 3, //QPSK
  58. P4QPSK = 4, //Pi/4QPSK
  59. _8PSK = 5, //8PSK
  60. _16APSK = 6, //16APSK
  61. _32APSK = 7 //32APSK
  62. }
  63. }