|
@@ -0,0 +1,161 @@
|
|
|
+using DevExpress.Utils.About;
|
|
|
+using System;
|
|
|
+using System.Collections.Concurrent;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data.Entity;
|
|
|
+using System.Linq;
|
|
|
+using System.Security.Policy;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Documents;
|
|
|
+using XdCxRhDW.Dto;
|
|
|
+using XdCxRhDW.Entity;
|
|
|
+using XdCxRhDW.Repostory;
|
|
|
+
|
|
|
+namespace XdCxRhDW.App
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 两星一地定位取参考
|
|
|
+ /// </summary>
|
|
|
+ public class X2D1PosHandle
|
|
|
+ {
|
|
|
+
|
|
|
+ public int TaskId;
|
|
|
+ //十分钟时间内的数据
|
|
|
+ private int TimeSeconds = 10 * 60;//十分钟
|
|
|
+ private bool isRuning = true;
|
|
|
+
|
|
|
+ BlockingCollection<X2D1NoXlNoParlPosDto> posDtos = new BlockingCollection<X2D1NoXlNoParlPosDto>();
|
|
|
+ public X2D1PosHandle(int taskId)
|
|
|
+ {
|
|
|
+ TaskId = taskId;
|
|
|
+ StartMonitor();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StartMonitor()
|
|
|
+ {
|
|
|
+ Task.Run(async () =>
|
|
|
+ {
|
|
|
+
|
|
|
+ while (isRuning)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var dto = posDtos.Take();
|
|
|
+
|
|
|
+ FixedStation fixedStation;
|
|
|
+ using (RHDWContext db = new RHDWContext())
|
|
|
+ {
|
|
|
+ fixedStation = await db.FixedStation.FirstAsync(f => f.ID == dto.FixedStationId.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTime min = dto.SigTime.AddSeconds(-TimeSeconds);
|
|
|
+ DateTime max = dto.SigTime.AddSeconds(TimeSeconds);
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
|
|
|
+ {
|
|
|
+ //获取十分钟之内的固定站数据
|
|
|
+ var cgRess = await db.CgRes.Where(m => m.FixedStationResID == dto.FixedStationId && dto.SigTime >= min && dto.SigTime <= max).OrderBy(d => d.SigTime).ToListAsync();
|
|
|
+
|
|
|
+ List<CgRes> matchCgList = new List<CgRes>();
|
|
|
+ cgRess.ForEach(c =>
|
|
|
+ {
|
|
|
+ if ((dto.SigTime - c.SigTime).TotalSeconds <= TimeSeconds)
|
|
|
+ {
|
|
|
+ matchCgList.Add(c);
|
|
|
+ }
|
|
|
+ });
|
|
|
+#warning 获取最近时间的时差值,若没找到参考信号就做无参 是否要等待?
|
|
|
+ var point1 = matchCgList.Where(c => c.SigTime <= dto.SigTime).FirstOrDefault();
|
|
|
+ var point2 = matchCgList.Where(c => c.SigTime >= dto.SigTime).FirstOrDefault();
|
|
|
+ bool isSucces = false;
|
|
|
+ if (point1 != null && point2 != null)
|
|
|
+ {
|
|
|
+ //通过双星时差及超短波时差怎么计算参考信息的时差
|
|
|
+ double refDto = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.Dto1.Value, point2.Dto1.Value);
|
|
|
+ double refDtoCdb = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.DtoCdb.Value, point2.DtoCdb.Value);
|
|
|
+
|
|
|
+ //执行两星一地有参定位
|
|
|
+ X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
|
|
|
+ {
|
|
|
+ SigTime = dto.SigTime,
|
|
|
+ MainCode = dto.MainCode,
|
|
|
+ AdjaCode = dto.AdjaCode,
|
|
|
+ SxDto = dto.SxDto,
|
|
|
+ XdDto = dto.XdDto,
|
|
|
+ MainYbDto = refDto,
|
|
|
+ AdjaYbDto = refDtoCdb,
|
|
|
+ SatTxLon = dto.SatTxLon,
|
|
|
+ SatTxLat = dto.SatTxLat,
|
|
|
+ CdbTxLon = dto.CdbTxLon,
|
|
|
+ CdbTxLat = dto.CdbTxLat,
|
|
|
+ RefLon = fixedStation.Lon,
|
|
|
+ RefLat = fixedStation.Lat,
|
|
|
+ FreqDown = dto.FreqDown,
|
|
|
+ FreqUp = dto.FreqUp,
|
|
|
+ XdDfo = dto.XdDfo,
|
|
|
+ XdSnr = dto.XdSnr,
|
|
|
+ SxDfo = dto.SxDfo,
|
|
|
+ SxSnr = dto.SxSnr,
|
|
|
+ CalcConfidence = true,
|
|
|
+ TheoryDfoCalc = true,
|
|
|
+ };
|
|
|
+ var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlAsync"), X2D1NoXlPosDto);
|
|
|
+ if (result.code != 200)
|
|
|
+ {
|
|
|
+ isSucces = false;
|
|
|
+ Serilog.Log.Error($"{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地有参定位失败{result.msg}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ isSucces = true;
|
|
|
+ Serilog.Log.Error($"{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地有参定位完成{result.msg}");
|
|
|
+ }
|
|
|
+ if (isSucces && result.data.PosLon == 999)
|
|
|
+ {
|
|
|
+ isSucces = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!isSucces)
|
|
|
+ {
|
|
|
+ dto.BeFindRef = false;
|
|
|
+ dto.FixedStationId = null;
|
|
|
+ var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlNoParAsync"), dto);
|
|
|
+ if (result.code != 200)
|
|
|
+ {
|
|
|
+ Serilog.Log.Error($"{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位失败{result.msg}");
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Serilog.Log.Error($"{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位完成{result.msg}");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Serilog.Log.Error(ex, $"【取参考信号流程异常{ex.Message}");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public void Append(X2D1NoXlNoParlPosDto dto)
|
|
|
+ {
|
|
|
+ bool ret = posDtos.TryAdd(dto);
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ Serilog.Log.Error($"【任务{dto.TaskID}】添加取参考Dto");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Stop()
|
|
|
+ {
|
|
|
+ //当前任务停止处理
|
|
|
+ isRuning = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|