|
@@ -1,13 +1,9 @@
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
-using System.Linq;
|
|
|
-using System.Reflection;
|
|
|
using System.Threading.Tasks;
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
using XdCxRhDW.Dto;
|
|
|
-using System.Security.Policy;
|
|
|
|
|
|
namespace CpuCgServer
|
|
|
{
|
|
@@ -39,10 +35,46 @@ namespace CpuCgServer
|
|
|
return xItem;
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
+ public class MultiXcorrStruct
|
|
|
+ {
|
|
|
+ public String file1 { get; set; }
|
|
|
+ public String file2 { get; set; }
|
|
|
+
|
|
|
+ public List<XcorrSmp> xcorrSmps { get; set; }
|
|
|
+ public double samplingRate { get; set; } //采样率
|
|
|
+ public double dtCenter { get; set; } //时差中心
|
|
|
+ public double dtRange { get; set; } //时差范围
|
|
|
+ public double dfRange { get; set; } //频差范围
|
|
|
+ public double snrThreshold { get; set; } //信噪比门限
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 时隙样点信息
|
|
|
+ /// </summary>
|
|
|
+
|
|
|
+ public class XcorrSmp
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="smpStart"></param>
|
|
|
+ /// <param name="smpCount"></param>
|
|
|
+ public XcorrSmp(long smpStart, long smpCount)
|
|
|
+ {
|
|
|
+ this.smpStart = smpStart;
|
|
|
+ this.smpCount = smpCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ public long smpStart { get; set; }
|
|
|
+
|
|
|
+ public long smpCount { get; set; }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
public class XcorrUtils
|
|
|
{
|
|
|
Process cafp;
|
|
|
+ Process mucafp;
|
|
|
// D:/data/test/r1.dat D:/data/test/r4.dat 1562500 -250000 20 16384 100000 1048576 11
|
|
|
public async Task<CafResultDto> Calc(XcorrStruct xs)
|
|
|
{
|
|
@@ -65,9 +97,9 @@ namespace CpuCgServer
|
|
|
}
|
|
|
cafp.StartInfo.Arguments = $"{flag} \"{xs.file1}\" \"{xs.file2}\" {(Int64)(xs.samplingRate)} {xs.dtCenter} {xs.dtRange} {xs.dfRange} {xs.smpStart} {xs.smpCount} {xs.snrThreshold}";
|
|
|
}
|
|
|
- var exePath= Path.Combine(cafp.StartInfo.WorkingDirectory, "AddIns");
|
|
|
+ var exePath = Path.Combine(cafp.StartInfo.WorkingDirectory, "AddIns");
|
|
|
cafp.StartInfo.WorkingDirectory = exePath;
|
|
|
- cafp.StartInfo.FileName = Path.Combine(exePath,"XcorrCpu.exe");
|
|
|
+ cafp.StartInfo.FileName = Path.Combine(exePath, "XcorrCpu.exe");
|
|
|
cafp.StartInfo.CreateNoWindow = true;
|
|
|
cafp.StartInfo.RedirectStandardError = true;
|
|
|
cafp.StartInfo.RedirectStandardOutput = true;
|
|
@@ -89,5 +121,64 @@ namespace CpuCgServer
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ public async Task<List<CafResultDto>> MultiCalc(MultiXcorrStruct xs)
|
|
|
+ {
|
|
|
+ List<CafResultDto> res = new List<CafResultDto>();
|
|
|
+ mucafp = new Process();
|
|
|
+ await Task.Run(() =>
|
|
|
+ {
|
|
|
+ int flag = 4;
|
|
|
+
|
|
|
+ string smparg = $"{xs.xcorrSmps.Count}";
|
|
|
+ xs.xcorrSmps.ForEach(n => smparg += $" {n.smpStart} {n.smpCount}");
|
|
|
+ mucafp.StartInfo.Arguments = $"{flag} \"{xs.file1}\" \"{xs.file2}\" {(Int64)(xs.samplingRate)} {xs.dtCenter} {xs.dtRange} {xs.dfRange} {xs.snrThreshold} {smparg}";
|
|
|
+
|
|
|
+ var exePath = Path.Combine(mucafp.StartInfo.WorkingDirectory, "AddIns");
|
|
|
+ mucafp.StartInfo.WorkingDirectory = exePath;
|
|
|
+ mucafp.StartInfo.FileName = Path.Combine(exePath, "XcorrCpu.exe");
|
|
|
+ mucafp.StartInfo.CreateNoWindow = true;
|
|
|
+ mucafp.StartInfo.RedirectStandardError = true;
|
|
|
+ mucafp.StartInfo.RedirectStandardOutput = true;
|
|
|
+ mucafp.StartInfo.UseShellExecute = false;
|
|
|
+ mucafp.Start();
|
|
|
+ Stopwatch stopWatch = new Stopwatch();
|
|
|
+ stopWatch.Start();
|
|
|
+ mucafp.WaitForExit();
|
|
|
+ stopWatch.Stop();
|
|
|
+ TimeSpan ts = stopWatch.Elapsed;
|
|
|
+ var str = mucafp.StandardOutput.ReadToEnd();
|
|
|
+ var items = str.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
|
|
+ for (int i = 0; i < items.Length; i++)
|
|
|
+ {
|
|
|
+ var item = items[i];
|
|
|
+ var cafres = item.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
|
|
+ if (cafres.Length != 3)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ CafResultDto caf = new CafResultDto();
|
|
|
+ caf.file1 = xs.file1;
|
|
|
+ caf.file2 = xs.file2;
|
|
|
+ caf.tm = (int)stopWatch.Elapsed.TotalMilliseconds;
|
|
|
+ caf.smpstart = xs.xcorrSmps[i].smpStart;
|
|
|
+ caf.smplen = xs.xcorrSmps[i].smpCount;
|
|
|
+ double snr = Math.Round(double.Parse(cafres[2]), 1);
|
|
|
+ if (snr == 0)
|
|
|
+ {
|
|
|
+ caf.dt = 0;
|
|
|
+ caf.df = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ caf.dt = Math.Round(double.Parse(cafres[0]), 3);
|
|
|
+ caf.df = Math.Round(double.Parse(cafres[1]), 3);
|
|
|
+ caf.snr = snr;
|
|
|
+ }
|
|
|
+ res.Add(caf);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|