瀏覽代碼

修改多样点参估

wyq 1 年之前
父節點
當前提交
19926cb681

二進制
Service/CpuCgServer/AddIns/XcorrCpu.exe


+ 98 - 7
Service/CpuCgServer/AddIns/XcorrUtils.cs

@@ -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;
+        }
+
     }
 }

+ 22 - 55
Service/CpuCgServer/Controllers/CpuCgController.cs

@@ -99,7 +99,7 @@ namespace CpuCgServer.Controllers
         {
             dto.file1 = GetLocalFile(dto.file1);
             dto.file2 = GetLocalFile(dto.file2);
-            XcorrStruct xItem = new XcorrStruct();
+            MultiXcorrStruct xItem = new MultiXcorrStruct();
             xItem.file1 = dto.file1;
             xItem.file2 = dto.file2;
             xItem.samplingRate = dto.samplingRate;
@@ -107,64 +107,31 @@ namespace CpuCgServer.Controllers
             xItem.dtRange = dto.dtRange;
             xItem.dfRange = dto.dfRange;
             xItem.snrThreshold = dto.snrThreshold;
-
+            xItem.xcorrSmps = dto.smpPositions.Select(m => new XcorrSmp(m.smpStart, m.smpCount)).ToList();
             List<CpuCgResDto> resDtos = new List<CpuCgResDto>();
-            foreach (var smpItem in dto.smpPositions)
+
+            XcorrUtils xcorr = new XcorrUtils();
+            try
             {
-                XcorrUtils xcorr = new XcorrUtils();
-                xItem.smpStart = smpItem.smpStart;
-                xItem.smpCount = smpItem.smpCount;
-                CpuCgResDto resDto = new CpuCgResDto();
-                resDto.Smpstart = xItem.smpStart;
-                resDto.Smplen = (long)xItem.smpCount;
-                try
+                var result = await xcorr.MultiCalc(xItem);
+                foreach (var item in result)
                 {
-                    var result = await xcorr.Calc(xItem);
-                    //开始计算
-                    if (result.flag == -2)
-                    {
-                        resDto.Dt = 0;
-                        resDto.Df = 0;
-                        resDto.Snr = 0;
-                        resDtos.Add(resDto);
-                        Serilog.Log.Error("参估计算内部错误!");
-                    }
-                    else if (result.flag == -1)
-                    {
-                        resDto.Dt = 0;
-                        resDto.Df = 0;
-                        resDto.Snr = 0;
-                        resDtos.Add(resDto);
-                        Serilog.Log.Error("参估计算所需数据超出文件范围!");
-                    }
-                    else
-                    {
-                        resDto.TimeMs = result.tm;
-                        if (result.flag == 1)
-                        {
-                            resDto.Dt = result.dt.Value;
-                            resDto.Df = result.df.Value;
-                            resDto.Snr = result.snr.Value;
-                            resDtos.Add(resDto);
-                        }
-                        else
-                        {
-                            resDto.Dt = 0;
-                            resDto.Df = 0;
-                            resDto.Snr = 0;
-                            resDtos.Add(resDto);
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    resDto.Dt = 0;
-                    resDto.Df = 0;
-                    resDto.Snr = 0;
+                    CpuCgResDto resDto = new CpuCgResDto();
+                    resDto.Smpstart = item.smpstart;
+                    resDto.Smplen = item.smplen;
+                    resDto.TimeMs = item.tm;
+                    resDto.Dt = item.dt.Value;
+                    resDto.Df = item.df.Value;
+                    resDto.Snr = item.snr.Value;
                     resDtos.Add(resDto);
-                    Serilog.Log.Error(ex, "执行CPU参估异常");
                 }
+
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, "执行CPU参估异常");
             }
+
             return Success(resDtos);
 
         }
@@ -178,8 +145,8 @@ namespace CpuCgServer.Controllers
         {
             var cafp = new Process();
             List<ImageResultDto> list = new List<ImageResultDto>();
-            dto.file1=GetLocalFile(dto.file1);
-            dto.file2=GetLocalFile(dto.file2);
+            dto.file1 = GetLocalFile(dto.file1);
+            dto.file2 = GetLocalFile(dto.file2);
             await Task.Run(() =>
             {
                 FileInfo file1 = new FileInfo(dto.file1);

+ 0 - 1
Service/CpuCgServer/CpuCgServer.csproj

@@ -131,7 +131,6 @@
       <DependentUpon>MainForm.cs</DependentUpon>
     </Compile>
     <None Include="packages.config" />
-    <None Include="Properties\licenses.licx" />
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>

二進制
XdCxRhDW.App/Service/CPU参估服务/AddIns/CPU参估服务.exe


二進制
XdCxRhDW.App/Service/CPU参估服务/AddIns/XcorrCpu.exe


二進制
XdCxRhDW.App/Service/CPU参估服务/CPU参估服务.exe