Przeglądaj źródła

修改提取时隙数据

wyq 1 rok temu
rodzic
commit
3fb57d1323

BIN
XdCxRhDW.Api/AddIns/检测Cpu参估/XcorrCpu.exe


+ 23 - 0
XdCxRhDW.TaskServer/Task/ExtractRes.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XdCxRhDW.Dto;
+
+namespace XdCxRhDW.TaskServer.Task
+{
+    public class ExtractRes
+    {
+        /// <summary>
+        /// 提取检测文件
+        /// </summary>
+        public string file { get; set; }
+        
+
+        /// <summary>
+        /// 提取时隙位置
+        /// </summary>
+        public List<SmpPosition>  positions { get; set; }
+    }
+}

+ 26 - 11
XdCxRhDW.TaskServer/Task/HistoryTaskI.cs

@@ -239,8 +239,9 @@ namespace XdCxRhDW.TaskServer.Task
         /// <param name="dtRange"></param>
         /// <param name="Ch"></param>
         /// <returns></returns>
-        public async Task<string> ExtractMergeAsync(string file, double fsHz, List<SmpPosition> smps, double dtCenter, double dtRange, int Ch)
+        public async Task<ExtractRes> ExtractMergeAsync(string file, double fsHz, List<SmpPosition> smps, double dtCenter, double dtRange, int Ch)
         {
+            long offset = 0;
             long zero = 0;
             if (Ch == 2)//主星
             {
@@ -252,7 +253,8 @@ namespace XdCxRhDW.TaskServer.Task
             }
             else//地信号文件
             {
-                zero = Convert.ToInt64(0.26 * fsHz) / 2;
+                zero = Convert.ToInt64(dtRange * 1e-6 * fsHz) / 2;
+                offset = Convert.ToInt64(0.26 * fsHz);
             }
 
             string detectFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MultiDetect");
@@ -261,6 +263,10 @@ namespace XdCxRhDW.TaskServer.Task
             string outfile = Path.Combine(detectFolder, Path.GetFileNameWithoutExtension(file) + "_de" + Path.GetExtension(file));
 
 
+            ExtractRes res = new ExtractRes();
+            res.file = outfile;
+
+            List<SmpPosition> smpp = new List<SmpPosition>();
             // 从指定位置开始读取数据
             using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
             {
@@ -268,24 +274,33 @@ namespace XdCxRhDW.TaskServer.Task
 
                 foreach (var smp in smps)
                 {
-                    long offset = smp.smpStart * 4 - zero * 4;
+                  
+                        long start = (smp.smpStart - zero - offset) * 4;
+                        int length = Convert.ToInt32(smp.smpCount + zero * 2 - offset) * 4;
 
-                    fileStream.Seek(offset, SeekOrigin.Begin); // 移动到文件的指定位置
+                        if (start < 0 || length < 0 || length > fileStream.Length)
+                        {
+                            continue;
+                        }
+                        // 移动到文件的指定位置
+                        fileStream.Seek(start, SeekOrigin.Begin);
 
-                    int length = Convert.ToInt32((long)smp.smpCount * 4 + zero * 4);
-                    byte[] buffer = new byte[length];
-                    int bytesRead = await fileStream.ReadAsync(buffer, 0, buffer.Length); // 读取指定长度的数据
+                        byte[] buffer = new byte[length];
+                        // 读取指定长度的数据
+                        int bytesRead = await fileStream.ReadAsync(buffer, 0, buffer.Length);
 
-                    Array.ConstrainedCopy(buffer, 0, bytes, (int)offset, bytesRead);
-                  
+                        Array.ConstrainedCopy(buffer, 0, bytes, (int)start, bytesRead);
+                        smpp.Add(smp);
+                   
                 }
                 using (FileStream wrStream = new FileStream(outfile, FileMode.Create, FileAccess.ReadWrite))
                 {
                     await wrStream.WriteAsync(bytes, 0, bytes.Length);
                 }
-                return outfile;
-            }
 
+            }
+            res.positions = smpp;
+            return res;
 
         }
     }

+ 5 - 5
XdCxRhDW.TaskServer/Task/X2D1Task.cs

@@ -124,15 +124,15 @@ namespace XdCxRhDW.TaskServer.Task
 
                                 //提取时隙有效数据
                                 //var mdfile = await ExtractMergeAsync(mfile, nfile.OutFsHz, smps, 0, dtRange, minfo.Ch);
-                                //var ddfile = await ExtractMergeAsync(dfile.File, nfile.OutFsHz, smps, 260000, dtRange, dinfo.Ch);
+                                //var ddfile = await ExtractMergeAsync(dfile.File, nfile.OutFsHz, smps, -260000, dtRange, dinfo.Ch);
                                 //var ndfile = await ExtractMergeAsync(nfile.File, nfile.OutFsHz, smps, 0, dtRange, ninfo.Ch);
 
-                                //var xds = await CPUCalcAsync(mdfile, ddfile, dfile.OutFsHz, smps, 260000, dtRange);
-                                //var sxs = await CPUCalcAsync(mdfile, ndfile, nfile.OutFsHz, smps, 0, dtRange);
+                                //var xds = await CPUCalcAsync(mdfile.file, ddfile.file, dfile.OutFsHz, ddfile.positions, -260000, dtRange);
+                                //var sxs = await CPUCalcAsync(mdfile.file, ndfile.file, nfile.OutFsHz, ndfile.positions, 0, dtRange);
 
 
 
-                                var xds = await CPUCalcAsync(mfile, dfile.File, dfile.OutFsHz, smps, 260000, dtRange);
+                                var xds = await CPUCalcAsync(mfile, dfile.File, dfile.OutFsHz, smps, -260000, dtRange);
                                 var sxs = await CPUCalcAsync(mfile, nfile.File, nfile.OutFsHz, smps, 0, dtRange);
 
                                 foreach (var sxitem in sxs)
@@ -273,7 +273,7 @@ namespace XdCxRhDW.TaskServer.Task
             historyFile.FsHz = fsHz;
             if (ch > 1)
             {
-                historyFile.SatId = GetSatId(historyFile.FreqHz);
+                historyFile.SatId = 44637;// GetSatId(historyFile.FreqHz);
 
             }
             return historyFile;

+ 1 - 0
XdCxRhDW.TaskServer/XdCxRhDW.TaskServer.csproj

@@ -159,6 +159,7 @@
       <DependentUpon>MainForm.cs</DependentUpon>
     </Compile>
     <Compile Include="Service\HistoryTaskService.cs" />
+    <Compile Include="Task\ExtractRes.cs" />
     <Compile Include="Task\HistoryFile.cs" />
     <Compile Include="Task\HistoryTaskI.cs" />
     <Compile Include="Task\TxInfo.cs" />

+ 3 - 3
XdCxRhDw.Dto/CpuCgMultiDto.cs

@@ -78,10 +78,10 @@ namespace XdCxRhDW.Dto
         public long smpStart { get; set; }
 
         /// <summary>
-        /// 样点数(0表示文件末尾,0-1之间的小数表示样点百分比)
+        /// 样点数
         /// </summary>
-        [RangeDouble(0, IncludeMin = true)]
-        public double smpCount { get; set; }
+        [RangeLong(0, IncludeMin = true)]
+        public long smpCount { get; set; }
 
 
     }