|
@@ -8,12 +8,68 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using XdCxRhDW.Dto;
|
|
|
using System.Security.Policy;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
+using DevExpress.Utils.Text.Internal;
|
|
|
+using System.Text;
|
|
|
|
|
|
namespace CheckServer
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
public static class CheckHelper
|
|
|
{
|
|
|
+ enum SigFlag : int
|
|
|
+ {
|
|
|
+ BPSK = 1,
|
|
|
+ QPSK = 2
|
|
|
+ }
|
|
|
+
|
|
|
+ struct slot
|
|
|
+ {
|
|
|
+ public SigFlag sigflag;
|
|
|
+ public int start;
|
|
|
+ public int len;
|
|
|
+ public SigMod mode;
|
|
|
+ public double ps;//码元速率
|
|
|
+ };
|
|
|
+ enum SigMod : int
|
|
|
+ {
|
|
|
+ bp96_ccow = 0,
|
|
|
+ bp96_01 = 1,
|
|
|
+ bp96_02 = 2,
|
|
|
+ bp96_03 = 3,
|
|
|
+ bp96_04 = 4,
|
|
|
+
|
|
|
+ bp192_01 = 5,
|
|
|
+ bp192_02 = 6,
|
|
|
+ bp192_03 = 7,
|
|
|
+ qp16_01 = 8,
|
|
|
+ qp16_02 = 9,
|
|
|
+ qp16_03 = 10,
|
|
|
+ qp16_04 = 11,
|
|
|
+ qp16_05 = 12,
|
|
|
+ qp16_06 = 13,
|
|
|
+ qp16_07 = 14,
|
|
|
+ qp16_08 = 15,
|
|
|
+ qp16_09 = 16,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private const string dll = @"AddIns\PSignalCheck.dll";//张志明写的DAMA检测算法,根据特征码识别
|
|
|
+
|
|
|
+
|
|
|
+ #region cpp dll Interop
|
|
|
+ [DllImport(dll, EntryPoint = "SigalEst", CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private extern static void SigalEst(string file, long fsHz, int[] smpStart, int[] smpCount, int[] modes, double[] rates, double[] ffcs, double[] snrs, int len);
|
|
|
+
|
|
|
+ [DllImport(dll, EntryPoint = "PSignalInit", CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private static extern bool PSignalInit();
|
|
|
+
|
|
|
+ [DllImport(dll, EntryPoint = "PSignalCheck", CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private static extern int PSignalCheck(String ifile, Int64 fsample, double snr, ref IntPtr signalslots);
|
|
|
+
|
|
|
+ [DllImport(dll, EntryPoint = "pSignalFree", CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private static extern void pSignalFree(IntPtr ipt);
|
|
|
+ #endregion
|
|
|
public static async Task<IEnumerable<DmcResult>> DmcCheckAsync(string fileName, double fsHz, EnumSigCheckTypeDto dmcType, double? bandKHz = null)
|
|
|
{
|
|
|
if (bandKHz == null || bandKHz.Value <= 0) bandKHz = 25;
|
|
@@ -50,17 +106,54 @@ namespace CheckServer
|
|
|
dmp.StartInfo.RedirectStandardError = true;
|
|
|
dmp.StartInfo.RedirectStandardOutput = true;
|
|
|
dmp.StartInfo.UseShellExecute = false;
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ dmp.OutputDataReceived += (sender, e) =>
|
|
|
+ {
|
|
|
+ sb.AppendLine(e.Data);
|
|
|
+ };
|
|
|
dmp.Start();
|
|
|
+ dmp.BeginOutputReadLine();
|
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
|
stopWatch.Start();
|
|
|
dmp.WaitForExit();
|
|
|
stopWatch.Stop();
|
|
|
TimeSpan ts = stopWatch.Elapsed;
|
|
|
- var str = dmp.StandardOutput.ReadToEnd();
|
|
|
+ var str = sb.ToString();
|
|
|
return ConvertDmcResult(dmcType, str, ts.TotalMilliseconds);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public static async Task<IEnumerable<DmcResult>> DAMACheckAsync(string fileName, double fsHz, EnumSigCheckTypeDto dmcType, double? bandKHz = null)
|
|
|
+ {
|
|
|
+ var val = await Task.Run(() =>
|
|
|
+ {
|
|
|
+ Stopwatch stopWatch = new Stopwatch();
|
|
|
+ stopWatch.Start();
|
|
|
+ IntPtr res = IntPtr.Zero;
|
|
|
+ PSignalInit();
|
|
|
+ int rcount = PSignalCheck(fileName, (long)fsHz, 18, ref res);
|
|
|
+ List<slot> rcontainer = new List<slot>();
|
|
|
+ for (int idx = 0; idx < rcount; ++idx)
|
|
|
+ {
|
|
|
+ IntPtr tmp = IntPtr.Add(res, idx * Marshal.SizeOf<slot>());
|
|
|
+ slot sl = Marshal.PtrToStructure<slot>(tmp);
|
|
|
+ rcontainer.Add(sl);
|
|
|
+ }
|
|
|
+
|
|
|
+ pSignalFree(res);
|
|
|
+ stopWatch.Stop();
|
|
|
+ return rcontainer.Select(t => new DmcResult()
|
|
|
+ {
|
|
|
+ DmcType = dmcType.GetEnumDisplayName(),
|
|
|
+ Length = t.len,
|
|
|
+ Start = t.start,
|
|
|
+ //UserName = t.mode.ToString(),
|
|
|
+ Times = (int)stopWatch.ElapsedMilliseconds,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+
|
|
|
private static IEnumerable<DmcResult> ConvertDmcResult(EnumSigCheckTypeDto type, string res, double tm)
|
|
|
{
|
|
|
var lines = res.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries);
|