|
@@ -2,10 +2,12 @@
|
|
|
using MySql.Data.MySqlClient;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Globalization;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Security.Policy;
|
|
|
using System.Text;
|
|
|
+using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using XdCxRhDw;
|
|
|
using XdCxRhDW.Dto;
|
|
@@ -29,13 +31,14 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
string capfile = Path.Combine(dto.CapDir, $"{preTime.ToString(dto.DateDirFormat)}");
|
|
|
|
|
|
var files = Directory.EnumerateFiles(capfile, "*.dat");
|
|
|
- /* ch1 = 超短波信号
|
|
|
- ch2 = 主星
|
|
|
- ch3 = 邻1
|
|
|
- ch4 = 采集卡4通道采集没接信号的那一路,不用管这路文件*/
|
|
|
+
|
|
|
var groups = files.Select(f => FileToHistoryFile(f)).GroupBy(m => m.CapTime).OrderBy(m => m.Key);
|
|
|
foreach (var item in groups)
|
|
|
{
|
|
|
+ if (!IsRuning)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
var finfos = item.ToList();
|
|
|
if (finfos.Count < 3)
|
|
|
{
|
|
@@ -43,35 +46,53 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
continue;
|
|
|
}
|
|
|
//超短波信号
|
|
|
- var dinfo = finfos.First(m => m.Ch == 1);
|
|
|
+ var dinfo = finfos.FirstOrDefault(m => m.Ch == 1);
|
|
|
+ if (dinfo == null)
|
|
|
+ {
|
|
|
+ LogHelper.Info($"历史任务:{dto.ID}采集时刻:{finfos.First().CapTime:yyyy-MM-dd HH:mm:ss}未找到超短波信号ch1文件,不满足");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//主星
|
|
|
- var minfo = finfos.First(m => m.Ch == 2);
|
|
|
+ var minfo = finfos.FirstOrDefault(m => m.Ch == 2);
|
|
|
+ if (minfo == null)
|
|
|
+ {
|
|
|
+ LogHelper.Info($"历史任务:{dto.ID}采集时刻:{finfos.First().CapTime:yyyy-MM-dd HH:mm:ss}未找到主星信号ch2文件,不满足");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//邻1
|
|
|
- var ninfo = finfos.First(m => m.Ch == 3);
|
|
|
+ var ninfo = finfos.FirstOrDefault(m => m.Ch == 3);
|
|
|
+ if (ninfo == null)
|
|
|
+ {
|
|
|
+ LogHelper.Info($"历史任务:{dto.ID}采集时刻:{finfos.First().CapTime:yyyy-MM-dd HH:mm:ss}未找到邻星信号ch3文件,不满足");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
try
|
|
|
{
|
|
|
+ var txInfos = await GetTxInfoAsync();
|
|
|
+ var satTx = txInfos.First(t => t.TxType == EnumTxType.Rec);
|
|
|
+ var cdbTx = txInfos.First(t => t.TxType == EnumTxType.Cdb);
|
|
|
+ var refTx = txInfos.First(t => t.TxType == EnumTxType.Ref);
|
|
|
//根据信号类型执行检测或参数估计
|
|
|
if (dto.SigType == EnumSigTypeDto.Normal)
|
|
|
{
|
|
|
- var xd = await GPUCalcAsync(minfo.FilePath, dinfo.FilePath, minfo.FsHz);
|
|
|
- var sx = await GPUCalcAsync(minfo.FilePath, ninfo.FilePath, minfo.FsHz);
|
|
|
+
|
|
|
+ var xd = await GPUCalcAsync(minfo.FilePath, dinfo.FilePath, minfo.FsHz, 260000, 40000);
|
|
|
+ var sx = await GPUCalcAsync(minfo.FilePath, ninfo.FilePath, minfo.FsHz, 0, 40000);
|
|
|
X2D1NoXlPosDto x2D1 = new X2D1NoXlPosDto()
|
|
|
{
|
|
|
SigTime = minfo.CapTime,
|
|
|
MainCode = minfo.SatId,
|
|
|
AdjaCode = ninfo.SatId,
|
|
|
- SxDto = sx.Dt * 1e6,
|
|
|
- XdDto = xd.Dt * 1e6,
|
|
|
- /* MainYbDto = Convert.ToDouble(items[2]) * 1e6,
|
|
|
- /AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
|
|
|
- SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
|
|
|
- SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
|
|
|
- CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
|
|
|
- CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
|
|
|
- RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
|
|
|
- RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
|
|
|
- FreqDown = 295.425e6,//For Api Test
|
|
|
- FreqUp = 260.425e6,//For Api Test*/
|
|
|
+ SxDto = sx.Dt,
|
|
|
+ XdDto = xd.Dt,
|
|
|
+ SatTxLon = satTx.Lon,
|
|
|
+ SatTxLat = satTx.Lat,
|
|
|
+ CdbTxLon = cdbTx.Lon,
|
|
|
+ CdbTxLat = cdbTx.Lat,
|
|
|
+ RefLon = refTx.Lon,
|
|
|
+ RefLat = refTx.Lat,
|
|
|
+ FreqDown = minfo.FreqHz * 1e-6,
|
|
|
+ FreqUp = dinfo.FreqHz * 1e-6,
|
|
|
XdDfo = xd.Df,
|
|
|
XdSnr = xd.Snr,
|
|
|
SxDfo = sx.Df,
|
|
@@ -87,32 +108,44 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
var nfile = await ToResampleAsync((int)ninfo.FsHz, ninfo.FilePath);
|
|
|
foreach (var deitem in mDetect)
|
|
|
{
|
|
|
- var xd = await CPUCalcAsync(deitem.File1, dfile.File, dfile.OutFsHz, deitem);
|
|
|
- var sx = await CPUCalcAsync(deitem.File1, nfile.File, nfile.OutFsHz, deitem);
|
|
|
- X2D1NoXlPosDto x2D1 = new X2D1NoXlPosDto()
|
|
|
+ if (!IsRuning)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ try
|
|
|
{
|
|
|
- SigTime = minfo.CapTime.AddSeconds(deitem.Start / nfile.OutFsHz),
|
|
|
- MainCode = minfo.SatId,
|
|
|
- AdjaCode = ninfo.SatId,
|
|
|
- SxDto = sx.Dt * 1e6,
|
|
|
- XdDto = xd.Dt * 1e6,
|
|
|
- /* MainYbDto = Convert.ToDouble(items[2]) * 1e6,
|
|
|
- /AdjaYbDto = Convert.ToDouble(items[3]) * 1e6,
|
|
|
- SatTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lon"),
|
|
|
- SatTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "卫星接收天线", "Lat"),
|
|
|
- CdbTxLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lon"),
|
|
|
- CdbTxLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "超短波接收天线", "Lat"),
|
|
|
- RefLon = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lon"),
|
|
|
- RefLat = IniFiles.ReadValue<double>("Station_Data2023.ini", "参考站", "Lat"),
|
|
|
- FreqDown = 295.425e6,//For Api Test
|
|
|
- FreqUp = 260.425e6,//For Api Test*/
|
|
|
- XdDfo = xd.Df,
|
|
|
- XdSnr = xd.Snr,
|
|
|
- SxDfo = sx.Df,
|
|
|
- SxSnr = sx.Snr,
|
|
|
- };
|
|
|
-
|
|
|
- await X2D1NoXlAsync(x2D1);
|
|
|
+ var xd = await CPUCalcAsync(deitem.File1, dfile.File, dfile.OutFsHz, deitem, 260000, 40000);
|
|
|
+ Thread.Sleep(100);
|
|
|
+ var sx = await CPUCalcAsync(deitem.File1, nfile.File, nfile.OutFsHz, deitem, 0, 40000);
|
|
|
+ X2D1NoXlPosDto x2D1 = new X2D1NoXlPosDto()
|
|
|
+ {
|
|
|
+ SigTime = minfo.CapTime.AddSeconds(deitem.Start / nfile.OutFsHz),
|
|
|
+ MainCode = minfo.SatId,
|
|
|
+ AdjaCode = ninfo.SatId,
|
|
|
+ SxDto = sx.Dt,
|
|
|
+ XdDto = xd.Dt,
|
|
|
+ SatTxLon = satTx.Lon,
|
|
|
+ SatTxLat = satTx.Lat,
|
|
|
+ CdbTxLon = cdbTx.Lon,
|
|
|
+ CdbTxLat = cdbTx.Lat,
|
|
|
+ RefLon = refTx.Lon,
|
|
|
+ RefLat = refTx.Lat,
|
|
|
+ FreqDown = minfo.FreqHz * 1e-6,
|
|
|
+ FreqUp = dinfo.FreqHz * 1e-6,
|
|
|
+ XdDfo = xd.Df,
|
|
|
+ XdSnr = xd.Snr,
|
|
|
+ SxDfo = sx.Df,
|
|
|
+ SxSnr = sx.Snr,
|
|
|
+ };
|
|
|
+
|
|
|
+ await X2D1NoXlAsync(x2D1);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.Info($"历史任务:{dto.ID}异常:{ex.Message}");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -123,15 +156,13 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
preTime = preTime.AddHours(1);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private async Task<bool> X2D1NoXlAsync(X2D1NoXlPosDto x2D1)
|
|
|
{
|
|
|
var result = await HttpHelper.PostRequestAsync<PosResDto>(baseUrl + "Pos/PosX2D1NoXlAsync", x2D1);
|
|
@@ -142,6 +173,26 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private async Task<List<TxInfo>> GetTxInfoAsync()
|
|
|
+ {
|
|
|
+ List<TxInfo> infos = new List<TxInfo>();
|
|
|
+ var result = await HttpHelper.GetRequestAsync<(TxInfo recTx, TxInfo cdbTx, TxInfo cxTx, TxInfo refLoc)>(baseUrl + "Tx/GetTxInfoAsync");
|
|
|
+ if (result.code != 200)
|
|
|
+ {
|
|
|
+ infos.Add(new TxInfo() { TxType = EnumTxType.Rec });
|
|
|
+ infos.Add(new TxInfo() { TxType = EnumTxType.Cdb });
|
|
|
+ infos.Add(new TxInfo() { TxType = EnumTxType.Cx });
|
|
|
+ infos.Add(new TxInfo() { TxType = EnumTxType.Ref });
|
|
|
+ LogHelper.Error($"历史任务获取天线信息失败");
|
|
|
+ return infos;
|
|
|
+ }
|
|
|
+ infos.Add(result.data.recTx);
|
|
|
+ infos.Add(result.data.cdbTx);
|
|
|
+ infos.Add(result.data.cxTx);
|
|
|
+ infos.Add(result.data.refLoc);
|
|
|
+ return infos;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取采集文件信息
|
|
|
/// </summary>
|
|
@@ -157,7 +208,11 @@ namespace XdCxRhDW.TaskServer.Task
|
|
|
|
|
|
//采集时间
|
|
|
var datestr = string.Join("_", strs.Take(6));
|
|
|
- historyFile.CapTime = DateTime.ParseExact(datestr, "yyyy_MM_dd_HH_mm_ss", null);
|
|
|
+ DateTime dateTime;
|
|
|
+ bool istime = DateTime.TryParseExact(datestr, "yyyy_MM_dd_HH_mm_ss", null, DateTimeStyles.None, out dateTime);
|
|
|
+ if (!istime) return historyFile;
|
|
|
+ historyFile.CapTime = dateTime;
|
|
|
+
|
|
|
|
|
|
//采集通道
|
|
|
var chstr = strs.Skip(strs.Length - 2).Take(1).First();
|