Selaa lähdekoodia

修改两星一地有参流程

wyq 1 vuosi sitten
vanhempi
commit
cc6f71d1b8

+ 18 - 11
Service/X2D1TaskServer/Controllers/X2D1TaskProcessingController.cs

@@ -1,14 +1,10 @@
 using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.IO;
-using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
 using System.Web.Http;
+using X2D1TaskServer.Service;
 using XdCxRhDW.Dto;
 using XdCxRhDW.WebApi;
-using X2D1TaskServer.Service;
-using System.Threading;
-using System.Threading.Tasks;
 
 namespace X2D1TaskServer.Controllers
 {
@@ -41,14 +37,25 @@ namespace X2D1TaskServer.Controllers
         {
             try
             {
-                if (_service.Stop(dto.ID))
-                {
-                    Thread.Sleep(2000);
-                }
+
                 if (dto.TaskType == EnumTaskTypeDto.History)
+                {
+                    if (_tskHservice.Stop(dto.ID))
+                    {
+                        Thread.Sleep(2000);
+                    }
                     _tskHservice.StartAsync(dto);
+                }
+
                 else
+                {
+                    if (_tskRservice.Stop(dto.ID))
+                    {
+                        Thread.Sleep(2000);
+                    }
                     _tskRservice.StartAsync(dto);
+                }
+
                 return Success();
             }
             catch (Exception ex)

+ 1 - 1
Service/X2D1TaskServer/Service/BaseTaskI.cs

@@ -10,7 +10,7 @@ namespace X2D1TaskServer
     public interface BaseTaskI
     {
         void StartAsync(X2D1TaskHandleDto dto);
-        void Stop(int taskID);
+        bool Stop(int taskID);
         Task StopTask(int taskID, EnumTaskStopType type, string stopReason);
     }
 }

+ 4 - 4
Service/X2D1TaskServer/Service/TaskHistoryService.cs

@@ -134,7 +134,7 @@ namespace X2D1TaskServer.Service
                             if (cts.IsCancellationRequested) break;
                             var xdgbInfos = sameTimeFiles.GroupBy(m => m.XdIndex);
 
-                            var splitXdgbInfos = SplitFreqFiles( xdgbInfos);
+                            var splitXdgbInfos = SplitFreqFiles(xdgbInfos);
                             List<Task> listTask = new List<Task>();
                             foreach (var item in splitXdgbInfos)//splitXdgbInfos中的数据并行处理
                             {
@@ -164,11 +164,11 @@ namespace X2D1TaskServer.Service
         }
 
 
-        public void Stop(int taskID)
+        public bool Stop(int taskID)
         {
-            if (!dicCts.ContainsKey(taskID)) return;
+            if (!dicCts.ContainsKey(taskID)) return false;
             dicCts[taskID]?.Cancel();
-            dicCts.Remove(taskID);
+            return dicCts.Remove(taskID);
         }
         public async Task StopTask(int taskID, EnumTaskStopType type, string stopReason)
         {

+ 3 - 3
Service/X2D1TaskServer/Service/TaskRealService.cs

@@ -223,11 +223,11 @@ namespace X2D1TaskServer.Service
             }, cts.Token);
         }
 
-        public void Stop(int taskID)
+        public bool Stop(int taskID)
         {
-            if (!dicCts.ContainsKey(taskID)) return;
+            if (!dicCts.ContainsKey(taskID)) return false;
             dicCts[taskID]?.Cancel();
-            dicCts.Remove(taskID);
+            return dicCts.Remove(taskID);
         }
         public async Task StopTask(int taskID, EnumTaskStopType type, string stopReason)
         {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 18 - 1012
Service/X2D1TaskServer/Service/TaskService.cs


+ 7 - 0
XdCxRhDW.App/Controllers/PosController.cs

@@ -737,6 +737,12 @@ namespace XdCxRhDW.App.Controllers
                     Serilog.Log.Error($"推算卫星{dto.AdjaCode}的ECEF星历出错.{ephAdja.msg}");
                     return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
                 }
+                if (dto.BeFindRef)
+                {
+                    X2D1PosRefService.Instance.AddPosDto(dto);
+                    PosRes posRes = new PosRes();
+                    return Success(MapDto(posRes));
+                }
                 using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
                 {
                     var StationRes = db.StationRes.Add(new StationRes()
@@ -771,6 +777,7 @@ namespace XdCxRhDW.App.Controllers
                         DfoCdb = Math.Round(dto.XdDfo, 10),
                         SnrCdb = Math.Round(dto.XdSnr, 1),
                         StationResID = StationRes.ID,
+                        FixedStationID=dto.FixedStationId,
                         MainCode = dto.MainCode,
                         Adja1Code = dto.AdjaCode,
                         MainXlTime = ephMain.data.TleTime,

+ 6 - 0
XdCxRhDW.App/EditForms/TaskEditorSignal.cs

@@ -98,6 +98,12 @@ namespace XdCxRhDW.App.EditForms
                 var res = gridViewTaskSignal.GetRow(selectedRows[i]) as SigInfo;
                 listSigInfoSelected.Add(res);
             }
+            int count = listSigInfoSelected.Count(s => s.IsFixedStationFreq.Trim() == "✔".Trim());
+            if (count >= 2)
+            {
+                DxHelper.MsgBoxHelper.ShowError("只支持一个固定站频点");
+                return;
+            }
             this.DialogResult = DialogResult.OK;
         }
 

+ 1 - 0
XdCxRhDW.App/UserControl/CtrlFixedStation.Designer.cs

@@ -49,6 +49,7 @@
             // 
             this.gridView1.GridControl = this.gridFixedStation;
             this.gridView1.Name = "gridView1";
+            this.gridView1.DoubleClick += new System.EventHandler(this.gridView1_DoubleClick);
             // 
             // CtrlFixedStation
             // 

+ 28 - 0
XdCxRhDW.App/UserControl/CtrlFixedStation.cs

@@ -111,5 +111,33 @@ namespace XdCxRhDW.App.UserControl
             }
         }
 
+        private async void gridView1_DoubleClick(object sender, EventArgs e)
+        {
+            var editItem = gridView1.GetFocusedRow() as FixedStation;
+            if (editItem == null) return;
+            try
+            {
+                FixedStationEditor frm = new FixedStationEditor(editItem);
+                if (frm.ShowDialog() != DialogResult.OK) return ;
+                editItem = frm.info;
+                using (RHDWContext db = new RHDWContext())
+                {
+                    var find = await db.FixedStation.Where(p => p.ID == editItem.ID).FirstOrDefaultAsync();
+                    find.StationName = editItem.StationName;
+                    find.FreqUpHz = editItem.FreqUpHz;
+                    find.Lon = editItem.Lon;
+                    find.Lat = editItem.Lat;
+                    find.Value = editItem.Value;
+                    find.Enable = editItem.Enable;
+                    find.UpdateTime = DateTime.Now;
+                    await db.SaveChangesAsync();
+                }
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, "保存固定站信息异常");
+                DxHelper.MsgBoxHelper.ShowError("保存固定站信息异常");
+            }
+        }
     }
 }

+ 7 - 2
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -249,8 +249,11 @@ namespace XdCxRhDW.App.UserControl
                             ds.Remove(item);
                         }
                     }
-                    mapControl1.DelPosItem(removeItems);
-                    mapControl1.AddPosItem(posRes);
+                    this.Invoke(new Action(() =>
+                    {
+                        mapControl1.DelPosItem(removeItems);
+                        mapControl1.AddPosItem(posRes);
+                    }));
                     if ((DateTime.Now - lasetUpdateTime).TotalSeconds > 5)
                     {
                         this.Invoke(new Action(() =>
@@ -638,6 +641,7 @@ namespace XdCxRhDW.App.UserControl
                             {
                                 dto.FixedStationDto = new X2D1FixedStationDto()
                                 {
+                                    FixedStationId=fixedStation.ID,
                                     FreqUp = fixedStation.FreqUpHz,
                                     Lon = fixedStation.Lon,
                                     Lat = fixedStation.Lat,
@@ -709,6 +713,7 @@ namespace XdCxRhDW.App.UserControl
                             return;
                         }
                         TaskStopHandleDto dto = new TaskStopHandleDto();
+                        dto.TaskType = (EnumTaskTypeDto)((int)tsk.TaskType);
                         dto.ID = tsk.ID;
                         var res = await HttpHelper.PostRequestAsync<AjaxResult>(svtItem.BaseHttpAddr + $"{url}/Stop", dto);
                         if (res.code != 200)

+ 51 - 29
XdCxRhDW.App/X2D1PosRef/X2D1PosHandle.cs

@@ -19,13 +19,13 @@ namespace XdCxRhDW.App
     /// </summary>
     public class X2D1PosHandle
     {
-        
+
         public int TaskId;
         //十分钟时间内的数据
-        private int TimeSeconds = 10 * 60;//十分钟
+        private int TimeSeconds = 30 * 60;//十分钟
         private bool isRuning = true;
 
-        BlockingCollection<X2D1NoXlNoParlPosDto> posDtos = new BlockingCollection<X2D1NoXlNoParlPosDto>();
+        BlockingCollection<X2D1NoXlNoParlPosDto> posItems = new BlockingCollection<X2D1NoXlNoParlPosDto>();
         public X2D1PosHandle(int taskId)
         {
             TaskId = taskId;
@@ -41,32 +41,46 @@ namespace XdCxRhDW.App
                 {
                     try
                     {
-                        var dto = posDtos.Take();
-
+                        var dto = posItems.Take();
                         FixedStation fixedStation;
+                        int fixedStationId = dto.FixedStationId.HasValue ? dto.FixedStationId.Value : 0;
                         using (RHDWContext db = new RHDWContext())
                         {
-                            fixedStation = await db.FixedStation.FirstAsync(f => f.ID == dto.FixedStationId.Value);
+                            fixedStation = await db.FixedStation.FirstOrDefaultAsync(f => f.ID == dto.FixedStationId.Value);
+                        }
+                        if (fixedStation == null)//没有固定站
+                        {
+                            SendX2D1NoXlNoParAsync(dto);
+                            continue;
                         }
-                        
-                        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();
+                            DateTime min = dto.SigTime.AddSeconds(-TimeSeconds);
+                            DateTime max = dto.SigTime.AddSeconds(TimeSeconds);
+                            //获取设定分钟之内的固定站数据
+                            var cgResRefs = await db.CgRes.Where(m => m.TaskID == dto.TaskID && m.FixedStationID == dto.FixedStationId && m.SigTime >= min && m.SigTime <= max).OrderBy(d => d.SigTime).ToListAsync();
 
                             List<CgRes> matchCgList = new List<CgRes>();
-                            cgRess.ForEach(c =>
+                            cgResRefs.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();
+                            var cgOrderList = matchCgList.OrderBy(d => d.SigTime).ToList();
+                            var point1 = cgOrderList.Where(c => c.SigTime <= dto.SigTime).FirstOrDefault();
+                            var point2 = cgOrderList.Where(c => c.SigTime >= dto.SigTime).FirstOrDefault();
+
+                            if (point1 == null || point2 == null)//若参考频点未出结果,查找目标信号出
+                            {
+                                bool isTarAny = await db.CgRes.AnyAsync(m => m.TaskID == dto.TaskID && m.TarFreqUp.HasValue&&m.TarFreqUp.Value== fixedStation.FreqUpHz &&  m.SigTime >= dto.SigTime);
+                                if (!isTarAny)//目标未出结果
+                                {
+                                    Append(dto);
+                                    continue;
+                                }
+                            }
                             bool isSucces = false;
                             if (point1 != null && point2 != null)
                             {
@@ -118,19 +132,7 @@ namespace XdCxRhDW.App
                             }
                             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}");
-                                }
-
+                                SendX2D1NoXlNoParAsync(dto);
                             }
 
                         }
@@ -143,9 +145,29 @@ namespace XdCxRhDW.App
                 }
             });
         }
+
+        /// <summary>
+        /// 发送两星一地无参定位
+        /// </summary>
+        /// <param name="dto"></param>
+        private async void SendX2D1NoXlNoParAsync(X2D1NoXlNoParlPosDto dto)
+        {
+            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}");
+            }
+        }
         public void Append(X2D1NoXlNoParlPosDto dto)
         {
-            bool ret = posDtos.TryAdd(dto);
+            bool ret = posItems.TryAdd(dto);
             if (!ret)
             {
                 Serilog.Log.Error($"【任务{dto.TaskID}】添加取参考Dto");

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä