|
@@ -2,6 +2,7 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
|
+using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
@@ -86,6 +87,7 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
|
|
|
while (!cts.IsCancellationRequested && preTime <= dto.EndTime)
|
|
|
{
|
|
|
+ if (!dicCts.Values.Contains(cts)) return;
|
|
|
string filesDir = dto.CapDir;
|
|
|
try
|
|
|
{
|
|
@@ -175,7 +177,7 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
SigProc = true,
|
|
|
};
|
|
|
detectDto.dmcType = detectDto.dmcType & ~EnumSigCheckTypeDto.DAMA;//DAMA不支持上行信号检测,在这里移除掉
|
|
|
- if ((int)detectDto.dmcType ==0)
|
|
|
+ if ((int)detectDto.dmcType == 0)
|
|
|
{
|
|
|
LogHelper.Warning($"【任务{dto.ID}】信号{taskSig.FreqUp / 1e6:f3},上行信号不支持DAMA检测,请使用能量检测");
|
|
|
continue;
|
|
@@ -381,6 +383,7 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
while (!Directory.Exists(filesDir))
|
|
|
{
|
|
|
if (cts.IsCancellationRequested) return;
|
|
|
+ if (!dicCts.Values.Contains(cts)) return;
|
|
|
LogHelper.Info($"【任务{dto.ID}】目录[{filesDir}]不存在,等待5秒...");
|
|
|
await Task.Delay(5000, cts.Token);
|
|
|
if (DateTime.Now.Hour != preTime.Hour)
|
|
@@ -419,6 +422,7 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
IOrderedEnumerable<IGrouping<DateTime, HistoryFile>> groups = null;
|
|
|
groups = files.Select(f => FileToHistoryFile(dto, f, canConnected)).GroupBy(m => m.CapTime).OrderBy(m => m.Key);
|
|
|
bool hasFile = false;
|
|
|
+ var lastTime = groups.Last().Key;
|
|
|
foreach (var sameTimeFiles in groups)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested) return;
|
|
@@ -430,10 +434,13 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
LogHelper.Warning("处理速度过慢,丢弃数据");
|
|
|
continue;
|
|
|
}
|
|
|
- if (!await WaitFileEnd(dto.ID, sameTimeFiles.First(), capSeconds, cts))//采集完成,仍然不能某个文件,做下一个信号
|
|
|
+ if (capTime == lastTime)
|
|
|
{
|
|
|
- continue;
|
|
|
+ await WaitFileEnd(dto.ID, sameTimeFiles.First(), capSeconds, cts);
|
|
|
}
|
|
|
+ LogHelper.Info($"【任务{dto.ID}】[{capTime:yyyyMMddHHmmss}]时刻文件采集完成");
|
|
|
+ if (!CanOpenFile(dto.ID, sameTimeFiles.First()))
|
|
|
+ continue;//文件无法打开
|
|
|
hasFile = true;
|
|
|
var xdgbInfos = sameTimeFiles.GroupBy(m => m.XdIndex);
|
|
|
foreach (var xdInfos in xdgbInfos)
|
|
@@ -543,7 +550,7 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
continue;
|
|
|
}
|
|
|
LogHelper.Info($"【任务{dto.ID}】信号{taskSig.FreqUp / 1e6:f3},{capTime:yyyyMMddHHmmss}时刻邻星超短CPU参估完成");
|
|
|
- await HttpHelper.DeleteFileAsync(baseUrl,mainFile,adjaFile,cdbFile);
|
|
|
+ await HttpHelper.DeleteFileAsync(baseUrl, mainFile, adjaFile, cdbFile);
|
|
|
var data1 = result1.data;
|
|
|
var data2 = result2.data;
|
|
|
if (data1.Count != data2.Count || data1.Count != deteResp.data.Count)
|
|
@@ -636,38 +643,45 @@ namespace X2D1NoRefTaskServer.Service
|
|
|
}, cts.Token);
|
|
|
}
|
|
|
|
|
|
- private async Task<bool> WaitFileEnd(int taskID, HistoryFile file, int capSeconds, CancellationTokenSource cts)
|
|
|
+ //等待采集完成(根据文件字节大小判断是否完成,最多等待采集时长+5秒)
|
|
|
+ private async Task WaitFileEnd(int taskID, HistoryFile file, int capSeconds, CancellationTokenSource cts)
|
|
|
{
|
|
|
+ int idx = 0;
|
|
|
+ Stopwatch sw = new Stopwatch();
|
|
|
+ sw.Start();
|
|
|
while (true)
|
|
|
{
|
|
|
FileInfo s = new FileInfo(file.FilePath);
|
|
|
- var len = (int)(DateTime.Now - s.CreationTime).TotalSeconds;
|
|
|
- if (len < capSeconds + 2)
|
|
|
+ long fs = (long)file.FsHz;
|
|
|
+ var fileSize = fs * capSeconds * 4;
|
|
|
+ if (s.Length == fileSize)
|
|
|
{
|
|
|
- LogHelper.Info($"【任务{taskID}】等待[{file.CapTime:yyyyMMddHHmmss}]时刻文件采集完成...");
|
|
|
- var sleepTime = (capSeconds - len) / 2 * 1000;
|
|
|
- if (sleepTime < 2000)
|
|
|
- sleepTime = 2000;
|
|
|
- await Task.Delay(sleepTime, cts.Token);
|
|
|
- continue;
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
+ if (idx == 0)
|
|
|
+ LogHelper.Info($"【任务{taskID}】等待[{file.CapTime:yyyyMMddHHmmss}]时刻文件采集完成...");
|
|
|
+ await Task.Delay(2000, cts.Token);
|
|
|
+ if (sw.ElapsedMilliseconds / 1000 > capSeconds + 5)
|
|
|
+ break;
|
|
|
+ idx++;
|
|
|
}
|
|
|
+ sw.Stop();
|
|
|
+ }
|
|
|
|
|
|
+ private bool CanOpenFile(int taskID, HistoryFile file)
|
|
|
+ {
|
|
|
try
|
|
|
{
|
|
|
using (var fs = new FileStream(file.FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
|
|
{
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error($"【任务{taskID}】文件[{file.FilePath}]尝试打开失败", ex);
|
|
|
return false;
|
|
|
}
|
|
|
- LogHelper.Info($"【任务{taskID}】[{file.CapTime:yyyyMMddHHmmss}]时刻文件采集完成");
|
|
|
- return true;
|
|
|
-
|
|
|
}
|
|
|
private void ResetTime(int formatFlag, ref DateTime time)
|
|
|
{
|