| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 | 
							- using System;
 
- 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;
 
- namespace XdCxRhDW.Core.Api
 
- {
 
-     public class XcorrStruct
 
-     {
 
-         public String file1 { get; set; }
 
-         public String file2 { get; set; }
 
-         public int smpStart { get; set; }           //开始样点
 
-         public int smpCount { 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; }	//信噪比门限
 
-         public XcorrStruct Copy()
 
-         {
 
-             XcorrStruct xItem = new XcorrStruct();
 
-             xItem.file1 = file1;
 
-             xItem.file2 = file2;
 
-             xItem.smpCount = smpCount;
 
-             xItem.samplingRate = samplingRate;
 
-             xItem.dtCenter = dtCenter;
 
-             xItem.dtRange = dtRange;
 
-             xItem.dfRange = dfRange;
 
-             xItem.smpStart = smpStart;
 
-             xItem.snrThreshold = snrThreshold;
 
-             return xItem;
 
-         }
 
-     }
 
-     public class XcorrUtils
 
-     {
 
-         Process cafp;
 
-         Process dmp;
 
-         // D:/data/test/r1.dat  D:/data/test/r4.dat 1562500 -250000 20 16384 100000 1048576 11
 
-         public async Task<CafResult> Calc(XcorrStruct xs)
 
-         {
 
-             CafResult res = new CafResult();
 
-             cafp = new Process();
 
-             await Task.Run(() =>
 
-             {
 
-                 cafp.StartInfo.FileName = Path.Combine(cafp.StartInfo.WorkingDirectory, "xcorr\\XcorrCpu.exe");
 
-                 cafp.StartInfo.Arguments = $"0 \"{xs.file1}\" \"{xs.file2}\" {(Int64)(xs.samplingRate)} {xs.dtCenter} {xs.dtRange} {xs.dfRange} {xs.smpStart} {xs.smpCount} {xs.snrThreshold}";
 
-                 cafp.StartInfo.CreateNoWindow = true;
 
-                 cafp.StartInfo.RedirectStandardError = true;
 
-                 cafp.StartInfo.RedirectStandardOutput = true;
 
-                 cafp.StartInfo.UseShellExecute = false;
 
-                 cafp.Start();
 
-                 Stopwatch stopWatch = new Stopwatch();
 
-                 stopWatch.Start();
 
-                 cafp.WaitForExit();
 
-                 stopWatch.Stop();
 
-                 TimeSpan ts = stopWatch.Elapsed;
 
-                 var str = cafp.StandardOutput.ReadToEnd();
 
-                 res.FromLine(str);
 
-                 res.file1 = xs.file1;
 
-                 res.file2 = xs.file2;
 
-                 res.tm = (int)stopWatch.Elapsed.TotalMilliseconds;
 
-                 res.smpstart = xs.smpStart;
 
-                 res.smplen = xs.smpCount;
 
-             });
 
-             return res;
 
-         }
 
-         /// <summary>
 
-         /// 参估画图
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public async Task<List<ImageResult>> DrawImage(XcorrStruct xs)
 
-         {
 
-             cafp = new Process();
 
-             List<ImageResult> list = new List<ImageResult>();
 
-             await Task.Run(() =>
 
-             {
 
-                 string outFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CgImag.txt");
 
-                 cafp.StartInfo.FileName = Path.Combine(cafp.StartInfo.WorkingDirectory, "xcorr\\XcorrCpu.exe");
 
-                 cafp.StartInfo.Arguments = $"1 \"{xs.file1}\" \"{xs.file2}\" {(Int64)(xs.samplingRate)} {xs.dtCenter} {xs.dtRange} {xs.dfRange} {xs.smpStart} {xs.smpCount} {xs.snrThreshold} {outFile}";
 
-                 cafp.StartInfo.CreateNoWindow = true;
 
-                 cafp.StartInfo.RedirectStandardError = true;
 
-                 cafp.StartInfo.RedirectStandardOutput = true;
 
-                 cafp.StartInfo.UseShellExecute = false;
 
-                 cafp.Start();
 
-                 Stopwatch stopWatch = new Stopwatch();
 
-                 stopWatch.Start();
 
-                 cafp.WaitForExit();
 
-                 stopWatch.Stop();
 
-                 TimeSpan ts = stopWatch.Elapsed;
 
-                 var str = cafp.StandardOutput.ReadToEnd();
 
-                 if (str.StartsWith("1:") && File.Exists(outFile))
 
-                 {
 
-                     var lines = File.ReadAllLines(outFile);
 
-                     if (lines.Length > 1)
 
-                     {
 
-                         var lineFirstArr = lines[0].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
 
-                         int fsHz = Convert.ToInt32(lineFirstArr[0]);
 
-                         int xFlag = Convert.ToInt32(lineFirstArr[1]);
 
-                         int xMax = Convert.ToInt32(lineFirstArr[2]);
 
-                         float yMax = Convert.ToSingle(lineFirstArr[3]);
 
-                         for (int i = 1; i < lines.Length; i++)
 
-                         {
 
-                             var lineArr = lines[i].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
 
-                             ImageResult ir = new ImageResult()
 
-                             {
 
-                                 FsHz = fsHz,
 
-                                 XFlag = xFlag,
 
-                                 XMax = xMax,
 
-                                 YMax = yMax,
 
-                                 XValue = Convert.ToInt32(lineArr[0]),
 
-                                 YValue = Convert.ToSingle(lineArr[1]),
 
-                                 Snr = Convert.ToSingle(lineArr[2]),
 
-                             };
 
-                             list.Add(ir);
 
-                         }
 
-                         ImageResult.MaxColorValue = list.Max(p => p.Snr);
 
-                     }
 
-                     File.Delete(outFile);
 
-                 }
 
-             });
 
-             return list;
 
-         }
 
-         public async Task<IEnumerable<DmcResult>> DmcCheckAsync(string fileName, double fsHz, DmcType dmcType)
 
-         {
 
-             string dmcCmd = "all";
 
-             dmp = new Process();
 
-             string pFileName = Path.Combine(dmp.StartInfo.WorkingDirectory, "xcorr\\dmc.exe");
 
-             string pArguments = string.Empty;
 
-             switch (dmcType)
 
-             {
 
-                 case DmcType.DAMA:
 
-                     dmcCmd = "dm";
 
-                     pArguments = $"{dmcCmd} \"{fileName}\"";// -f {fs}" -c --dmfirst";
 
-                     break;
 
-                 case DmcType.IBS:
 
-                     dmcCmd = "nd";
 
-                     pArguments = $"{dmcCmd} \"{fileName}\"";// -f {fs}" -c --dmfirst";
 
-                     break;
 
-                 case DmcType.Ky5758:
 
-                     pFileName = Path.Combine(dmp.StartInfo.WorkingDirectory, "xcorr\\enc.exe");
 
-                     //enc.exe enc-test.dat 0.096 5 0全部文件
 
-                     pArguments = $"{fileName} {fsHz * 1e-6} {5} {0}";
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-             return await Task.Run(() =>
 
-              {
 
-                  dmp.StartInfo.FileName = pFileName;
 
-                  dmp.StartInfo.Arguments = pArguments;
 
-                  dmp.StartInfo.CreateNoWindow = true;
 
-                  dmp.StartInfo.RedirectStandardError = true;
 
-                  dmp.StartInfo.RedirectStandardOutput = true;
 
-                  dmp.StartInfo.UseShellExecute = false;
 
-                  dmp.Start();
 
-                  Stopwatch stopWatch = new Stopwatch();
 
-                  stopWatch.Start();
 
-                  dmp.WaitForExit();
 
-                  stopWatch.Stop();
 
-                  TimeSpan ts = stopWatch.Elapsed;
 
-                  var str = dmp.StandardOutput.ReadToEnd();
 
-                  return ConvertDmcResult(dmcType,str, ts.TotalMilliseconds);
 
-              });
 
-         }
 
-         private IEnumerable<DmcResult> ConvertDmcResult(DmcType type,string res, double tm)
 
-         {
 
-             var lines = res.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries);
 
-             foreach (var line in lines)
 
-             {
 
-                 var items = line.Split('\t');
 
-                 if (items.Length < 2) continue;
 
-                 int start = int.Parse(items[0]);
 
-                 int length = int.Parse(items[1]);
 
-                 string userName = "";
 
-                 if (items.Length >= 3)
 
-                     userName = items[2];
 
-                 var item= new DmcResult(start, length, userName, (int)tm);
 
-                 if (type == DmcType.DAMA)
 
-                     item.SigType = "BPSK";
 
-                 else
 
-                     item.SigType = string.Empty;
 
-                 yield return item;
 
-             }
 
-         }
 
-         public void StopDm()
 
-         {
 
-             try
 
-             {
 
-                 if (dmp != null)
 
-                 {
 
-                     dmp.Kill();
 
-                 }
 
-             }
 
-             catch (Exception)
 
-             {
 
-             }
 
-         }
 
-         public void StopCalc()
 
-         {
 
-             try
 
-             {
 
-                 if (cafp != null)
 
-                 {
 
-                     cafp.Kill();
 
-                 }
 
-             }
 
-             catch (Exception)
 
-             {
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |